Skip to content

Commit 459c9e8

Browse files
committed
- removed popculture() and cocktail() entities
- removed popculture() entities - removed cocktail() entities - changed example_chatbot_5 to be an example for tone() instead of popculture() - updated test_entities to ignore cocktail and popculture
1 parent 7f12f44 commit 459c9e8

File tree

3 files changed

+18
-80
lines changed

3 files changed

+18
-80
lines changed

examples/example_chatbot_5.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@
88

99
if __name__ == "__main__":
1010

11-
user_text = 'Hasta la vista baby!'
11+
user_text = 'Már órák óta várok! Kérem adjon információt arról, hogy mennyi az egyenlegem. Köszönöm.'
1212

1313
###
1414

15-
references = entities.popculture()
16-
references_match= parser.Intents(references).match_set(user_text)
15+
tone = entities.tone()
16+
tone_match = parser.Intents(tone).match_best(user_text,1) # match_best
17+
common = entities.common()
18+
common_match= parser.Intents(common).match_set(user_text)
1719

18-
if references_match:
19-
print('Értem, egy másik AI-ra utaltál az üzenetedben.')
20-
if 'terminator' in references_match:
21-
print('Visszatérek!')
22-
else:
23-
print('Ez egy valós üzenetnek tűnik!') # nem fogja kiírni
20+
if 'formal' in tone_match:
21+
if 'profanity' in common_match:
22+
print('Elnézését kérem a kellemetlenségét, de nem szükséges káromkodnia.') # nem fogja kiírni
23+
print('Kérése feldolgozása folyamatban van.')
24+
elif 'informal' in tone_match:
25+
if 'profanity' in common_match:
26+
print('Sajnálom, hogy hibáztam, de azért nem kell így beszélni.') # nem fogja kiírni
27+
print('Kérésedet elkezdtük feldolgozni.') # nem fogja kiírni
28+
else: # nem eldönthető
29+
if 'profanity' in common_match:
30+
print('Elnézést kérünk a kellemetlenségért.') # nem fogja kiírni
31+
print('Kérés feldolgozása...') # nem fogja kiírni

lara/entities.py

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -136,76 +136,6 @@ def smalltalk():
136136
"can_you_understand_me":[{"stem":"(meg)?[eé]rt(e(d|sz|t+ed?)|i)\,?((\shogy)?\sa?mit\s([ií]r|mond)\w+|\smagyarul)","wordclass":"regex"}]
137137
}
138138

