Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: choose joke type per language support #41

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Brighten your day with dad humor.
- Jokes from [The Internet Chuck Norris DB (ICNDB)](http://www.icndb.com/) provided under CC BY-SA 3.0
- programmer jokes from [stackoverflow](http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke?page=4&tab=votes#tab-top) provided under CC BY-SA 3.0
- [Blagues-API](https://github.com/Blagues-API/blagues-api/) (french)
- [Puntuguese dataset](https://github.com/Superar/Puntuguese) (portuguese puns)
12 changes: 10 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ class JokingSkill(OVOSSkill):

@intent_handler("joke.intent")
def handle_joke(self, message: Optional[Message] = None) -> None:
self.speak_dialog("general_jokes")
# TODO - refactor this once lang support is more uniform
if self.lang.startswith("pt"):
self.speak_dialog("puns")
elif self.lang.split("-")[0] in ["cs", "es", "eu", "gl", "hu", "it", "pl", "sv"]:
self.speak_dialog("dev_jokes")
else:
self.speak_dialog("general_jokes")
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved

@intent_handler("search_joke.intent")
def handle_search_joke(self, message: Message) -> None:
category = message.data["search"].lower()
self.log.debug("joke search: %s", category)

# TODO self.voc_match more joke types
# special handling for chuck norris jokes
# TODO allow blacklisting some categories in settings.json (kid friendly setting by default)
if self.voc_match(voc_filename="ChuckNorris", utt=category, lang=self.lang):
self.speak_dialog("chuck_norris_jokes")
elif self.voc_match(voc_filename="Dad", utt=category, lang=self.lang):
self.speak_dialog("dad_jokes")
elif self.voc_match(voc_filename="Programmer", utt=category, lang=self.lang):
self.speak_dialog("dev_jokes")
elif self.voc_match(voc_filename="Pun", utt=category, lang=self.lang):
self.speak_dialog("puns")
else:
self.speak_dialog("no_joke", {"search": category})
3 changes: 3 additions & 0 deletions locale/en-us/Pun.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pun
Wordplay
quip
3 changes: 3 additions & 0 deletions locale/pt-pt/Pun.voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Duplo sentido
trocadilho
Jogo de palavras
2,850 changes: 2,850 additions & 0 deletions locale/pt-pt/puns.dialog

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions translations/en-us/vocabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"ChuckNorris.voc": [
"chuck norris"
],
"Pun.voc": [
"pun",
"Wordplay",
"quip"
],
"Dad.voc": [
"Dad"
]
Expand Down
2,852 changes: 2,852 additions & 0 deletions translations/pt-pt/dialogs.json

Large diffs are not rendered by default.

Loading