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

Remove __getitem__ code duplication in gensim.models.phrases #2206

Merged
merged 5 commits into from
Oct 4, 2018

Conversation

jenishah
Copy link
Contributor

@jenishah jenishah commented Oct 2, 2018

Fix #2149
wrote a single function sentence2token that can be used by _getitem_ of Phrase and Phrases class.

Copy link
Contributor

@menshikh-iv menshikh-iv left a comment

Choose a reason for hiding this comment

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

Good start, thanks @jenishah. Please fix mentioned issues & make sure that all CI passed successfully (now all ok except flake8 check in Travis).

gensim/models/phrases.py Outdated Show resolved Hide resolved
gensim/models/phrases.py Outdated Show resolved Hide resolved
gensim/models/phrases.py Outdated Show resolved Hide resolved
gensim/models/phrases.py Outdated Show resolved Hide resolved
gensim/models/phrases.py Show resolved Hide resolved
gensim/models/phrases.py Outdated Show resolved Hide resolved
gensim/models/phrases.py Outdated Show resolved Hide resolved
@jenishah
Copy link
Contributor Author

jenishah commented Oct 3, 2018

Thanks for the review @menshikh-iv . This was my first PR, and I need to learn a lot about proper documentation. Your reviews were a great help.

Copy link
Contributor

@menshikh-iv menshikh-iv left a comment

Choose a reason for hiding this comment

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

@jenishah only small things missing until I can merge this, please finalize PR, good work 👍

@@ -232,6 +232,51 @@ def load(cls, *args, **kwargs):
return model


def _sentence2token(phrase_class, sentence):
""" returns tokens after from a sentence by joining the phrases with delimiter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in form "Do X", not "does X"


Returns
-------
{list of str, :class:`gensim.interfaces.TransformedCorpus`}
Copy link
Contributor

Choose a reason for hiding this comment

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

missed ~ for TransformedCorpus (as in other examples)

{list of str, :class:`gensim.interfaces.TransformedCorpus`}
`sentence` with detected phrase bigrams merged together, or a streamed corpus of such sentences
if the input was a corpus.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Empty line at the end of docstring

@menshikh-iv
Copy link
Contributor

Nice work, thanks @jenishah, congratz with first contribution and happy hacktoberfest 🌟

@menshikh-iv menshikh-iv changed the title Removing duplication of code of phrases module Removing __getitem__ code duplication in gensim.models.phrases Oct 4, 2018
@menshikh-iv menshikh-iv changed the title Removing __getitem__ code duplication in gensim.models.phrases Remove __getitem__ code duplication in gensim.models.phrases Oct 4, 2018
@menshikh-iv menshikh-iv merged commit 485fa34 into piskvorky:develop Oct 4, 2018
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.

None yet

2 participants