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: change random.word to be based on definitions.word.* #276

Closed
wants to merge 12 commits into from

Conversation

pkuczynski
Copy link
Member

@pkuczynski pkuczynski commented Jan 23, 2022

Fixes #113
Fixes #218

@prisis
Copy link
Member

prisis commented Jan 23, 2022

I would put into 6.1  @import-brain

@ejcheng
Copy link
Member

ejcheng commented Jan 24, 2022

I would put into 6.1  @import-brain

Done

@pkuczynski
Copy link
Member Author

How about the review @prisis ?

@prisis
Copy link
Member

prisis commented Jan 24, 2022

@pkuczynski hope it's fine with you if i wait with the review a bit.

I would like to fix the tests more and remove all the mock function call, so we now that we break something.

And this is a runtime change of the code, so we will not merge it into v6.0 for now. But im thankful for you spend time on this PR.

Note: ignore the approve, clicked the wrong button...

prisis
prisis previously approved these changes Jan 24, 2022
src/random.ts Outdated
@@ -159,53 +159,28 @@ export class Random {
return this.faker.datatype.boolean();
}

// TODO: have ability to return specific type of word? As in: noun, adjective, verb, etc
Copy link
Member

Choose a reason for hiding this comment

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

The question is if we want to have this feature too.

Copy link
Member Author

Choose a reason for hiding this comment

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

We already have. Users can use faker.word.xyz to do it... That's why I removed this comment.

@prisis prisis self-requested a review January 24, 2022 11:42
@pkuczynski
Copy link
Member Author

The problem is, that the longer you wait with merging, the higher chance of conflict. I worked on this as it was listed as "help needed". This feature does not have any tests, so not sure what mocks do you want to remove?

@Shinigami92
Copy link
Member

The problem is, that the longer you wait with merging, the higher chance of conflict. I worked on this as it was listed as "help needed". This feature does not have any tests, so not sure what mocks do you want to remove?

Sorry but this is irrelevant to the current situation of the project.

We have a roadmap https://github.com/orgs/faker-js/projects/2 with the milestone https://github.com/faker-js/faker/milestone/1
We are thanksful that you try to contribute, but if you want to prevent merge conflicts right now, than wait until we release 6.0.0 and stop opening PR for now

This said, I can somewhat promise you that src/random.ts will not change that much anymore. The project stability is more regarding to the test-suite, bundling-setup and documentation. Multiple times said: no runtime changes before 6.0.0 released

@griest024 griest024 self-requested a review January 24, 2022 17:44
src/random.ts Outdated Show resolved Hide resolved
@pkuczynski pkuczynski requested a review from griest024 January 24, 2022 20:26
griest024
griest024 previously approved these changes Jan 25, 2022
ST-DDT
ST-DDT previously approved these changes Jan 28, 2022
@pkuczynski
Copy link
Member Author

pkuczynski commented Jan 28, 2022

Possibly in the future we might consider to move this to faker.word.any() as this what happened with other methods from this module...

What do you think? I could record this idea as a GitHub issue for future consideration...

@griest024
Copy link
Contributor

Possibly in the future we might consider to move this to faker.word.any() as this what happened with other methods from this module...

What do you think? I could record this idea as a GitHub issue for future consideration...

I think that is reasonable.

@pkuczynski
Copy link
Member Author

I think that is reasonable.

Here you go #339 :)

@Shinigami92
Copy link
Member

As this is changing runtime behavior and we already want to do #339 anyways, I will close this PR in favor of #339

@pkuczynski
Copy link
Member Author

@Shinigami92 I think this should be still merged, because it contains valid changes. Then the move in #339 can happen more easily...

@pkuczynski pkuczynski reopened this Mar 21, 2022
# Conflicts:
#	src/random.ts
# Conflicts:
#	src/random.ts
@Shinigami92
Copy link
Member

@ST-DDT and I decided this together via screen-share some minutes ago
We do not see to merge this because it just changes behavior that we already want to deprecate anyways.
What you could do right now would be to just add a console.warn that logs that this function will be deprecated so we can already deprecate it in v6.1.

Let me also say that I do totally not expect that the move from initial to v6.0.0 will take same amount of time as from v6.0 to v6.1 🙂
We want now to move on a bit faster

@pkuczynski pkuczynski dismissed stale reviews from ST-DDT and griest024 via a1e24a7 March 21, 2022 13:08
@pkuczynski
Copy link
Member Author

I mean this function after the changes done currently, can be with pretty much (almost) no change moved to word.any and random.word deprecated. It does slightly change the behaviour, that's true but not in a way which is dangerous in any way and it already does fix the issues reported in #113... So I still see this as perfectly mergeable...

@pkuczynski
Copy link
Member Author

@Shinigami92 @ST-DDT rebased and tests fixed

@Shinigami92 Shinigami92 marked this pull request as draft March 21, 2022 17:05
Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

I'm more and more tempted to not accept this PR 😕 Sorry...

I re-read through #113 and I thing we should go with the suggested proposal to just regex them out if they generate "invalid" words and then make a retry

With this PR (#276) we loose many possible words, especially hacker words, were you can see that they are not in generated system filenames anymore

I will block this from my side with a request changes, but if another maintainer is on my side, then I would vote for close this PR

@pkuczynski
Copy link
Member Author

Well, at least we get more sensible words with this pr comparing to before... but yeah, do what you wish...

@ST-DDT
Copy link
Member

ST-DDT commented Mar 22, 2022

Well, at least we get more sensible words with this pr comparing to before... but yeah, do what you wish...

What do you consider a "sensible" word? IMO we have to decide first what we expect from this method.
AFAIK this method is used in file name generation.
Should those contain Chinese letters/words in Chinese locales?
What about the opposite? Should it partially return English file names in Chinese locales

@ST-DDT ST-DDT added the s: needs decision Needs team/maintainer decision label Mar 22, 2022
@pkuczynski
Copy link
Member Author

Well, at least we get more sensible words with this pr comparing to before... but yeah, do what you wish...

What do you consider a "sensible" word? IMO we have to decide first what we expect from this method. AFAIK this method is used in file name generation. Should those contain Chinese letters/words in Chinese locales? What about the opposite? Should it partially return English file names in Chinese locales

I wold consider noun, adjective, verb, ... a sensible word. While things like streetSuffix or currencyName does not seem something I would expect from random.word (or word.any in the future). For example would as long as returned at the moment could be considered as a word? Even if you split it into as and long. The second one seems ok, but as? Don't think so...

Looking at the wikipedia https://en.wikipedia.org/wiki/Word:

In linguistics, a word of a spoken language can be defined as the smallest sequence of phonemes that can be uttered in isolation with objective or practical meaning. In many languages, words also correspond to sequences of graphemes ("letters") in their standard writing systems that are delimited by spaces wider than the normal inter-letter space, or by other graphical conventions.[1] The concept of "word" is usually distinguished from that of a morpheme, which is the smallest unit of word which has a meaning, even if it will not stand on its own together or in other small words.

@pkuczynski
Copy link
Member Author

For filename generation we could also use lorem.slug().

In other languages, I would expect the filename is generated in the selected locale, unless there is no translation for it. Wouldn't you?

@pkuczynski
Copy link
Member Author

I am not doing anything with his PR until you make a decision, right?

@Shinigami92
Copy link
Member

In yesterdays maintainers-team-meeting we discussed that we want to have the random.word function just as it is right now, but add a @deprecated JSDoc comment to it and a warning for removal
We want to have the word.any function directly and it should be implemented like you are already doing in this PR

@Shinigami92 Shinigami92 removed the s: needs decision Needs team/maintainer decision label Mar 25, 2022
@pkuczynski
Copy link
Member Author

OK!

@pkuczynski pkuczynski closed this Mar 28, 2022
@pkuczynski pkuczynski deleted the random-word branch March 28, 2022 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: chore PR that doesn't affect the runtime behavior needs rebase There is a merge conflict p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

random.word() can return undesirable non-alpha characters
6 participants