[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testProximityLexicon.py:1.1.2.2
Andreas Jung
andreas@digicool.com
Thu, 10 Jan 2002 13:07:30 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv29951/tests
Modified Files:
Tag: ajung-textindexng-branch
testProximityLexicon.py
Log Message:
update
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testProximityLexicon.py 1.1.2.1 => 1.1.2.2 ===
class Tests(unittest.TestCase):
+ _metaphoneAscii= {
+ 'brown' : ['braun','Brun','braune','browne'],
+ 'quick' : ['qicke','quicke','quicky','kik','kuik'],
+ }
+
+ _metaphoneLatin1= {
+ 'alle' : ['ale','ahle','aale','al'],
+ 'einen' : ['eihnen','einnen','eihnnen'],
+ 'zerstört' : ['zerstoert','zerstörd','zersdörd','zerzdoerd'],
+ }
+
+ _soundexAscii = {
+
+ }
+
+ _soundexLatin1 = {
+
+ }
def doTest(self,s, algorithm):
""" """
@@ -28,7 +46,22 @@
words = s.split()
self.assertEqual(len(self._lexicon),0)
-
+
+ self.WIDS = {}
+ for word in words:
+ self.WIDS[word] = self._lexicon.getWordId(word)
+
+ for word,wid in self.WIDS.items():
+ self.assertEqual( wid, self._lexicon.getWordId(word))
+
+
+ def algorithmTest(self,d):
+
+ for key,words in d.items():
+
+ for word in words:
+ wid = self._lexicon.getWordId(word)
+ self.assertEqual( wid, self.WIDS[key] ,(word,key))
def testSoundexAscii(self):
@@ -36,15 +69,31 @@
s = 'the quick brown fox jumps over the lazy dog'
self.doTest(s,'soundex')
+ self.algorithmTest(self._soundexAscii)
def testSoundexLatin1(self):
""" Soundex Latin1 test """
- s = ( 'Bei den dreitägigen Angriffen seien auch bis'
- ' auf einen alle Flugplätze der Taliban zerstört worden')
-
+ s = ( 'auf einen alle Flugplätze der Taliban zerstört worden')
self.doTest(s,'soundex')
+ self.algorithmTest(self._soundexLatin1)
+
+
+ def testMetaphoneAscii(self):
+ """ Soundex Ascii test """
+
+ s = 'the quick brown fox jumps over the lazy dog'
+ self.doTest(s,'metaphone')
+ self.algorithmTest(self._metaphoneAscii)
+
+
+ def testMetaphoneLatin1(self):
+ """ Soundex Latin1 test """
+
+ s = 'auf einen alle Flugplätze der Taliban zerstört worden'
+ self.doTest(s,'metaphone')
+ self.algorithmTest(self._metaphoneLatin1)
def printLexicon(self):