Created
November 17, 2019 15:21
-
-
Save gaphex/020de4d695a2b4b577290b9b95f95e79 to your computer and use it in GitHub Desktop.
Read a list of `InputExample`s from a list of strings.
This file contains hidden or 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
| def read_examples(str_list): | |
| """Read a list of `InputExample`s from a list of strings.""" | |
| unique_id = 0 | |
| for s in str_list: | |
| line = convert_to_unicode(s) | |
| if not line: | |
| continue | |
| line = line.strip() | |
| text_a = None | |
| text_b = None | |
| m = re.match(r"^(.*) \|\|\| (.*)$", line) | |
| if m is None: | |
| text_a = line | |
| else: | |
| text_a = m.group(1) | |
| text_b = m.group(2) | |
| yield InputExample(unique_id=unique_id, text_a=text_a, text_b=text_b) | |
| unique_id += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment