Gladiator commited on
Commit
63f3553
1 Parent(s): b04763d

removed redundant code

Browse files
Files changed (1) hide show
  1. summarizer/coreference_handler.py +0 -36
summarizer/coreference_handler.py DELETED
@@ -1,36 +0,0 @@
1
- # removed previous import and related functionality since it's just a blank language model,
2
- # while neuralcoref requires passing pretrained language model via spacy.load()
3
-
4
- import neuralcoref
5
- import spacy
6
-
7
- from summarizer.sentence_handler import SentenceHandler
8
-
9
-
10
- class CoreferenceHandler(SentenceHandler):
11
-
12
- def __init__(self, spacy_model: str = 'en_core_web_sm',
13
- greedyness: float = 0.45):
14
- """
15
- Corefence handler. Only works with spacy < 3.0.
16
-
17
- :param spacy_model: The spacy model to use as default.
18
- :param greedyness: The greedyness factor.
19
- """
20
- self.nlp = spacy.load(spacy_model)
21
- neuralcoref.add_to_pipe(self.nlp, greedyness=greedyness)
22
-
23
- def process(self, body: str, min_length: int = 40, max_length: int = 600):
24
- """
25
- Processes the content sentences.
26
-
27
- :param body: The raw string body to process
28
- :param min_length: Minimum length that the sentences must be
29
- :param max_length: Max length that the sentences mus fall under
30
- :return: Returns a list of sentences.
31
- """
32
- doc = self.nlp(body)._.coref_resolved
33
- doc = self.nlp(doc)
34
- return [c.string.strip()
35
- for c in doc.sents
36
- if max_length > len(c.string.strip()) > min_length]