Created
November 5, 2018 06:44
-
-
Save Treehopper/a2500ea8d594890b9eba3c870a8113e2 to your computer and use it in GitHub Desktop.
Test string for similarity with each line in a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
@Grab(group='info.debatty', module='java-string-similarity', version='1.1.0') | |
import info.debatty.java.stringsimilarity.* | |
def input = args[0] | |
def inputFile = new File('file.txt') | |
def csvFile = new File('file-smlr.csv') | |
def l = new Levenshtein() | |
csvFile.withPrintWriter { out -> | |
out.println("line from file;distance compared to " + input) | |
inputFile.eachLine { line -> | |
out.print(line) | |
out.print(";") | |
out.println(l.distance(input, line)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment