Package miopia :: Package preprocessor :: Module QuoteAppointmentPreProcessor
[hide private]
[frames] | no frames]

Source Code for Module miopia.preprocessor.QuoteAppointmentPreProcessor

 1  ''' 
 2  Created on 10/12/2012 
 3   
 4  @author: david.vilares 
 5  ''' 
 6  import re 
 7  from PreProcessorDecorator import * 
 8   
 9   
10 -class QuoteAppointmentPreProcessor(PreProcessorDecorator):
11 ''' 12 classdocs 13 ''' 14
15 - def __init__(self,component):
16 ''' 17 Constructor 18 ''' 19 self.component = component
20
21 - def preprocess(self,text):
22 23 ptext = self.component.preprocess(text) 24 return self._process_quote_appointments(ptext)
25 26 27 # def _process_quote_appointments(self,lines): 28 # 29 # def quote_transformation(quote): 30 # words = quote.split() 31 # return '_'.join(words)[:-1]+unicode('_QUOTE"') 32 # 33 # plines = [] 34 # quote_pattern = re.compile(u'\"[a-zA-Z ;\u00C0-\uFFFF]+\"') 35 # for l in lines: 36 # quotes = quote_pattern.findall(l) 37 # for q in quotes: 38 # l = l.replace(q, quote_transformation(q)) 39 # plines.append(l) 40 # return plines 41 42
43 - def _process_quote_appointments(self,text):
44 45 def quote_transformation(quote): 46 words = quote.split() 47 return '_'.join(words)[:-1]+unicode('_QUOTE"')
48 49 quote_pattern = re.compile(u'\"[a-zA-Z ;\u00C0-\uFFFF]+\"') 50 quotes = quote_pattern.findall(text) 51 for q in quotes: 52 text = text.replace(q, quote_transformation(q)) 53 return text
54