[Erp5-report] r9054 - /erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 4 18:26:33 CEST 2006


Author: bartek
Date: Fri Aug  4 18:25:43 2006
New Revision: 9054

URL: http://svn.erp5.org?rev=9054&view=rev
Log:
Improved stripping of words for better display

Modified:
    erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py

Modified: erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py?rev=9054&r1=9053&r2=9054&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py (original)
+++ erp5/trunk/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py Fri Aug  4 18:25:43 2006
@@ -1,4 +1,7 @@
+import string
 
+redundant_chars='"\'.:;,-' # chars we need to strip from a word before we see if it matches
+tr=string.maketrans(redundant_chars,' '*len(redundant_chars))
 
 class Done(Exception):
   pass
@@ -28,8 +31,6 @@
       self.chain.pop()
 
   def add(self,w):
-    #import pdb
-    #pdb.set_trace()
     self.chain.insert(0,FoundWord(w))
     self.limit+=self.trail+1
     self.has=True
@@ -37,9 +38,11 @@
   def __str__(self):
     return '...%s...' % ' '.join(map(str,self.chain))
 
+
+
 def generateParts(context,text,sw,tags,trail,maxlines):
   par=Part(tags,trail)
-  test=lambda w:w.strip().replace('"','').replace("'","") in sw
+  test=lambda w:w.translate(tr).strip() in sw
   i=0
   for aw in text:
     if i==maxlines:




More information about the Erp5-report mailing list