two new functions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Lightproof |
Invalid
|
Undecided
|
Unassigned |
Bug Description
In order to translate more easily some rules from LT, I created two functions :
The first one (“morphex”) checks if one of the morphologies of a word matches the first pattern and if all morphologies do NOT match the second pattern. That’s useful to exclude some kinds of words.
The second function (“stemchk”) searches if the stem matches the pattern. The strict parameter, as in the modified “morph” function, defines if all the stems must match the pattern or only one of them.
# search and exclude morphologies
def morphex(rLoc, word, pattern, negpattern):
global analyses
if word == None:
return False
if word not in analyses:
x = spellchecker.
if not x:
return None
t = x.getAlternatives()
if not t:
t = ['']
a = analyses[word]
# check negative condition
np = re.compile(
for s in a:
res = np.search(s)
if res:
return False
# search pattern
p = re.compile(pattern)
for s in a:
res = p.search(s)
if res:
return True
return False
# check pattern on stems
def stemchk(rLoc, word, pattern, strict=True):
global stems
if word == None:
return False
if word not in stems:
x = spellchecker.
if not x:
return False
t = x.getAlternatives()
if not t:
t = ['']
stems[word] = t
a = stems[word]
p = re.compile(pattern)
if strict:
for s in a:
res = p.search(s)
if not res:
return True
else:
for s in a:
res = p.search(s)
if res:
return False
Modify the first line of “prepare_for_eval” in Compile.py :
s = re.sub(
Unsuitable.