Merge branch 'regexpunct'

This commit is contained in:
Chrys 2019-10-22 00:27:24 +02:00
commit 8ee7823e21
2 changed files with 32 additions and 26 deletions

View File

@ -44,26 +44,31 @@ _:===:line
=:===:equals =:===:equals
[customDict] [customDict]
# This dictionary uses regexp, so be sure to escape anything that would be parsed by regexp, e.g. *, ., ^, $, etc.
[emoticonDict] [emoticonDict]
<{-.-}>:===:Raves # This dictionary uses regexp, so be sure to escape anything that would be parsed by regexp, e.g. *, ., ^, $, etc.
8-):===:smile with sunglasses .*[\s*|'|"][\s*|'|"]<{-.-}>.*:===:Raves
:-/:===:confused .*[\s*|'|"][\s*|'|"]8-\).*:===:smile with sunglasses
-.-:===:bugged .*[\s*|'|"][\s*|'|"]:-/.*:===:confused
>.<:===:laughing .*[\s*|'|"][\s*|'|"]-\.-.*:===:bugged
8-X:===:skull .*[\s*|'|"][\s*|'|"]>\.<.*:===:laughing
>:):===:evil smile .*[\s*|'|"][\s*|'|"]8-X.*:===:skull
>:-):===:evil smile .*[\s*|'|"][\s*|'|"]>:\).*:===:evil smile
\o/:===:Hurray .*[\s*|'|"][\s*|'|"]>:-\).*:===:evil smile
:/:===:confused .*[\s*|'|"][\s*|'|"]\\o/.*:===:Hurray
8):===:smile with sunglasses .*[\s*|'|"][\s*|'|"]:/.*:===:confused
:D:===:laugh .*[\s*|'|"][\s*|'|"]8\).*:===:smile with sunglasses
;):===:wink .*[\s*|'|"]:D[\s*|'|"].*:===:laugh
XD:===:LOL .*[\s*|'|"];\)[\s*|'|"].*:===:wink
:-):===:smile .*[\s*|'|"]XD[\s*|'|"].*:===:LOL
:):===:smile .*[\s*|'|"]:-\)[\s*|'|"].*:===:smile
->:===:arrow right .*[\s*|'|"]:\)[\s*|'|"].*:===:smile
<-:===:arrow left .*[\s*|'|"]->[\s*|'|"].*:===:arrow right
oO:===:WTF? # example for arrow left
Oo:===:WTF? #(?:[ |^])(<-)(?:[ ,.!?$]):===:arrow left
^^:===:enjoy smile # or
#([ |^])<-([ ,.!?$]):===:arrow left\2
.*[\s*|'|"]<-[\s*|'|"].*:===:arrow left
.*[\s*|'|"][O|o][O|o][\s*|'|"].*:===:WTF?
.*[\s*|'|"]\^\^[\s*|'|"].*:===:enjoy smile

View File

@ -34,14 +34,15 @@ class punctuationManager():
except: except:
pass pass
return text.translate(currAllPunctNone) return text.translate(currAllPunctNone)
def useCustomDict(self, text, customDict, seperator=''): def useCustomDict(self, text, customDict, seperator=''):
resultText = str(text) resultText = str(text)
if customDict: if customDict:
for key,item in customDict.items(): for key,item in customDict.items():
try:
resultText = re.sub(str(key), seperator + str(item) + seperator, resultText)
except:
resultText = resultText.replace(str(key),seperator + str(item) + seperator) resultText = resultText.replace(str(key),seperator + str(item) + seperator)
return resultText return resultText
def usePunctuationDict(self, text, punctuationDict, punctuation): def usePunctuationDict(self, text, punctuationDict, punctuation):
resultText = str(text) resultText = str(text)