From d2dd100dbda2af16925ecb0f76925813d4d3c8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl> Date: Fri, 4 Aug 2006 16:25:43 +0000 Subject: [PATCH] Improved stripping of words for better display git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9054 20353a03-c40f-0410-a6d1-a30d3c3de9de --- bt5/erp5_dms/ExtensionTemplateItem/cutFound.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py b/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py index b2c4f8724e..346655d433 100644 --- a/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py +++ b/bt5/erp5_dms/ExtensionTemplateItem/cutFound.py @@ -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 @@ class Part: 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 @@ class Part: 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: -- 2.30.9