def load(self): super(AnagramMap, self).load() data = load(self.filename) self.anagram_hashmap = data["hashmap"] self.anagram_alphabet = data["alphabet"]
def correct(self, text_data): """Correct text data Args: text_data (`Text`): Text data """ unigrams = Unigrams(join(self.config["root"], self.config["dirs"]["models_root"], self.config["dirs"]["models"]["inline"], self.config["models"]["inline"]["unigrams"],)) ml_classifier = load(join(self.config["dirs"]["models_root"], self.config["dirs"]["models"]["learning"], self.config["models"]["learning"]["classifier"])) if ml_classifier is None: return self.model["algo"].set_classifier(ml_classifier) for paragraph in text_data.text: for line in paragraph: if line.grade % 5 == 0: continue f = MachineLearningFeatures() features = f.extract_features(line, unigrams.ngrams, text_data.stats) line.grade = self.model["algo"].classify(features) * 5
def load(self): super(AltCaseMap, self).load() data = load(self.filename) self.altcase_map = data["altcase"] self.altcase_pruned_map = data["altcase_pruned"]
def load(self): super(Bigrams, self).load() data = load(self.filename) self.ngrams = data["bigrams"] self.ngrams_pruned = data["bigrams_pruned"]
def correct(self, text_data): """Correct text data Args: text_data (`Text`): Text data """ unigrams = Unigrams( join( self.config["root"], self.config["dirs"]["models_root"], self.config["dirs"]["models"]["inline"], self.config["models"]["inline"]["unigrams"], )) ml_classifier = load( join(self.config["dirs"]["models_root"], self.config["dirs"]["models"]["learning"], self.config["models"]["learning"]["classifier"])) if ml_classifier is None: return self.model["algo"].set_classifier(ml_classifier) for paragraph in text_data.text: for line in paragraph: if line.grade % 5 == 0: continue f = MachineLearningFeatures() features = f.extract_features(line, unigrams.ngrams, text_data.stats) line.grade = self.model["algo"].classify(features) * 5
def load(self): super(Unigrams, self).load() data = load(self.filename) self.raw_unigrams = data["raw_unigrams"] self.ngrams = data["unigrams"] self.ngrams_pruned = data["unigrams_pruned"]
def __init__(self, app_config): self.config = app_config self.logger = logging.getLogger('local') self.hash_filename = join(app_config["dirs"]["models_root"], app_config["models"]["hashes"]) self.hash_list = [] if exists(self.hash_filename): self.hash_list = load(self.hash_filename)
def load(self): super(OcrKeyMap, self).load() self.ocrkey_map = load(self.filename)
def load(self): super(Dictionary, self).load() self.dictionary = load(self.filename)