Source code for sugaroid.brain.utils

import spacy


[docs]class LanguageProcessor: def __init__(self): self.nlp = spacy.load("en_core_web_sm")
[docs] def lp(self): return self.nlp
[docs] def tokenize(self, arg): doc = self.nlp(arg) return doc
[docs] def similarity(self, arg1, arg2): return self.nlp(arg1).similarity(self.nlp(arg2))
[docs] def lemma(self, arg): return [x.lemma_ for x in self.nlp(arg)]