improve pronouns change (perspective)#48
Conversation
... by leveraging the skills translate_namedvalues to be able to fine grain the vocabulary changed
|
actually -while rarely occuring- a while loop would be better for k, v in vocabulary.items():
while f" {k} " in utterance:
utterance = utterance.replace(f" {k} ", f" {v} ")and probably |
krisgesling
left a comment
There was a problem hiding this comment.
Thanks for helping to improve the dialog for all languages!
This generally looks good to me. Do you want to make the other little changes you suggested?
| return reminder | ||
| vocabulary = self.translate_namedvalues("Perspective") | ||
|
|
||
| reminder = f" {reminder}" |
There was a problem hiding this comment.
Yeah the space at the end seems like a good change. Shouldn't happen in english unless the stt is cut off but could in some other language.
|
|
||
| reminder = f" {reminder}" | ||
| for k, v in vocabulary.items(): | ||
| if f" {k} " in reminder: |
There was a problem hiding this comment.
I think the if is fine. What's the thinking behind a while?
There was a problem hiding this comment.
If the sentence is "remind me that i take my teeth out ouf my mouth". It would only change one. (Pretty rare, but consistent) - allthough that would make a heck of a sentence 🤣
There was a problem hiding this comment.
By default I think String.replace() replaces all instances of the search string:
>>> reminder = " remind me that i take my teeth out ouf my mouth "
>>> reminder.replace("my", "our")
' remind me that i take our teeth out ouf our mouth '
There is an optional parameter if you want to limit that to n instances:
>>> reminder.replace("my", "our", 1)
' remind me that i take our teeth out ouf my mouth '
So if I'm not mistaken, in this case we should only need to call that once.
It is quite an interesting sentence too lol
There was a problem hiding this comment.
Doh, that shouldn't happen. (the mistake)
| vocabulary = self.translate_namedvalues("Perspective") | ||
|
|
||
| reminder = f" {reminder}" | ||
| for k, v in vocabulary.items(): |
There was a problem hiding this comment.
Can we try and use full variable names, just for readability and consistency.
... by leveraging the skills translate_namedvalues to be able to fine grain the vocabulary changed
Problem
The method used limits the possibilities in several ways:
myandourwould equate toyourwith changing the perspectivemein,meine,meinen, but also in many other langs)Thus i think that using
translate_namedvaluesis the better approach to change the pronouns. The reminder is iterated over and changed as the vocabulary is found.This also reverts changes made introducing
My.dialog,Our.dialogandYour.dialogreplacing those with a singlePerspective.valuecontaining the vocabulary pairs. (all available langs)CLA
👍
Tested
👍