Permalink
Browse files

Merge branch 'master' of github.com:gzvulon/IAI3-LM

  • Loading branch information...
2 parents f32df8c + 016d452 commit 984aff5348940ae27bc1f2bc18ffcf85be9effb0 @gzvulon committed Jun 23, 2011
Showing with 7 additions and 6 deletions.
  1. +2 −1 src/s_text_filter.py
  2. +5 −5 tests/st_text_filter.py
View
3 src/s_text_filter.py
@@ -13,6 +13,7 @@ def suffix_stem(terms):
(r'[a-z]*s$', 1, ''),(r'[a-z]+eed$', 3, 'ee'),(r'[a-z]*ed$', 2, ''),
(r'[a-z]*ing$', 3, ''), (r'[a-z]*at$', 2, 'ate'),(r'[a-z]*bl$', 2, 'ble'),
(r'[a-z]*iz$', 2, 'ize')]
+ suffixes = [ (re.compile(rx),n,s) for rx,n,s in suffixes ]
for term in terms:
for reg, cut, new_suffix in suffixes:
@@ -33,4 +34,4 @@ def word_list_filter(terms):
"on", "or", "such", "that", "the", "their", "then", "there",
"these", "they", "this", "to", "was", "will", "with"]
res = filter(lambda term: not term in black_list, terms)
- return res
+ return res
View
10 tests/st_text_filter.py
@@ -21,24 +21,24 @@ def tearDown(self):
def test_suffix_stem_simple_examples(self):
terms = ['sses', 'ies', 'ss', 's', 'meed', 'ed', 'ing', 'at', 'bl', 'iz']
- fixed_terms = s_text_filter.suffixStem(terms)
+ fixed_terms = s_text_filter.suffix_stem(terms)
self.assertEqual(fixed_terms, ['ss', 'i', 'ss', '', 'mee', '', '', 'ate', 'ble', 'ize'])
def test_suffix_stem_complex_example1(self):
terms = ['ssesessses']
- self.assertEqual(s_text_filter.suffixStem(terms), ['ssesesss'])
+ self.assertEqual(s_text_filter.suffix_stem(terms), ['ssesesss'])
def test_suffix_stem_complex_example2(self):
terms = ['ssesessss']
- self.assertEqual(s_text_filter.suffixStem(terms), ['ssesessss'])
+ self.assertEqual(s_text_filter.suffix_stem(terms), ['ssesessss'])
def test_suffix_stem_complex_example3(self):
terms = ['eeesseseed']
- self.assertEqual(s_text_filter.suffixStem(terms), ['eeessesee'])
+ self.assertEqual(s_text_filter.suffix_stem(terms), ['eeessesee'])
def test_suffix_stem_complex_example4(self):
terms = ['inging']
- self.assertEqual(s_text_filter.suffixStem(terms), ['ing'])
+ self.assertEqual(s_text_filter.suffix_stem(terms), ['ing'])
def test_word_list_filter1(self):
print '== test_word_list_filter1 =='

0 comments on commit 984aff5

Please sign in to comment.