14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
return False
if sWord in _dWord:
if sPattern:
return any(re.search(sPattern, sMorph) for sSimil in getSimil(sWord) for sMorph in _dMorph.get(sSimil, []))
return True
if sWord[0:1].isupper():
sWord = sWord.lower()
if sWord in _dWord:
if sPattern:
return any(re.search(sPattern, sMorph) for sSimil in getSimil(sWord) for sMorph in _dMorph.get(sSimil, []))
return True
return False
def getSimil (sWord):
"return list of words phonetically similar to sWord"
if not sWord:
return []
if sWord in _dWord:
return _lSet[_dWord[sWord]]
if sWord[0:1].isupper():
sWord = sWord.lower()
if sWord in _dWord:
return _lSet[_dWord[sWord]]
return []
def selectSimil (sWord, sPattern):
"return list of words phonetically similar to sWord and whom POS is matching sPattern"
if not sPattern:
return set(getSimil(sWord))
|
|
|
|
|
|
|
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
return False
if sWord in _dWord:
if sPattern:
return any(re.search(sPattern, sMorph) for sSimil in getSimil(sWord) for sMorph in _dMorph.get(sSimil, []))
return True
if sWord[0:1].isupper():
sWord = sWord.lower()
if sWord in _dWord:
if sPattern:
return any(re.search(sPattern, sMorph) for sSimil in getSimil(sWord) for sMorph in _dMorph.get(sSimil, []))
return True
return False
def getSimil (sWord):
"return list of words phonetically similar to sWord"
if not sWord:
return []
if sWord in _dWord:
return _lSet[_dWord[sWord]]
if sWord[0:1].isupper():
sWord = sWord.lower()
if sWord in _dWord:
return _lSet[_dWord[sWord]]
return []
def selectSimil (sWord, sPattern):
"return list of words phonetically similar to sWord and whom POS is matching sPattern"
if not sPattern:
return set(getSimil(sWord))
|