def test_simple(self):
     X = ["This was a good summer", "The food was awful"]
     m = InquirerLexTransform()
     Z = m.transform(X)
     self.assertEqual(len(Z), 2)
     self.assertTrue(isinstance(Z[0], str) and isinstance(Z[1], str))
     self.assertIn("positiv", Z[0].lower())
     self.assertIn("negativ", Z[1].lower())
     self.assertNotIn("good", Z[0].lower())
     self.assertNotIn("awful", Z[1].lower())
示例#2
0
def build_lex_extraction(binary, min_df, ngram):
    return make_pipeline(InquirerLexTransform(),
                         CountVectorizer(binary=binary,
                                         tokenizer=lambda x: x.split(),
                                         min_df=min_df,
                                         ngram_range=(1, ngram)),
                         Densifier())
 def test_empty(self):
     m = InquirerLexTransform()
     Z = m.transform([])
     self.assertEqual(len(Z), 0)
 def test_fit_returns_self(self):
     m = InquirerLexTransform()
     s = m.fit([])
     self.assertEqual(s, m)