示例#1
0
    def setUp(self):
        test_name = self.shortDescription()
        self.token_list = res.token_list
        super(BagOfWordsTest, self).setUp()

        if test_name == "Test routine build_model() in BagOfWords":
            print "setting up for testing build_model()"
            self.mock_obj = BagOfWords()
            self.mock_obj._text_set = self.test_data.r_D_text_set
            self.mock_obj.build_model()

        elif test_name == "Test routine compute() in BagOfWords":
            print "setting up for testing compute()"

            self.test_data.attach_feature("bag_of_words")
            self.term_freq = res.term_frequency
示例#2
0
    def init_attribute(self, attribute_name):
        """Create attribute instance

        Parameter
        ---------
        attribute_name : string
            Contains the feature name, to create an attribute
            instance.
        """
        if attribute_name == "bag_of_words":
            attribute = BagOfWords(self.bow_model)
            return attribute
        elif attribute_name == "tf_idf":
            attribute = TfIdf(self.bow_model)
            return attribute
        elif attribute_name == "readability":
            attribute = Readability()
            return attribute
        elif attribute_name == "variety":
            attribute = Variety()
            return attribute
        elif attribute_name == "perfect_tense":
            attribute = PerfectTense()
            return attribute
        elif attribute_name == "nested_sentence":
            attribute = NestedSentence()
            return attribute
        elif attribute_name == "passive":
            attribute = Passive()
            return attribute
        elif attribute_name == "adjective":
            attribute = Adjective()
            return attribute
        elif attribute_name == "sentence_start":
            attribute = SentenceStart()
            return attribute
        elif attribute_name == "bag_of_pos":
            attribute = BagOfPos(self.bow_model)
            return attribute
        elif attribute_name == "modal_verb":
            attribute = ModalVerb()
            return attribute
        else:
            raise FeatureNotExistException(attribute_name)