[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testProximityLexicon.py:1.1.2.1

Andreas Jung andreas@digicool.com
Wed, 9 Jan 2002 20:51:13 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv9835

Added Files:
      Tag: ajung-textindexng-branch
	testProximityLexicon.py 
Log Message:
added


=== Added File Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testProximityLexicon.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################

import sys, os, unittest

from Products.PluginIndexes.TextIndexNG.ProximityLexicon import ProximityLexicon
import Proximity

class Tests(unittest.TestCase):


    def doTest(self,s, algorithm):
        """ """
    
        self._lexicon  = ProximityLexicon(algorithm)    
        PF = getattr(Proximity,algorithm)

        words = s.split()

        self.assertEqual(len(self._lexicon),0)
        


    def testSoundexAscii(self):
        """ Soundex Ascii test """

        s = 'the quick brown fox jumps over the lazy dog'
        self.doTest(s,'soundex')


    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')

        self.doTest(s,'soundex')


    def printLexicon(self):

        for k,v in self._lexicon._lexicon.items():
            print k.encode('latin1'),v
        
       

def test_suite():
   return unittest.makeSuite(Tests)

def main():
   unittest.TextTestRunner().run(test_suite())

def debug():
   test_suite().debug()

def pdebug():
    import pdb
    pdb.run('debug()')
   
if __name__=='__main__':
   if len(sys.argv) > 1:
      globals()[sys.argv[1]]()
   else:
      main()