MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / norm_str

Method norm_str

data_processor.py:37–56  ·  view source on GitHub ↗
(self, string)

Source from the content-addressed store, hash-verified

35 return string.strip().lower()
36
37 def norm_str(self, string):
38 string = re.sub(self.other_char, " ", string)
39
40 if self.nlp is None:
41 from spacy.lang.en import English
42 self.nlp = English()
43
44 new_doc = list()
45 doc = self.nlp(string)
46 for token in doc:
47 if token.is_space or token.is_punct:
48 continue
49 if token.is_digit:
50 token = "[num]"
51 else:
52 token = token.text
53
54 new_doc.append(token)
55
56 return " ".join(new_doc).lower()
57
58 def lean_str_sst(self, string):
59 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected