1 '''
2
3 @author: David Vilares Calvo
4 '''
5
6 from PreProcessorI import *
7
9 '''
10 classdocs
11 '''
12
13
14
16 '''
17 Constructor
18 '''
19 raise NotImplementedError
20
21
22 - def _build_new_text(self,text,old_string,new_string, maxreplace=None):
23
24 try:
25 index_beginning = text.index(old_string)
26 add_beginning_punkt = self._include_beginning_punct(text, index_beginning)
27 index_ending = index_beginning + len(old_string)
28 add_ending_punkt = self._include_ending_punct(text, index_ending)
29 except ValueError:
30 return text
31 if add_beginning_punkt:
32 new_string = ' . '+new_string
33 if add_ending_punkt:
34 new_string = new_string+' . '
35 if maxreplace ==None:
36 text = text.replace(old_string,new_string)
37 else:
38 text = text.replace(old_string,new_string,1)
39 return text
40
41
42
43
44
45
46
47
48
49
50
52 return (not text[0:i].strip().endswith('.') and i!=0)
53
55 return (not text[i:].strip().startswith('.'))
56
58 raise NotImplementedError
59