summaryrefslogtreecommitdiff
path: root/sample/testapp.py
diff options
context:
space:
mode:
authorYoshiki Shibukawa <yoshiki@shibu.jp>2013-10-11 07:37:00 -0700
committerYoshiki Shibukawa <yoshiki@shibu.jp>2013-10-11 07:37:00 -0700
commitc697d308906ea526cb56778b3856ad908b958d94 (patch)
tree83ce3d5449fdd44b0fb7181fda07f93e889807b8 /sample/testapp.py
parenteebe65816ad97fa561c9c10b8a337138fb7cf9a3 (diff)
parentafa6d43a23ea7c7781b9faf23cf0adebaeaeef58 (diff)
downloadsnowballstemmer-c697d308906ea526cb56778b3856ad908b958d94.tar.gz
Merge pull request #1 from wallunit/master
Fixed typo in function call to _clear_cache().
Diffstat (limited to 'sample/testapp.py')
-rw-r--r--sample/testapp.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/sample/testapp.py b/sample/testapp.py
new file mode 100644
index 0000000..1566134
--- /dev/null
+++ b/sample/testapp.py
@@ -0,0 +1,28 @@
+import sys
+import re
+import snowballstemmer
+
+
+def usage():
+ print("testapp.py <algorithm> \"sentence\"...")
+
+def main():
+ argv = sys.argv
+ if len(argv) < 1:
+ usage()
+ return
+ algorithm = 'english'
+ if len(argv) > 2:
+ algorithm = argv[1]
+ argv = argv[2:]
+ else:
+ argv = argv[1:]
+ stemmer = snowballstemmer.stemmer(algorithm)
+ splitter = re.compile(r"[\s\.-]")
+ for arg in argv:
+ for word in splitter.split(arg):
+ if word == '':
+ continue
+ original = word.lower()
+ print(original + " -> " + stemmer.stemWord(original))
+main()