summaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2013-01-23 14:08:47 -0700
committerRocky Madden <git@rockymadden.com>2013-01-23 14:08:47 -0700
commitf7ea57ca37a26040b64a2ef17b76647ae1760a1a (patch)
tree47ea0851b24014d6a7f949a77ea61bb61f780c5f /readme.md
parent007768d50f0b9ada015c1470237d085cd0ea1182 (diff)
downloadstringmetric-f7ea57ca37a26040b64a2ef17b76647ae1760a1a.tar.gz
stringmetric-f7ea57ca37a26040b64a2ef17b76647ae1760a1a.tar.bz2
stringmetric-f7ea57ca37a26040b64a2ef17b76647ae1760a1a.zip
Added weighted Levenshtein examples.
Diffstat (limited to 'readme.md')
-rwxr-xr-xreadme.md22
1 files changed, 18 insertions, 4 deletions
diff --git a/readme.md b/readme.md
index 57d4bd8..12a7c63 100755
--- a/readme.md
+++ b/readme.md
@@ -37,7 +37,7 @@ println(HammingMetric.compare("toned", "roses"))
println(HammingMetric.compare("1011101", "1001001"))
```
-Output: _(Note the exception of integers, rather than doubles, being returned)_
+Output: _(Note the exception of integers, rather than doubles, being returned.)_
```shell
3
2
@@ -77,13 +77,13 @@ println(LevenshteinMetric.compare("sitting", "kitten"))
println(LevenshteinMetric.compare("cake", "drake"))
```
-Output: _(Note the exception of integers, rather than doubles, being returned)_
+Output: _(Note the exception of integers, rather than doubles, being returned.)_
```shell
3
2
```
-__N-Gram Metric:__ _(Note you must specify the size of the n-gram you wish to use)_
+__N-Gram Metric:__ _(Note you must specify the size of the n-gram you wish to use.)_
```scala
println(NGramMetric.compare("night", "nacht")(1))
println(NGramMetric.compare("night", "nacht")(2))
@@ -97,7 +97,7 @@ Output:
0.5
```
-__N-Gram Algorithm:__ _(Note you must specify the size of the n-gram you wish to use)_
+__N-Gram Algorithm:__ _(Note you must specify the size of the n-gram you wish to use.)_
```scala
println(NGramAlgorithm.compute("abcdefghijklmnopqrstuvwxyz")(1))
println(NGramAlgorithm.compute("abcdefghijklmnopqrstuvwxyz")(2))
@@ -123,6 +123,20 @@ Output:
0.6666666666666666
```
+__Weighted Levenshtein Metric:__ _(Note you must specify the weight of each operation. Delete, insert, and then substitute.)_
+```scala
+println(WeightedLevenshteinMetric.compare("book", "back")(10, 0.1, 1))
+println(WeightedLevenshteinMetric.compare("hosp", "hospital")(10, 0.1, 1))
+println(WeightedLevenshteinMetric.compare("hospital", "hosp")(10, 0.1, 1))
+```
+
+Output: _(Note that while a double is returned, it can be outside the range of 0 to 1, based upon the weights used.)_
+```shell
+2
+0.4
+40
+```
+
## Testing
```shell
$ gradle :stringmetric-core:test