Example #1
0
 def testWithExistingLanguagesWithCaseFolding(self):
     T = Thesaurus('de', True)
     self.assertEqual(sorted(T.getTermsFor(u'Abrechnung')), [u'berechnung', u'bilanz', u'faktur', u'rechnung', u'schlussrechnung'])
     self.assertEqual(sorted(T.getTermsFor(u'abrechnung')), [u'berechnung', u'bilanz', u'faktur', u'rechnung', u'schlussrechnung'])
     
     # make sure all words are treated synonomyous by searching for a word that is not at the beginning of the line
     #Abrechnung Berechnung, Faktur, Rechnung
     #Abrechnung Bilanz, Schlussrechnung         
     self.assertEqual(sorted(T.getTermsFor(u'Faktur')), [u'abrechnung', u'berechnung', u'rechnung'])
     self.assertEqual(sorted(T.getTermsFor(u'faktur')), [u'abrechnung', u'berechnung', u'rechnung'])
Example #2
0
 def testWithNonExistingThesaurus(self):
     T = Thesaurus('foobar')
     self.assertRaises(ValueError, T._load)
     
     T = Thesaurus('en', filename='non/existent/path')
     self.assertRaises(ValueError, T._load)
Example #3
0
 def testFilenameConstructor(self):
     filename = os.path.join(os.path.dirname(__file__), 'data', 'thesaurus_de.txt')
     T = Thesaurus('de', filename=filename)
     self.assertEqual(sorted(T.getTermsFor(u'foo')), [u'bar', u'baz'])
Example #4
0
 def testWithExistingLanguagesNoCasefolding(self):
     T = Thesaurus('de',False)
     self.assertEqual(T.getTermsFor(u'abrechnung'), None)
     self.assertEqual(sorted(T.getTermsFor(u'Abrechnung')), [u'Berechnung', u'Bilanz', u'Faktur', u'Rechnung', u'Schlussrechnung'])