60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
s = re.sub(r"isRealStart0 *\(\)", 'before0("^ *$")', s)
s = re.sub(r"isEnd *\(\)", 'after("^ *$|^,")', s)
s = re.sub(r"isRealEnd *\(\)", 'after("^ *$")', s)
s = re.sub(r"isEnd0 *\(\)", 'after0("^ *$|^,")', s)
s = re.sub(r"isRealEnd0 *\(\)", 'after0("^ *$")', s)
s = re.sub(r"(select|exclude)[(][\\](\d+)", '\\1(dTokenPos, m.start(\\2), m.group(\\2)', s)
s = re.sub(r"define[(][\\](\d+)", 'define(dTokenPos, m.start(\\1)', s)
s = re.sub(r"(morph|morphex|displayInfo)[(][\\](\d+)", '\\1((m.start(\\2), m.group(\\2))', s)
s = re.sub(r"(morph|morphex|displayInfo)[(]", '\\1(dTokenPos, ', s)
s = re.sub(r"(sugg\w+|switch\w+)\(@", '\\1(m.group(i[4])', s)
s = re.sub(r"word\(\s*1\b", 'nextword1(sSentence, m.end()', s) # word(1)
s = re.sub(r"word\(\s*-1\b", 'prevword1(sSentence, m.start()', s) # word(-1)
s = re.sub(r"word\(\s*(\d)", 'nextword(sSentence, m.end(), \\1', s) # word(n)
s = re.sub(r"word\(\s*-(\d)", 'prevword(sSentence, m.start(), \\1', s) # word(-n)
s = re.sub(r"before\(\s*", 'look(sSentence[:m.start()], ', s) # before(sSentence)
s = re.sub(r"after\(\s*", 'look(sSentence[m.end():], ', s) # after(sSentence)
|
|
|
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
s = re.sub(r"isRealStart0 *\(\)", 'before0("^ *$")', s)
s = re.sub(r"isEnd *\(\)", 'after("^ *$|^,")', s)
s = re.sub(r"isRealEnd *\(\)", 'after("^ *$")', s)
s = re.sub(r"isEnd0 *\(\)", 'after0("^ *$|^,")', s)
s = re.sub(r"isRealEnd0 *\(\)", 'after0("^ *$")', s)
s = re.sub(r"(select|exclude)[(][\\](\d+)", '\\1(dTokenPos, m.start(\\2), m.group(\\2)', s)
s = re.sub(r"define[(][\\](\d+)", 'define(dTokenPos, m.start(\\1)', s)
s = re.sub(r"(morph|displayInfo)[(][\\](\d+)", '\\1((m.start(\\2), m.group(\\2))', s)
s = re.sub(r"(morph|displayInfo)[(]", '\\1(dTokenPos, ', s)
s = re.sub(r"(sugg\w+|switch\w+)\(@", '\\1(m.group(i[4])', s)
s = re.sub(r"word\(\s*1\b", 'nextword1(sSentence, m.end()', s) # word(1)
s = re.sub(r"word\(\s*-1\b", 'prevword1(sSentence, m.start()', s) # word(-1)
s = re.sub(r"word\(\s*(\d)", 'nextword(sSentence, m.end(), \\1', s) # word(n)
s = re.sub(r"word\(\s*-(\d)", 'prevword(sSentence, m.start(), \\1', s) # word(-n)
s = re.sub(r"before\(\s*", 'look(sSentence[:m.start()], ', s) # before(sSentence)
s = re.sub(r"after\(\s*", 'look(sSentence[m.end():], ', s) # after(sSentence)
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
def createRule (s, nIdLine, sLang, bParagraph, dOptPriority):
"returns rule as list [option name, regex, bCaseInsensitive, identifier, list of actions]"
global dJSREGEXES
global nRULEWITHOUTNAME
sLineId = str(nIdLine) + ("p" if bParagraph else "s")
sRuleId = sLineId
#### GRAPH CALL
if s.startswith("@@@@"):
if bParagraph:
print("Error. Graph call can be made only after the first pass (sentence by sentence)")
exit()
|
|
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
def createRule (s, nIdLine, sLang, bParagraph, dOptPriority):
"returns rule as list [option name, regex, bCaseInsensitive, identifier, list of actions]"
global dJSREGEXES
global nRULEWITHOUTNAME
sLineId = "#" + str(nIdLine) + ("p" if bParagraph else "s")
sRuleId = sLineId
#### GRAPH CALL
if s.startswith("@@@@"):
if bParagraph:
print("Error. Graph call can be made only after the first pass (sentence by sentence)")
exit()
|