| 343 | |
| 344 | |
| 345 | class EntityRecognizedSummarizer(DataAugmenter): |
| 346 | def __init__(self): |
| 347 | self.nlp = spacy.load("en_core_web_sm") # run !python -m spacy download en_core_web_sm in order to download |
| 348 | |
| 349 | def parse_single(self, essay): |
| 350 | ents = recognize_entities(essay, self.nlp) |
| 351 | characters = ents.most_common(4, person=True) |
| 352 | topic = recognize_entities(essay, self.nlp, n=2, person=False) |
| 353 | |
| 354 | question = f"Please write a story titled {topic} with the characters {characters}." |
| 355 | answer = f"Sure. Here is a story titled {topic}\n" + essay |
| 356 | |
| 357 | return [question], [answer] |
| 358 | |
| 359 | |
| 360 | class CodeBugger(DataAugmenter): |