コード例 #1
0
 def setUp(self):
     self.v = Variables()
     self.prp = PhrasesRequirementProcessor()
コード例 #2
0
class TestPhrasesRequirementProcessor(TestCase):
    def setUp(self):
        self.v = Variables()
        self.prp = PhrasesRequirementProcessor()

    def it_generates_new_corpus_from_segmented_reports(self):
        self.prp.generate_corpus_from_segmented_reports \
        |should| equal_to((self.v.cut_of_segmented_reports, self.v.topics))

    def it_aggregates_sentences_of_topics_on_segmented_reports(self):
        self.prp.aggregate_topics_of_segmented_reports(self.v.cut_of_segmented_reports, self.v.topics) \
        |should| equal_to(self.v.aggregated_topics)

    def it_organizes_aggregated_topics_by_dictionary(self):
        self.prp.organize_aggregated_topics_by_dict(self.v.aggregated_topics, self.v.topics) \
        |should| equal_to(self.v.dict_of_sentences_by_topic)

    def it_tags_unigrams_by_topic(self):
        self.prp.tag_unigrams_by_topic(self.v.dict_of_sentences_by_topic) \
        |should| equal_to(self.v.tagged_unigrams_by_topic)

    def it_generates_nouns_unigrams_by_topic(self):
        self.prp.generate_nouns_unigrams_by_topic(self.v.tagged_unigrams_by_topic) \
        |should| equal_to(self.v.nouns_unigrams_by_topic)

    def it_generates_none_unigrams_by_topic(self):
        self.prp.generate_none_unigrams_by_topic(self.v.tagged_unigrams_by_topic) \
        |should| equal_to(self.v.none_unigrams_by_topic)

    def it_creates_a_dictionary_model_for_test_accuracy_of_tagger_by_topic(
            self):
        self.prp.create_a_dict_model_for_test_accuracy(self.v.tagged_unigrams_by_topic) \
        |should| equal_to((self.v.dict_model_by_topic, self.v.tagger_accuracy_by_topic))

    def it_creates_most_frequent_nouns_unigrams_by_topic(self):
        self.prp.create_most_frequent_nouns_unigrams_by_topic(self.v.nouns_unigrams_by_topic) \
        |should| equal_to(self.v.run_time_most_frequent_nouns_unigrams_by_topic)

    def it_creates_wordtypes_of_none_unigrams_by_topic(self):
        self.prp.create_wordtypes_of_none_unigrams_by_topic(self.v.none_unigrams_by_topic) \
        |should| equal_to(self.v.run_time_wordtypes_of_none_unigrams_by_topic)
コード例 #3
0
 def setUp(self):
     self.v = Variables()
     self.prp = PhrasesRequirementProcessor()
コード例 #4
0
class TestPhrasesRequirementProcessor(TestCase):
    def setUp(self):
        self.v = Variables()
        self.prp = PhrasesRequirementProcessor()

    def it_generates_new_corpus_from_segmented_reports(self):
        self.prp.generate_corpus_from_segmented_reports | should | equal_to(
            (self.v.cut_of_segmented_reports, self.v.topics)
        )

    def it_aggregates_sentences_of_topics_on_segmented_reports(self):
        self.prp.aggregate_topics_of_segmented_reports(
            self.v.cut_of_segmented_reports, self.v.topics
        ) | should | equal_to(self.v.aggregated_topics)

    def it_organizes_aggregated_topics_by_dictionary(self):
        self.prp.organize_aggregated_topics_by_dict(self.v.aggregated_topics, self.v.topics) | should | equal_to(
            self.v.dict_of_sentences_by_topic
        )

    def it_tags_unigrams_by_topic(self):
        self.prp.tag_unigrams_by_topic(self.v.dict_of_sentences_by_topic) | should | equal_to(
            self.v.tagged_unigrams_by_topic
        )

    def it_generates_nouns_unigrams_by_topic(self):
        self.prp.generate_nouns_unigrams_by_topic(self.v.tagged_unigrams_by_topic) | should | equal_to(
            self.v.nouns_unigrams_by_topic
        )

    def it_generates_none_unigrams_by_topic(self):
        self.prp.generate_none_unigrams_by_topic(self.v.tagged_unigrams_by_topic) | should | equal_to(
            self.v.none_unigrams_by_topic
        )

    def it_creates_a_dictionary_model_for_test_accuracy_of_tagger_by_topic(self):
        self.prp.create_a_dict_model_for_test_accuracy(self.v.tagged_unigrams_by_topic) | should | equal_to(
            (self.v.dict_model_by_topic, self.v.tagger_accuracy_by_topic)
        )

    def it_creates_most_frequent_nouns_unigrams_by_topic(self):
        self.prp.create_most_frequent_nouns_unigrams_by_topic(self.v.nouns_unigrams_by_topic) | should | equal_to(
            self.v.run_time_most_frequent_nouns_unigrams_by_topic
        )

    def it_creates_wordtypes_of_none_unigrams_by_topic(self):
        self.prp.create_wordtypes_of_none_unigrams_by_topic(self.v.none_unigrams_by_topic) | should | equal_to(
            self.v.run_time_wordtypes_of_none_unigrams_by_topic
        )
