Ejemplo n.º 1
0
    def load(self):
        super(AnagramMap, self).load()

        data = load(self.filename)

        self.anagram_hashmap = data["hashmap"]
        self.anagram_alphabet = data["alphabet"]
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    def load(self):
        super(AltCaseMap, self).load()

        data = load(self.filename)

        self.altcase_map = data["altcase"]
        self.altcase_pruned_map = data["altcase_pruned"]
Ejemplo n.º 4
0
    def load(self):
        super(AnagramMap, self).load()

        data = load(self.filename)

        self.anagram_hashmap = data["hashmap"]
        self.anagram_alphabet = data["alphabet"]
Ejemplo n.º 5
0
    def load(self):
        super(Bigrams, self).load()

        data = load(self.filename)

        self.ngrams = data["bigrams"]
        self.ngrams_pruned = data["bigrams_pruned"]
Ejemplo n.º 6
0
    def load(self):
        super(AltCaseMap, self).load()

        data = load(self.filename)

        self.altcase_map = data["altcase"]
        self.altcase_pruned_map = data["altcase_pruned"]
Ejemplo n.º 7
0
    def load(self):
        super(Bigrams, self).load()

        data = load(self.filename)

        self.ngrams = data["bigrams"]
        self.ngrams_pruned = data["bigrams_pruned"]
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
    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"]
Ejemplo n.º 10
0
    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"]
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    def load(self):
        super(OcrKeyMap, self).load()

        self.ocrkey_map = load(self.filename)
Ejemplo n.º 14
0
    def load(self):
        super(Dictionary, self).load()

        self.dictionary = load(self.filename)
Ejemplo n.º 15
0
    def load(self):
        super(OcrKeyMap, self).load()

        self.ocrkey_map = load(self.filename)
Ejemplo n.º 16
0
    def load(self):
        super(Dictionary, self).load()

        self.dictionary = load(self.filename)