-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Access the stemmer of Terrier from PyTerrier (#382)
* Update index.py * added test cases * added documentation * fixes and testing other stemmers --------- Co-authored-by: Sean MacAvaney <sean.macavaney@gmail.com>
- Loading branch information
1 parent
4560df0
commit 5f9b35e
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
import pyterrier as pt | ||
import os | ||
import unittest | ||
from .base import BaseTestCase | ||
import warnings | ||
|
||
class TestTerrierWrappers(BaseTestCase): | ||
|
||
def test_stemming(self): | ||
stemmer = pt.TerrierStemmer.porter | ||
TESTS = { | ||
"abandoned": "abandon", | ||
"abandon": "abandon", | ||
"abergavenny": "abergavenni" | ||
} | ||
for i,j in TESTS.items(): | ||
self.assertEqual(j, stemmer.stem(i)) | ||
|
||
stemmer = pt.TerrierStemmer.none | ||
for i,j in TESTS.items(): | ||
self.assertEqual(i, stemmer.stem(i)) | ||
|
||
stemmer = pt.TerrierStemmer.portugese | ||
for i,j in TESTS.items(): | ||
self.assertTrue(len(stemmer.stem(i)) > 0) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |