diff options
author | Rocky Madden <git@rockymadden.com> | 2014-01-06 09:28:22 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2014-01-06 09:28:22 -0700 |
commit | 6b60e4274f9bd61b435d5228952a7ee13d61d49b (patch) | |
tree | be084c2e3ff78d9299fc9f5e5d43fe31db566827 /readme.md | |
parent | 5718765df259757a0abec97ba1fd94a776eb14bd (diff) | |
download | stringmetric-6b60e4274f9bd61b435d5228952a7ee13d61d49b.tar.gz stringmetric-6b60e4274f9bd61b435d5228952a7ee13d61d49b.tar.bz2 stringmetric-6b60e4274f9bd61b435d5228952a7ee13d61d49b.zip |
More decorating section clean up.
Diffstat (limited to 'readme.md')
-rwxr-xr-x | readme.md | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -252,7 +252,7 @@ It is possible to decorate algorithms and metrics with additional functionality, --- -Non-decorated usage: +Non-decorated: ```scala MetaphoneAlgorithm.compute("abc123") MetaphoneMetric.compare("abc123", "abc456") @@ -260,14 +260,7 @@ MetaphoneMetric.compare("abc123", "abc456") --- -Memoized: -```scala -(MetaphoneAlgorithm withMemoization).compute("abc123") -``` - ---- - -Single filter, so that we only examine alphabetical characters: +Using a transform so that we only examine alphabetical characters: ```scala (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123") (MetaphoneMetric withTransform StringTransform.filterAlpha).compare("abc123", "abc456") @@ -275,7 +268,7 @@ Single filter, so that we only examine alphabetical characters: --- -Functionally composed filter, so that we only examine alphabetical characters but the case won't matter: +Using a functionally composed transform so that we only examine alphabetical characters, but the case will not matter: ```scala val composedTransform = (StringTransform.filterAlpha andThen StringTransform.ignoreAlphaCase) @@ -285,9 +278,8 @@ val composedTransform = (StringTransform.filterAlpha andThen StringTransform.ign --- -Make your own: +Making your own transform: ```scala -// StringTransform is a type alias for (Array[Char] => Array[Char]) val myTransform: StringTransform = (ca) => ca.filter(_ == 'x') (MetaphoneAlgorithm withTransform myTransform).compute("abc123") @@ -296,6 +288,13 @@ val myTransform: StringTransform = (ca) => ca.filter(_ == 'x') --- +Using memoization: +```scala +(MetaphoneAlgorithm withMemoization).compute("abc123") +``` + +--- + ## Convenience objects Convenience objects are available to make interactions with the library easier. |