text_alignment 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/text_alignment/text_alignment.rb +4 -1
 - data/lib/text_alignment/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c4b2cdf0c257b74c6bec90b93d1907787f3c102108046731c2755684a1b156e9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 85334dad09a046432503183e3d3ad83841612299038f2f2dac1f9d5d208e1939
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9272bdd6c56717b53d39b3f2009259accb608ea86b99758b6a7ee9cee1e7b275330db55af4e0eba1eba80ee69275a21a3179243394d24139b3018996f659abe1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a6a9d97d2bf81ac0c2972fd6e9d5202116156d8ff2e5e81a9bf0306e313dbc601522f887bcbcebff8b9d888cc06826a8ce69ba908dce29fa8decad85d53008af
         
     | 
| 
         @@ -354,12 +354,15 @@ class TextAlignment::TextAlignment 
     | 
|
| 
       354 
354 
     | 
    
         
             
            	end
         
     | 
| 
       355 
355 
     | 
    
         | 
| 
       356 
356 
     | 
    
         
             
            	def alignment_similarity(_s1, _s2, alignment)
         
     | 
| 
      
 357 
     | 
    
         
            +
            		return 0 if alignment.sdiff.nil?
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
       357 
359 
     | 
    
         
             
            		# compute the lcs only with non-whitespace letters
         
     | 
| 
       358 
360 
     | 
    
         
             
            		lcs = alignment.sdiff.count{|d| d.action == '=' && d.old_element =~ /\S/ && d.new_element =~ /\S/}
         
     | 
| 
       359 
361 
     | 
    
         | 
| 
       360 
362 
     | 
    
         
             
            		s1 = _s1.tr(@padding_letter1, ' ')
         
     | 
| 
       361 
363 
     | 
    
         
             
            		s2 = _s2.tr(@padding_letter2, ' ')
         
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
            		similarity = 2 * lcs / (s1.scan(/\S/).count + s2.scan(/\S/).count).to_f
         
     | 
| 
       363 
366 
     | 
    
         
             
            	end
         
     | 
| 
       364 
367 
     | 
    
         | 
| 
       365 
368 
     | 
    
         
             
            end
         
     |