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

Make inputs directly from a dict #591

Merged
merged 5 commits into from
Nov 30, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix variable naming
  • Loading branch information
Daniel Vidal Hussey committed Nov 30, 2018
commit b143c2a0b6a2588df5adf8565153d0df0992cdf7
6 changes: 3 additions & 3 deletions sockeye/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def make_input_from_json_string(sentence_id: SentenceId, json_string: str) -> Tr
:param sentence_id: Sentence id.
:param json_string: A JSON object serialized as a string that must contain a key "text", mapping to the input text,
and optionally a key "factors" that maps to a list of strings, each of which representing a factor sequence
for the input text. Constraints and an avoid list can also be added through the "constraints" and "avoid"
for the input text. Constraints and an avoid list can also be added through the "constraints" and "avoid"
keys.
:return: A TranslatorInput.
"""
Expand Down Expand Up @@ -726,7 +726,7 @@ def make_input_from_dict(sentence_id: SentenceId, input_dict: Dict) -> Translato
lengths = [len(f) for f in factors]
if not all(length == len(tokens) for length in lengths):
logger.error("Factors have different length than input text: %d vs. %s", len(tokens), str(lengths))
return _bad_input(sentence_id, reason=json_string)
return _bad_input(sentence_id, reason=input_dict)

# List of phrases to prevent from occuring in the output
avoid_list = input_dict.get(C.JSON_AVOID_KEY)
Expand All @@ -753,7 +753,7 @@ def make_input_from_dict(sentence_id: SentenceId, input_dict: Dict) -> Translato

except Exception as e:
logger.exception(e, exc_info=True) if not is_python34() else logger.error(e) # type: ignore
return _bad_input(sentence_id, reason=json_string)
return _bad_input(sentence_id, reason=input_dict)


def make_input_from_factored_string(sentence_id: SentenceId,
Expand Down