Esempio n. 1
0
 def evaluate(self, dataset_uri):
     dataset = dataset_utils.load_dataset_of_corpus(dataset_uri)
     (sents_tokens, sents_tags) = zip(*[zip(*sent) for sent in dataset])
     (sents_pred_tags) = self._tag_sents(self._num_tags, sents_tokens,
                                         self._trans_probs,
                                         self._emiss_probs)
     acc = self._compute_accuracy(sents_tags, sents_pred_tags)
     return acc
Esempio n. 2
0
 def train(self, dataset_uri):
     dataset = dataset_utils.load_dataset_of_corpus(dataset_uri)
     (sents_tokens, sents_tags) = zip(*[zip(*sent) for sent in dataset])
     self._num_tags = dataset.tag_num_classes[0]
     (self._trans_probs,
      self._emiss_probs) = self._compute_probs(self._num_tags, sents_tokens,
                                               sents_tags)
     logger.log('No. of tags: {}'.format(self._num_tags))
Esempio n. 3
0
    def train(self, dataset_uri):
        dataset = dataset_utils.load_dataset_of_corpus(dataset_uri)
        self._word_dict = self._extract_word_dict(dataset)
        self._tag_count = dataset.tag_num_classes[0]

        logger.log('No. of unique words: {}'.format(len(self._word_dict)))
        logger.log('No. of tags: {}'.format(self._tag_count))

        (self._net, self._optimizer) = self._train(dataset)
        sents_tags = self._predict(dataset)
        acc = self._compute_accuracy(dataset, sents_tags)

        logger.log('Train accuracy: {}'.format(acc))
Esempio n. 4
0
 def evaluate(self, dataset_uri):
     dataset = dataset_utils.load_dataset_of_corpus(dataset_uri)
     sents_tags = self._predict(dataset)
     acc = self._compute_accuracy(dataset, sents_tags)
     return acc