コード例 #5
0
 def detect_unigrams(self):
     prp = PhrasesRequirementProcessor()
     cut_of_segmented_reports, \
     topics = prp.generate_corpus_from_segmented_reports
     aggregated_topics = \
         prp.aggregate_topics_of_segmented_reports(cut_of_segmented_reports, 
                                                   topics)
     dict_of_sentences_by_topic = \
         prp.organize_aggregated_topics_by_dict(aggregated_topics, 
                                                topics)
     tagged_unigrams_by_topic = prp.tag_unigrams_by_topic(dict_of_sentences_by_topic)
     nouns_unigrams_by_topic = \
         prp.generate_nouns_unigrams_by_topic(tagged_unigrams_by_topic)
     none_unigrams_by_topic = \
         prp.generate_none_unigrams_by_topic(tagged_unigrams_by_topic)
     dict_model_by_topic, \
     tagger_accuracy_by_topic = \
         prp.create_a_dict_model_for_test_accuracy(tagged_unigrams_by_topic)
     run_time_most_frequent_nouns_unigrams_by_topic = \
         prp.create_most_frequent_nouns_unigrams_by_topic(nouns_unigrams_by_topic)
     run_time_wordtypes_of_none_unigrams_by_topic = prp.create_wordtypes_of_none_unigrams_by_topic(none_unigrams_by_topic)
     prp.create_unigram_set_of_nouns_and_nones(run_time_most_frequent_nouns_unigrams_by_topic, run_time_wordtypes_of_none_unigrams_by_topic)
     prp.show_accuracy_by_topic(tagger_accuracy_by_topic)
     prp.remove_pyc_and_zombie_files
コード例 #6
0
 def detect_unigrams(self):
     prp = PhrasesRequirementProcessor()
     cut_of_segmented_reports, \
     topics = prp.generate_corpus_from_segmented_reports
     aggregated_topics = \
         prp.aggregate_topics_of_segmented_reports(cut_of_segmented_reports,
                                                   topics)
     dict_of_sentences_by_topic = \
         prp.organize_aggregated_topics_by_dict(aggregated_topics,
                                                topics)
     tagged_unigrams_by_topic = prp.tag_unigrams_by_topic(
         dict_of_sentences_by_topic)
     nouns_unigrams_by_topic = \
         prp.generate_nouns_unigrams_by_topic(tagged_unigrams_by_topic)
     none_unigrams_by_topic = \
         prp.generate_none_unigrams_by_topic(tagged_unigrams_by_topic)
     dict_model_by_topic, \
     tagger_accuracy_by_topic = \
         prp.create_a_dict_model_for_test_accuracy(tagged_unigrams_by_topic)
     run_time_most_frequent_nouns_unigrams_by_topic = \
         prp.create_most_frequent_nouns_unigrams_by_topic(nouns_unigrams_by_topic)
     run_time_wordtypes_of_none_unigrams_by_topic = prp.create_wordtypes_of_none_unigrams_by_topic(
         none_unigrams_by_topic)
     prp.create_unigram_set_of_nouns_and_nones(
         run_time_most_frequent_nouns_unigrams_by_topic,
         run_time_wordtypes_of_none_unigrams_by_topic)
     prp.show_accuracy_by_topic(tagger_accuracy_by_topic)
     prp.remove_pyc_and_zombie_files