summaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-11-01 10:35:52 -0600
committerRocky Madden <git@rockymadden.com>2012-11-01 10:35:52 -0600
commit2f8d5430acea7de95117067d4297232c96986799 (patch)
tree958e16e8deeecde0182bf0265d0b8bd687a9dfed /readme.md
parentad00f80beca08ad605d9f837c08aaf4c470b480e (diff)
downloadstringmetric-2f8d5430acea7de95117067d4297232c96986799.tar.gz
stringmetric-2f8d5430acea7de95117067d4297232c96986799.tar.bz2
stringmetric-2f8d5430acea7de95117067d4297232c96986799.zip
Example code clean up.
Diffstat (limited to 'readme.md')
-rwxr-xr-xreadme.md77
1 files changed, 49 insertions, 28 deletions
diff --git a/readme.md b/readme.md
index b1f6440..73c1fa4 100755
--- a/readme.md
+++ b/readme.md
@@ -62,51 +62,72 @@ Filters, which can optionally be applied, clean up arguments prior to evaluation
[SemVer](http://semver.org/)
## Building the API
-`gradle :stringmetric-core:jar`
+ gradle :stringmetric-core:jar
## Building the CLI
-`gradle :stringmetric-cli:tar`
+ gradle :stringmetric-cli:tar
## Using the API
-`// Import metric of choice.`
-`import org.hashtree.stringmetric.similarity.JaroWinklerMetric`
+ // Simple example. Import metric, compare, do something with result.
+ import org.hashtree.stringmetric.similarity.JaroWinklerMetric
+
+ val distance = JaroWinklerMetric.compare("string1", "string2")
-`// Import some filters, optionally.`
-`import org.hashtree.stringmetric.{ AsciiLetterCaseStringFilter, AsciiLetterOnlyStringFilter, StringFilterDelegate }`
+ if (distance >= 0.9) println("It's likely you're a match!")
-`// Invoke metric compare method without filters.`
-`val distance0 = JaroWinklerMetric.compare("string1", "string2")`
+*****
-`// Invoke metric compare method with filters to ignore non-letter characters and case.`
-`val distance1 = JaroWinklerMetric.compare("string1", "string2")`
-`(new StringFilterDelegate with AsciiLetterCaseStringFilter with AsciiLetterOnlyStringFilter)`
+ // One filter example. Import metric, compare with one filter, do something with result.
+ import org.hashtree.stringmetric.similarity.{ JaroWinklerMetric, StringFilterDelegate }
+ import org.hashtree.stringmetric.filter.AsciiLetterCaseStringFilter
-`// Invoke metric compare method with filters to ignore case.`
-`val distance2 = JaroWinklerMetric.compare("string1", "string2")`
-`(new StringFilterDelegate with AsciiLetterCaseStringFilter)`
+ val distance = JaroWinklerMetric.compare("string1", "string2")
+ (new StringFilterDelegate with AsciiLetterCaseStringFilter)
-`// All metrics have an overloaded compare method which accepts character arrays.`
-`val distance3 = JaroWinklerMetric.compare("string1".toCharArray, "string2".toCharArray)`
+ if (distance >= 0.9) println("It's likely you're a match!")
-`// Do something. In this case, distance is between 1.0 and 0.0.`
-`if (distance0 >= 0.9) println("It's likely you're a match!")`
+*****
+
+ // Compound filter example. Import metric, compare with two filters, do something with result.
+ import org.hashtree.stringmetric.similarity.{ JaroWinklerMetric, StringFilterDelegate }
+ import org.hashtree.stringmetric.filter.{ AsciiLetterCaseStringFilter, AsciiLetterOnlyStringFilter }
+
+ val distance = JaroWinklerMetric.compare("string1", "string2")
+ (new StringFilterDelegate with AsciiLetterCaseStringFilter with AsciiLetterOnlyStringFilter)
+
+ if (distance >= 0.9) println("It's likely you're a match!")`
+
+*****
+
+ // All string metrics and algorithms have an overloaded compare method which accepts character arrays.
+ import org.hashtree.stringmetric.similarity.JaroWinklerMetric
+
+ val distance = JaroWinklerMetric.compare("string1".toCharArray, "string2".toCharArray)
+
+ if (distance >= 0.9) println("It's likely you're a match!")
## Using the CLI
Uncompress the built tar and ensure you have ability to execute the commands. Execute the metric of choice via the command line:
-`// The help option prints command syntax and usage.`
-`jaroWinklerMetric --help`
-`metaphoneMetric --help`
-`metaphoneAlgorithm --help`
+ // The help option prints command syntax and usage.
+ jaroWinklerMetric --help
+ metaphoneMetric --help
+ metaphoneAlgorithm --help
+
+*****
+
+ // Compare "abc" to "xyz" using the Jaro-Winkler metric.
+ jaroWinklerMetric abc xyz`
+
+*****
-`// Compare "abc" to "xyz" using the Jaro-Winkler metric.`
-`jaroWinklerMetric abc xyz`
+ // Compare "abc "to "xyz" using the Metaphone metric.
+ metaphoneMetric abc xyz
-`// Compare "abc "to "xyz" using the Metaphone metric.`
-`metaphoneMetric abc xyz`
+*****
-`// Get the phonetic representation of "abc" via the metaphone phonetic algorithm.`
-`metaphoneAlgorithm abc`
+ // Get the phonetic representation of "abc" via the metaphone phonetic algorithm.
+ metaphoneAlgorithm abc
## Requirements
* Scala 2.9.2