900b9a7f2884aaf419e62508be7497b0ad3e1f62,pytext/metric_reporters/squad_metric_reporter.py,SquadMetricReporter,_unnumberize,#SquadMetricReporter#,358
Before Change
start_char_idx = 0
end_char_idx = 0
answer_str = ""
for doc_token_idx in range(len(doc_tokens) - num_ans_tokens):
if doc_tokens[doc_token_idx : doc_token_idx + num_ans_tokens] == ans_tokens:
start_char_idx = start_idx[doc_token_idx]
end_char_idx = end_idx[doc_token_idx + num_ans_tokens - 1]
answer_str = doc_str[start_char_idx:end_char_idx]
break
return answer_str, start_char_idx, end_char_idx
// The following three functions are copied from Squad"s evaluation script.
// https://worksheets.codalab.org/rest/bundles/0x6b567e1cf2e041ec80d7098f031c5c9e/contents/blob/
After Change
// start_idx and end_idx are lists of char start and end positions in doc_str.
doc_tokens, start_idxs, end_idxs = self.tensorizer._lookup_tokens(doc_str)
// find the offset of doc_tokens in tokens
offset = list(
map(
lambda x: tokens[x : x + len(doc_tokens)] == doc_tokens,
range(len(tokens) - len(doc_tokens) + 1),
)
).index(True)
assert offset > -1
// find the answer char idxs
start_char_idx = 0
end_char_idx = end_idxs[-1]
try:
start_char_idx = start_idxs[ans_token_start - offset]
end_char_idx = end_idxs[ans_token_end - offset]
except IndexError:
// if token indices fall outside the bounds due to a model misprediction.
pass
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 3
Instances
Project Name: facebookresearch/pytext
Commit Name: 900b9a7f2884aaf419e62508be7497b0ad3e1f62
Time: 2021-02-24
Author: debo@fb.com
File Name: pytext/metric_reporters/squad_metric_reporter.py
Class Name: SquadMetricReporter
Method Name: _unnumberize
Project Name: senarvi/theanolm
Commit Name: e185a7110ec79864dcef5114b71356691eec39df
Time: 2016-07-16
Author: seppo.git@marjaniemi.com
File Name: theanolm/commands/sample.py
Class Name:
Method Name: sample
Project Name: explosion/spaCy
Commit Name: 22b9e1215932f9111c49d4ec5e1ccd25bab1fc3c
Time: 2019-09-27
Author: svlandeg@users.noreply.github.com
File Name: spacy/pipeline/entityruler.py
Class Name: EntityRuler
Method Name: add_patterns
Project Name: jazzband/django-debug-toolbar
Commit Name: e0b6f888a677336586dc33f091a04e2e8d8adba6
Time: 2017-04-24
Author: keryn@kerynknight.com
File Name: debug_toolbar/panels/templates/panel.py
Class Name: TemplatesPanel
Method Name: _store_template_info