Skip to content

improve pronouns change (perspective) #48

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

Open
wants to merge 3 commits into
base: 21.02
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def date_str(self, d):
return self.translate('Tomorrow')
else:
return nice_date(d.date())

def change_pronouns(self, reminder):
"""Change my / our into you / your, etc.

Expand All @@ -204,12 +204,13 @@ def change_pronouns(self, reminder):
Arguments:
reminder (str): reminder text
"""
my_regex = r'\b{}\b'.format(self.translate('My'))
our_regex = r'\b{}\b'.format(self.translate('Our'))
your_word = self.translate('Your')
reminder = re.sub(my_regex, your_word, reminder)
reminder = re.sub(our_regex, your_word, reminder)
return reminder
vocabulary = self.translate_namedvalues("Perspective")

reminder = f" {reminder}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

for k, v in vocabulary.items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try and use full variable names, just for readability and consistency.

if f" {k} " in reminder:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the if is fine. What's the thinking behind a while?

Copy link
Author

@emphasize emphasize Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤣

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh, that shouldn't happen. (the mistake)

reminder = reminder.replace(f" {k} ", f" {v} ")
return reminder.strip()

@intent_handler('ReminderAt.intent')
def add_new_reminder(self, msg=None):
Expand Down
Empty file added dialog/ca-es/Perspective.value
Empty file.
1 change: 0 additions & 1 deletion dialog/de-de/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/de-de/Our.dialog

This file was deleted.

8 changes: 8 additions & 0 deletions dialog/de-de/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mein,dein
meine,deine
meinen,deinen
meinem,deinem
unser,euer
unsere,euere
unseren,eueren
unserem,euerem
1 change: 0 additions & 1 deletion dialog/de-de/Your.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/en-us/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/en-us/Our.dialog

This file was deleted.

2 changes: 2 additions & 0 deletions dialog/en-us/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my,your
our,your
1 change: 0 additions & 1 deletion dialog/en-us/Your.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/es-es/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/es-es/Our.dialog

This file was deleted.

3 changes: 3 additions & 0 deletions dialog/es-es/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mi,tu
nuestro,tu
nuestra,tu
1 change: 0 additions & 1 deletion dialog/es-es/Your.dialog

This file was deleted.

Empty file added dialog/eu-eu/Perspective.value
Empty file.
1 change: 0 additions & 1 deletion dialog/fa-ir/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/fa-ir/Our.dialog

This file was deleted.

2 changes: 2 additions & 0 deletions dialog/fa-ir/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
مال تو,برای من
مال تو,مال ما
1 change: 0 additions & 1 deletion dialog/fa-ir/Your.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/fr-fr/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/fr-fr/Our.dialog

This file was deleted.

4 changes: 4 additions & 0 deletions dialog/fr-fr/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mon,votre
ma,votre
nos,votre
notre,votre
1 change: 0 additions & 1 deletion dialog/fr-fr/Your.dialog

This file was deleted.

Empty file added dialog/gl-es/Perspective.value
Empty file.
Empty file added dialog/it-it/Perspective.value
Empty file.
1 change: 0 additions & 1 deletion dialog/nl-nl/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/nl-nl/Our.dialog

This file was deleted.

2 changes: 2 additions & 0 deletions dialog/nl-nl/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mijn,uw
onze,uw
1 change: 0 additions & 1 deletion dialog/nl-nl/Your.dialog

This file was deleted.

Empty file added dialog/pl-pl/Perspective.value
Empty file.
Empty file added dialog/pt-br/Perspective.value
Empty file.
1 change: 0 additions & 1 deletion dialog/ru-ru/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/ru-ru/Our.dialog

This file was deleted.

2 changes: 2 additions & 0 deletions dialog/ru-ru/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
мой,ваш
наш,ваш
1 change: 0 additions & 1 deletion dialog/ru-ru/Your.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/sv-se/My.dialog

This file was deleted.

1 change: 0 additions & 1 deletion dialog/sv-se/Our.dialog

This file was deleted.

2 changes: 2 additions & 0 deletions dialog/sv-se/Perspective.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
min,din
vår,din
1 change: 0 additions & 1 deletion dialog/sv-se/Your.dialog

This file was deleted.