Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement saving to Facebook format #2712
Implement saving to Facebook format #2712
Changes from 40 commits
1bd9b34
1da932f
2e6ecbd
e3f104e
393ead3
a04e560
f7ac2c6
aacab5e
c2882af
08fe0f1
749ca6d
aec5e88
bfc938d
88de72b
100f25f
86d8c7b
94778d0
9e139c1
0684833
2ed3115
8e8ca1e
ebb2ac8
03a777c
d087074
6df1ff5
9c44e87
5b3eb2b
d709f2f
d37fd4f
821862e
8bfa866
6bebcef
1eaea78
594ca6b
971bfa6
f8a7d47
968eea0
8c03bc5
984ff2b
47d45f4
eacf8b6
7eef237
6009f0d
ea02091
c7c7aa8
4745bb8
28f27f8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name and comment are inconsistent. I think it's worth aligning them one way or another. My preference would be to rename the function
_save_vocabulary
to make it obvious what it's doing (dict
is a bit ambiguous here).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these lines duplicated? If there's a good reason, then please put it in a code comment.
From the C++ source, it looks like you're writing size, nwords, nlabels in that order. If
size==nwords
, then the duplication makes sense, but it's worth documenting why that equality holds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the link:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is also an
_internal
method. People won't be calling it from outside this module, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is as follows
_fasttext_bin.py
is internal module intended to use infasttext.py
.For loading we have a bunch of
_internal
functions (_batched_generator
,_load_matrix
, etc) and top-levelload
used infasttext.py
I tried to copy the same for saving i.e. bunch
_internal
functions (_sign_model
,_args_save
, etc) with top-levelsave
used infasttext.py
.If this does not make sense, let's change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, if you intend for this function to be called from outside the module, then the name is fine. However, in that case, you must include a full docstring, including the parameters and their types. This is important information for people who will be using your module - they won't necessarily be familiar with the module's implementation details, so make the documentation as helpful as possible.
Also, if possible, assign default values to optional parameters, and save users the labor of working out what they mean. E.g. the encoding is usually utf8, and there's probably already a constant for that in that module somewhere.
I see that this function mostly wraps the internal
_save_to_stream
function, so perhaps move the docstring from there?