-
Notifications
You must be signed in to change notification settings - Fork 773
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
Fixed Issue: #1977 #2181
Merged
Merged
Fixed Issue: #1977 #2181
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2601ac3
Fixed Issue: #1977
SSivakumar12 ede4d99
standardise errors into function for consistency
7796fbc
add additional edgecase and removal of underscore for consistency
19bab3d
remove redundant else clause
aa03a25
fixing linting errors
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import random | ||
import time | ||
from typing import Union | ||
|
||
|
||
def truncate_document(topic_model, doc_length, tokenizer, document: str): | ||
def truncate_document(topic_model, doc_length: Union[int, None], tokenizer: Union[str, callable], document: str) -> str: | ||
"""Truncate a document to a certain length. | ||
|
||
If you want to add a custom tokenizer, then it will need to have a `decode` and | ||
|
@@ -57,6 +58,15 @@ def decode(self, doc_chunks): | |
return truncated_document | ||
return document | ||
|
||
def validate_truncate_document_parameters(tokenizer, doc_length) -> Union[None, ValueError]: | ||
"""validates parameters that are used in the function `truncate_document`""" | ||
if tokenizer is None and doc_length is not None: | ||
raise ValueError( | ||
"Please select from one of the valid options for the `tokenizer` parameter: \n" | ||
"{'char', 'whitespace', 'vectorizer'} \n" | ||
"If `tokenizer` is of type callable ensure it has methods to encode and decode a document \n" | ||
) | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also include a check for the opposite? That someone does use a tokenizer but not a doc_length? |
||
|
||
|
||
def retry_with_exponential_backoff( | ||
func, | ||
|
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.
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.
Are you returning the
_
for a specific reason? Looking at thevalidate_truncate_document_parameters
, there doesn't seem anything that is returned.