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 ago bug #1129

Merged
merged 11 commits into from
Apr 10, 2023
Merged

Fix ago bug #1129

merged 11 commits into from
Apr 10, 2023

Conversation

serhii73
Copy link
Collaborator

Close #340

@serhii73 serhii73 marked this pull request as draft February 2, 2023 15:56
@Gallaecio
Copy link
Member

"(\\d+)\s*год\\b": "\\1", as originally suggested by @noviluni, works for the new test cases, but fails for existing ones.

Because I do not speak Russian, I am not sure how to best address those other issues.

For example, according to tests, 1 год 2 месяца means 1 year and 2 months ago. Is that correct? If so, does 1 год mean 1 year ago or year 1? How can you tell?

@serhii73
Copy link
Collaborator Author

Hi @Gallaecio

1 год 2 месяца means 1 year and 2 months ago. Is that correct?

Yes, you're right.

If so, does 1 год mean 1 year ago or year 1?

It means year 1.

I think I just overcomplicated the tests and most of the web pages have a simpler format.

@Gallaecio
Copy link
Member

How can you tell 1 год means year 1 but 1 год 2 месяца means 1 year and 2 months ago? How would you say 1 year ago in line with 1 год 2 месяца?

@serhii73
Copy link
Collaborator Author

1 year ago - один год назад / 1 год назад
2001 years ago - 2001 год назад
year 2001 - 2001 год

In Russian, there would be one year(1 год), two years(2 года), three years(3 года), and four years(4 года), but five years(5 лет), six years(6 лет), seven years(7 лет), eight years(8 лет), and nine years(9 лет).

That is, to count the years, you need two words: год and лет.

In general,
2000 год - it's the year 2000
2000 лет назад - 2000 years ago
2001 год - it's the year 2001
2001 год назад - 2000 years ago

@serhii73
Copy link
Collaborator Author

1 год 2 месяца means 1 year and 2 months ago. Is that correct?

Yes, you're right.

is because the word the месяц(month) can be used with the words either backward or forward in time.

@serhii73
Copy link
Collaborator Author

If so, does 1 год mean 1 year ago or year 1?

It means year 1.

it's because for ago need a world назад.

@Gallaecio
Copy link
Member

OK, so I have gone with 2 regular expressions:

  • Given a number of 4+ digits ending in 1 and followed by год and only by год, remove the “years” suffix so that it is treated as an absolute year rather than a number of years. I went with this after I wound that parse("1000") interprets 1000 as the year, but parse("999") gives no result.
  • Given any number not ending in 1 and followed by год, remove the “years” suffix so that it is treated as an absolute year.

I have added a few more test cases that I hope are accurate. Please take a good look.

@serhii73 serhii73 changed the title [WIP] Fix ago bug Fix ago bug Apr 7, 2023
@serhii73 serhii73 marked this pull request as ready for review April 7, 2023 13:27
@serhii73
Copy link
Collaborator Author

serhii73 commented Apr 7, 2023

LGTM @Gallaecio @wRAR

@Gallaecio Gallaecio merged commit 9234be3 into master Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants