Skip to content

Commit

Permalink
example: fix context_plus_question construction if either context or …
Browse files Browse the repository at this point in the history
…question is empty
  • Loading branch information
Mehrad0711 committed Oct 6, 2021
1 parent 4c3cc89 commit 845d620
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion genienlp/data_utils/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ def from_examples(examples: Iterable[Example], numericalizer):
all_context_plus_question_features = []

for ex in examples:
context_plus_question = ex.context + sep_token + ex.question if len(ex.question) else ex.context
if not len(ex.question):
context_plus_question = ex.context
elif not len(ex.context):
context_plus_question = ex.question
else:
context_plus_question = ex.context + sep_token + ex.question

all_context_plus_questions.append(context_plus_question)

# concatenate question and context features with a separator, but no need for a separator if there are no features to begin with
Expand Down

0 comments on commit 845d620

Please sign in to comment.