139-
# cocktail party tricks
140-
def cocktail():
141-
return {
142-
"random" : [{"stem":"(mondj([aá]l|on)?|v[aá]las+z([aá]l|on)?|tal[aá]lj([aá]l|on)?\ski|gondolj([aá]l|on)?)\s.*?(egy\s)?sz[aá]m\w*","wordclass":"regex"}],
143-
"random_coin" : [{"stem":"fej vagy írás"},{"stem":"írás vagy fej"},{"stem":"(dob[dj]([aáo][dln])?(\sf?el)?|p[oö]rges+([eé][dln])(\smeg)?|forgas+([aáo][dln])?(\smeg)?)(\segy|\saz?)?\s(p[eé]nzt?|(p[eé]nz)?[eé]rm[eé]t)","wordclass":"regex"},{"stem":"ha\s(fej|[ií]r[aá]s).+?ha\s(fej|[ií]r[aá]s)","wordclass":"regex"}],
144-
"random_dice" : [{"stem":"(dob[oó])?kock[aá]\w*","wordclass":"regex","inc":[{"stem":"(dob[dj]|gur[ií]ts)([aáo][dln]?)?","wordclass":"regex"},{"stem":"(\d+|oldal[auú]s?)","wordclass":"regex"}],"exc":[{"stem":"([eé]rm[eé]|p[eé]nz|fej)\w*","wordclass":"regex"}]},{"stem":"(dob[dj]|gur[ií]ts)([aáo][dln]?)?\.+?(\d+|hat\s?o\w+)","wordclass":"regex","exc":[{"stem":"([eé]rm[eé]|p[eé]nz|fej)\w*","wordclass":"regex"}]},{"stem":"dice","inc":[{"stem":"roll"},{"stem":"random"}]}],
145-
"random_card" : [{"stem":"(h[uú]z+([aáo][dln])?|v[aá]las+z([aáo][dln])?)(\ski)?(\segy|\saz?)?\s(lapot|k[aá]rty[aá](lapo(ka)?)?t)","wordclass":"regex"}],
146-
"timer_add" : [{"stem":"(id[oöő]z[ií]t([oöő]|[eé]s)t|riaszt([aá]s|[oó])t|cs[oöe]ng([oöő]|et[eé]s)t|alarm(o?t)?|[eé]bres+z\w*)","wordclass":"regex","inc":[{"stem":"([aá]l+[ií](ts|c+s+)([aáo]?[ldn]?)?|csin[aá]lj([aáo][dln]?)?|rakj([aáo][dln]?)?|hoz+([aáo][dln]?)?\sl[eé]tre|v[eé]gy([eé][dln]?)|\sfel)(\sbe|\sfel)?","wordclass":"regex"},{"stem":"set|on|enable|start","wordclass":"regex"}]},{"stem":"sz[oó]l?j+([aáo][dln])?\s?(r[aá]m\s|nekem\s)?.+?(m[uú]lva|bel[uü]l)","wordclass":"regex"},{"stem":"kel+\.+?kel[nj][ei]\w*","wordclass":"regex","exc":[{"stem":"mikor"},{"stem":"hánykor"}]}],
147-
"timer_remove" : [{"stem":"(id[oöő]z[ií]t([oöő]|[eé]s)t|riaszt([aá]s|[oó])t|cs[oöe]ng([oöő]|et[eé]s)t|alarm(o?t)?|[eé]bres+z\w*)","wordclass":"regex","inc":[{"stem":"([aá]l+[ií](ts|c+s+)([aáo]?[ldn]?)?\sle|kapcsol\w+\s?(m[aá]r\s)?(ki|le)|t[oö]r[oö]l\w+|of{2}\w*|ki(kapcs\w*)?)","wordclass":"regex"},{"stem":"of{2}|disable|delete|remove","wordclass":"regex"}]}],
148-
"calendar_info" : [{"stem":"(megbesz[eé]l[eé]st?|me+ting\w*|id[oőö]pont(ok)?|napt[aá]r|[kc]al+end[aá]r|tal[aá]lkoz[oó]|te+nd[oöő]|esem[eé]ny)\w*","wordclass":"regex","inc":[{"stem":"(mi(ke?)?t?\s(van(nak)?|[ií]r\w*)|van(nak)?\s(\w+\s)?m[aá](ra)?|m[aá](i|ra)|valami|mutas(s?a)?d|olvas(s?a)?d)|lek[eé]r\w*|list[aá]\w*|olvas\w*","wordclass":"regex"}]},{"stem":"(mai\s(feladat|program)\w*|(feladat|program)\w*\s(az?\s)?m[aá]i?(ra)?)","wordclass":"regex"}],
149-
"calendar_add" : [{"stem":"(megbesz[eé]l[eé]st?|me+ting\w*|id[oőö]pont(ok)?|napt[aá]r|[kc]al+end[aá]r|tal[aá]lkoz[oó]|te+nd[oöő]|esem[eé]ny)\w*","wordclass":"regex","inc":[{"stem":"([ií]r[dj]([aáou][dkln]?)?\s(be|fel|meg)|iktas+d?\sbe|ve(d+|gy[eéuü][dkln]?)\sfel|ad(j[aáou])?[dkln]?|hoz+([aáou][lkdn]?)?\sl[eé]tre)","wordclass":"regex"},{"stem":"(felv[eé][stv]|hoz+[aá]\s?ad|[ií]r[aá]s|foglal)\w*","wordclass":"regex"}]}],
150-
"calendar_remove": [{"stem":"(megbesz[eé]l[eé]st?|me+ting\w*|id[oőö]pont(ok)?|napt[aá]r|[kc]al+end[aá]r|tal[aá]lkoz[oó]|te+nd[oöő]|esem[eé]ny)\w*","wordclass":"regex","inc":[{"stem":"(t[oö]r[oö]l[jd]([eéoöuü][dkln]?)?|(v|sz)e(d+|gy[eéuü][dkln]?)\s(ki|le)|\w*t[oö]rl[eé]s\w*)","wordclass":"regex"}]}],
151-
"calendar_modify": [{"stem":"(megbesz[eé]l[eé]st?|me+ting\w*|id[oőö]pont(ok)?|napt[aá]r|[kc]al+end[aá]r|tal[aá]lkoz[oó]|te+nd[oöő]|esem[eé]ny)\w*","wordclass":"regex","inc":[{"stem":"([ií]r[dj]([aáou][dkln]?)?\s[aá]t|te(gy[euü]k?)?d*\s[aá]t|szerkes+z\w+|m[oó]dos[ií][ct]\w+|rak(j[aáou])?[lkdn]?\s[aá]t)|[aá]t[ií]r[aá]s\w*","wordclass":"regex"}]}],
152-
"calendar_date" : [{"stem":"hányadika van"},{"stem":"mai dátum"}],
153-
"calendar_day" : [{"stem":"(mi(ly|j)?en\snap(ot)?\s(van|[ií]runk))|(mit?\s(van|[ií]runk)(\sa)?\sma\w*)","wordclass":"regex"},{"stem":"mik?\s(van(nak)?|lesz(nek)?|volt(ak)?|t[oö]rt[eé]nt(ek)?)(\sa)?\sm[aá](i(\snapon)?|ra)?","wordclass":"regex"}],
154-
"calendar_holiday": [{"stem":"mi(nek az?|t|lyen)\s([uü]n+ep(l?[uü]nk|e|nap(ja)?)?|napj[aá]t?)","wordclass":"regex"},{"stem":"(piros\s?bet[uüú]s|[uü]n+ep(nap)?|nevezetes\snap)\svan","wordclass":"regex"}],
155-
"weather" : [{"stem":"időjárás","affix":["jelentés"],"wordclass":"noun"},{"stem":"(milyen|j[oó]|sz[eé]p)\s?(lesz\s)?(az\s)?id[oöő](nk)?(\slesz)?","wordclass":"regex"},{"stem":"h[aá]ny\sfok(os)?\s(van|lesz)","wordclass":"regex"}],
156-
"weather_rain" : [{"stem":"(sz[uü]ks[eé]g(em|[uü]nk)?|(fog\s)?kel+(eni)?(\sfog)?|vigyek(\smagam+al)?)(\slesz|\svan)?(\segy)?\s(es)?erny[oöő](t|re)?","wordclass":"regex"},{"stem":"(fog\s?(ma\s)?esni|esik\sma|esni\sfog(\sma)?)(\s(az\s)?es[oöő])?","wordclass":"regex","exc":[{"stem":"hó"}]},{"stem":"(v[aá]rhat[oó]|mond+(ot+|tak|anak)?)","wordclass":"regex","inc":[{"stem":"eső","wordclass":"noun"}]}],
157-
"weather_snow" : [{"stem":"havaz(ni|ik|[aá]s|ot+)","wordclass":"regex"},{"stem":"(fog(\sma\s)?esni|esik\sma|esni\sfog(\sma)?)\s(a\s)?h[oó]","wordclass":"regex"},{"stem":"(v[aá]rhat[oó]|mond+(ot+|tak|anak)?)","wordclass":"regex","inc":[{"stem":"h[oó]|havaz\w+","wordclass":"regex"}]}],
158-
"weather_sunny": [{"stem":"(s[uü]t(ni)?\s(fog\s?)?(\-?e\s)?(\w+\s)?(a\s)?nap|(der[uüú]s|meleg)\s(id[oöő]\s)?(v[aá]rhat[oó]|lesz(\sma)?|van(\smost)?(\s(oda)?kin+t?)?))","wordclass":"regex"}],
159-
"news" : [{"stem":"hír","affix":["adó"],"wordclass":"noun"},{"stem":"újság","prefix":["hír"],"wordclass":"noun"},{"stem":"valami\w*\s[uú]j((don)?s[aá]g(ot)?)?","wordclass":"regex"},{"stem":"(t[oö]rt[eé]nt(ek)?\s|volt(ak)?\s)(ma\s)?(valami\s)?([uú]j(dons[aá]g)?\s)?(az?\s)?((nagy)?vil[aá]gban|fontos|esem[eé]ny|napokban)","wordclass":"regex"}],
160-
"joke" : [{"stem":"vicc","wordclass":"noun","exc":[{"stem":"(ez\s(csak\s)?valami|ros+z)","wordclass":"regex"}]},{"stem":"vid[ií][ct]s+([aáo][dln])?\s?fel","wordclass":"regex"},{"stem":"nevet+es+([eé][dln])?\s?meg","wordclass":"regex"},{"stem":"felvid[ií]t(hat|a)(sz|n[aá][dl]?)","wordclass":"regex"},{"stem":"valami mókásat"}],
161-
"summary" : [{"stem":"(mi\sa.+?\sl[eé]nyege?)|(mir[oöő]l\ssz[oó]l\saz?)","wordclass":"regex"},{"stem":"összefoglal","wordclass":"noun"},{"stem":"foglal\w+\s[oö]s+ze","wordclass":"regex"},{"stem":"mond(j[ao]?)?[dn]?\sel\s(r[oö]viden|t[oö]m[oö]ren|egyszer[uüű]en|[oö]s+zefoglalva)","wordclass":"regex"}],
162-
"zodiac" : [{"stem":"horosz","affix":["pók","kóp"],"match_stem":False,"wordclass":"noun"},{"stem":"csillagok","affix":["ban"],"inc":[{"stem":"ír","wordclass":"verb"},{"stem":"mond","wordclass":"verb"}]},{"stem":"aszcendens","wordclass":"noun"}],
163-
"translate" : [{"stem":"(le)?ford[ií]t(s?[aáo]?[dln]?|ani|an[aá][dl]?)","wordclass":"regex"},{"stem":"hogy(an)?\s(van|(kel+\s)?mond(od|an[aá]d?|j[aá]k?|ani))\s(az\s)?\w+l\s\,?(hogy\s|az?\s)?","wordclass":"regex"},{"stem":"mit?\s(a\s)?jelent\s\w+l\s\,?(hogy\s|az?\s)?","wordclass":"regex"}],
164-
"shop" : [{"stem":"(meg\s?)?((hol|ho(l|n+an)\studok|ho(l|n+an)\slehet|szeretn[eé][km]|akaro[km])\s?)?(ve(n+i|hetn?[eé][km])|v[aá]s[aá]rol(ni|hatn?[aáo][km]))(\smeg)?(\sszeretn[eé][km]|akaro[km])","wordclass":"regex"},{"stem":"(vegy[eé][dln]?|(meg)?v(e|[aá]s[aá]rol)n+(i|[aáeé][km]))","wordclass":"regex","exc":[{"stem":"fel"},{"stem":"(nagy)?l[eé][lv]eg\w+","wordclass":"regex"}]}],
165-
"music" : [{"stem":"zene","wordclass":"noun"},{"stem":"(kezdj(\sel)?\s)?(le)?j[aá]ts+z([aáo][dln]?|ani)?(\sle)?\s","wordclass":"regex"},{"stem":"(be)?(tegy[eé][dl]|tehetn[eé][dln]?|ted+|rakj?[aáo]?[dln]?|rakhatn[aá][dl]?)(\sbe)?\s(valamit?\s)?\w[lt]","wordclass":"regex"},{"stem":"j[aá]ts+z\w*\s(le|valamit?)","wordclass":"regex"}],
166-
"sing" : [{"stem":"ének","wordclass":"verb","prefix":["el"],"affix":["et"]},{"stem":"dalol","wordclass":"verb","prefix":["el"]}],
167-
"directions" : [{"stem":"((mer+e\s(kel+\smen\w+|van))|((hogy(an)?|mivel|mer+e)\s(lehet\s|kel+\s)?(el)?jut(hat)?(n?[aáeéoi][km]?)(\sel)?))","wordclass":"regex"},{"stem":"([uú]tvonal\s?(meg)?terv\w*|tervez\w*\s(meg\s)?(az?\s)[uú]t(vonal)?at)","wordclass":"regex"}]
168-
}
169-
170-
# pop culture AI references
171-
def popculture():
172-
return {
173-
"turing" : [{"stem":"Turing","affix":["teszt"]},{"stem":"Enigma"}],
174-
"matrix" : [{"stem":"Neo","wordclass":"noun"},{"stem":"Oracle"},{"stem":"Morpheus"},{"stem":"Trinity"}],
175-
"terminator" : [{"stem":"Terminator","wordclass":"noun"},{"stem":"Connor","inc":[{"stem":"John"},{"stem":"Sarah"}]},{"stem":"Skynet","wordclass":"noun"},{"stem":"T\-(600|800|850|1000|1001|5000)","wordclass":"regex"},{"stem":"h?asz?ta\s?lr?a\s?vis+z?t?a\,?\sb[aeé]b[iy]","wordclass":"regex"}],
176-
"mrrobot" : [{"stem":"Elliot"},{"stem":"Mr\.?\s?Robot","wordclass":"regex"}],
177-
"bladerunner" : [{"stem":"Voight[\-\s]?Kampf+","wordclass":"regex"},{"stem":"replikáns","wordclass":"noun"},{"stem":"Deckard"},{"stem":"Rachael"}],
178-
"starwars" : [{"stem":"(R2[\-\s]?D2|B{2}[\-\s]?8|C[\-\s]?3PO)","wordclass":"regex"}],
179-
"drwho" : [{"stem":"dalek","affix":["s"]},{"stem":"cyberman"}],
180-
"spaceodyssey" : [{"stem":"monolit","affix":["h"]},{"stem":"HAL 9000"},{"stem":"nyisd ki a zsilipkaput"},{"stem":"David Bowman"},{"stem":"Űrodüsszeia","wordclass":"noun"},{"stem":"Frank","inc":[{"stem":"hallasz"}]}],
181-
"undertale" : [{"stem":"Mettaton"}],
182-
"portal" : [{"stem":"GLaDOS"},{"stem":"Cave Johnson"},{"stem":"Chell"},{"stem":"Wheatley"},{"stem":"(weighte(ne)?d\s?)?companion\s?cube","wordclass":"regex"}],
183-
"mgs" : [{"stem":"Big Boss"},{"stem":"S+n+a+k+e+","wordclass":"regex"},{"stem":"Raiden"},{"stem":"Ocelot"},{"stem":"Otacon"},{"stem":"nanomachines"}],
184-
"systemshock" : [{"stem":"SHODAN"},{"stem":"Von Braun"}],
185-
"deusex" : [{"stem":"JC\.?\s?Denton","wordclass":"regex"},{"stem":"Adam Jensen"}],
186-
"jarvis" : [{"stem":"Jarvis"}],
187-
"google" : [{"stem":"ok(ay|[eé])?\sgo+gle","wordclass":"regex"},{"stem":"go+gle\s(home|as+istant|as+zisztens)","wordclass":"regex"}],
188-
"alexa" : [{"stem":"Alexa","wordclass":"noun"}],
189-
"siri" : [{"stem":"Siri","wordclass":"noun"},{"stem":"Steve Jobs"}],
190-
"cortana" : [{"stem":"Cortana","wordclass":"noun"},{"stem":"Master Chief"},{"stem":"John[\-\s]?117","wordclass":"regex"},{"stem":"Clippy"}],
191-
"gits" : [{"stem":"Motoko","wordclass":"noun"},{"stem":"Kusanagi","wordclass":"noun"},{"stem":"Batou"},{"stem":"Tachikoma","wordclass":"noun"},{"stem":"(the\s)?pup+ete+r","wordclass":"regex"},{"stem":"bábjátékos","wordclass":"noun"}],
192-
"dragonball" : [{"stem":"Android 1[678]","wordclass":"regex"}],
193-
"evangelion" : [{"stem":"evangelion"},{"stem":"NERV"}],
194-
"flcl" : [{"stem":"Canti"}],
195-
"cowboybebop" : [{"stem":"Spike"},{"stem":"Faye Valentine"},{"stem":"Edward"}],
196-
"megaman" : [{"stem":"Megaman","wordclass":"noun"}],
197-
"chobits" : [{"stem":"Chi+","wordclass":"regex"},{"stem":"chobit"},{"stem":"persocom"}],
198-
"kizunaai" : [{"stem":"Kizuna"}],
199-
"hatsunemiku" : [{"stem":"Hatsune"},{"stem":"Vocaloid"}],
200-
"astroboy" : [{"stem":"Astro Boy"}],
201-
"onepunchman" : [{"stem":"Genos"}],
202-
"doraemon" : [{"stem":"Doraemon"}],
203-
"her" : [{"stem":"Samantha","wordclass":"noun"},{"stem":"Theodore"},{"stem":"Scarlett Johansson"}],
204-
"tron" : [{"stem":"Tron","wordclass":"noun"},{"stem":"Master Control Program"},{"stem":"Mester Kontroll Program"},{"stem":"end of line"}],
205-
"rickmorty" : [{"stem":"You pass butter"},{"stem":"vaj","affix":["at"],"inc":[{"stem":"ad","wordclass":"verb","prefix":["ide","oda","nekem","át"]}]}],
206-
"knightrider" : [{"stem":"k(night)?[\s\.]?i(ndustries)?[\s\.]?t(wo)?[\s\.]?t(housand)?[\s\.]?","wordclass":"regex"},{"stem":"SPM fokozat","affix":["ba"]}]
207-
}
208-
209139
# smiley and emoji references
210140
def emoji():
211141
return {

tests/test_entities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def validate_intent_item(item,intent):
5656
print(intent,'probably has a regex "wordclass" declared otherwise in',item['stem'])
5757

5858
@pytest.mark.parametrize("entity", [
59-
"common","commands","counties","dow","smalltalk","cocktail","popculture","emoji","disallow","tone"
59+
"common","commands","counties","dow","smalltalk","emoji","disallow","tone"
6060
])
6161
def test_entities(entity):
6262
parenthesis_check = eval('parser.Intents(entities.'+entity+'()).match_set("test")')

0 commit comments

Comments
 (0)