src/parser/match_lines.rb
# Using levenshtein's calculation for string similarity the list of similar lines is calculated
# The list returned is an ordered hash table containing all the valid entries of line similarities
# mapped as:
# Positive Line Index => { Negative Line Index => Distance }
# Note that this method uses instable sorts
Using levenshtein's calculation for string similarity the list of similar lines is calculated
The list returned is an ordered hash table containing all the valid entries of line similarities
mapped as:
Positive Line Index => { Negative Line Index => Distance }
Note that this method uses instable sorts
Using levenshtein ' s calculation for string similarity the list of similar lines is calculated The list returned is an ordered hash table containing all the valid entries of line similarities mapped as : Positive Line Index = > { Negative Line Index = > Distance } Note that this method uses instable sorts
def findSimilarLines(posLines, negLines)
    similarityIndex = Array.new
    shortest = Hash.new
    i = 0
    j = 0
    posLines.each { |posLine|
        similarityIndex[i] = Array.new
        shortest[i] = Hash.new
        negLines.each { |negLine|
            similarityIndex[i][j] = levenshtein(posLine, negLine)
            largeLength = [posLine.length, negLine.length].max
            if similarityIndex[i][j] < getTreshold(largeLength)
                shortest[i][j] = similarityIndex[i][j]
            end
            j+=1
        }
        shortest[i] = constructHash(shortest[i].sort_by { |k,v| v })
        i+=1
        j=0
    }
    return constructHash(shortest.sort_by { |h,v| v.keys && v.values })
end
def findSimilarLines ( posLines , negLines ) similarityIndex = Array . new shortest = Hash . new i = 0 j = 0 posLines . each { | posLine | similarityIndex [ i ] = Array . new shortest [ i ] = Hash . new negLines . each { | negLine | similarityIndex [ i ] [ j ] = levenshtein ( posLine , negLine ) largeLength = [ posLine . length , negLine . length ] . max if similarityIndex [ i ] [ j ] < getTreshold ( largeLength ) shortest [ i ] [ j ] = similarityIndex [ i ] [ j ] end j += 1 } shortest [ i ] = constructHash ( shortest [ i ] . sort_by { | k , v | v } ) i += 1 j = 0 } return constructHash ( shortest . sort_by { | h , v | v . keys && v . values } ) end
Using levenshtein's calculation for string similarity the list of similar lines is calculated
The list returned is an ordered hash table containing all the valid entries of line similarities
mapped as:
Positive Line Index => { Negative Line Index => Distance }
Note that this method uses instable sorts
Using levenshtein ' s calculation for string similarity the list of similar lines is calculated The list returned is an ordered hash table containing all the valid entries of line similarities mapped as : Positive Line Index = > { Negative Line Index = > Distance } Note that this method uses instable sorts
#array of the indexs shorted by the shortest at 0 to the largest at n # Pick the the length of the longest line. # So additions that are smaller than the negative counter part are not favoured.  #Check if it is above HIGH_THRESHOLD #similarityIndex[i][j] = levenshtein(posLine, negLine) #puts "shortest = #{shortest[i]}" #puts "a shortest = #{shortest[i]}" #puts "bf shortest = #{shortest}"
posLines
<not_specific>
negLines
<not_specific>