本文整理汇总了Python中sklearn.feature_extraction.text.ENGLISH_STOP_WORDS属性的典型用法代码示例。如果您正苦于以下问题:Python text.ENGLISH_STOP_WORDS属性的具体用法?Python text.ENGLISH_STOP_WORDS怎么用?Python text.ENGLISH_STOP_WORDS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sklearn.feature_extraction.text
的用法示例。
在下文中一共展示了text.ENGLISH_STOP_WORDS属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_stoplisted_unigram_corpus
# 需要导入模块: from sklearn.feature_extraction import text [as 别名]
# 或者: from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS [as 别名]
def test_get_stoplisted_unigram_corpus(self):
tdm = make_a_test_term_doc_matrix()
uni_tdm = tdm.get_stoplisted_unigram_corpus()
term_df = tdm.get_term_freq_df()
uni_term_df = uni_tdm.get_term_freq_df()
self.assertEqual(set(term for term in term_df.index
if ' ' not in term
and "'" not in term
and term not in ENGLISH_STOP_WORDS),
set(uni_term_df.index)),
示例2: test_allow_single_quotes_in_unigrams
# 需要导入模块: from sklearn.feature_extraction import text [as 别名]
# 或者: from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS [as 别名]
def test_allow_single_quotes_in_unigrams(self):
tdm = make_a_test_term_doc_matrix()
self.assertEqual(type(tdm.allow_single_quotes_in_unigrams()), type(tdm))
uni_tdm = tdm.get_stoplisted_unigram_corpus()
term_df = tdm.get_term_freq_df()
uni_term_df = uni_tdm.get_term_freq_df()
self.assertEqual(set(term for term in term_df.index
if ' ' not in term
and term not in ENGLISH_STOP_WORDS),
set(uni_term_df.index)),
示例3: _assert_stoplisted_minus_joe
# 需要导入模块: from sklearn.feature_extraction import text [as 别名]
# 或者: from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS [as 别名]
def _assert_stoplisted_minus_joe(self, tdm, uni_tdm):
term_df = tdm.get_term_freq_df()
uni_term_df = uni_tdm.get_term_freq_df()
self.assertEqual(set(term for term in term_df.index
if ' ' not in term
and 'joe' != term.lower()
and "'" not in term
and term not in ENGLISH_STOP_WORDS),
set(uni_term_df.index)),
示例4: test_countvectorizer_stop_words
# 需要导入模块: from sklearn.feature_extraction import text [as 别名]
# 或者: from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS [as 别名]
def test_countvectorizer_stop_words():
cv = CountVectorizer()
cv.set_params(stop_words='english')
assert_equal(cv.get_stop_words(), ENGLISH_STOP_WORDS)
cv.set_params(stop_words='_bad_str_stop_')
assert_raises(ValueError, cv.get_stop_words)
cv.set_params(stop_words='_bad_unicode_stop_')
assert_raises(ValueError, cv.get_stop_words)
stoplist = ['some', 'other', 'words']
cv.set_params(stop_words=stoplist)
assert_equal(cv.get_stop_words(), set(stoplist))
示例5: _build_stop_words
# 需要导入模块: from sklearn.feature_extraction import text [as 别名]
# 或者: from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS [as 别名]
def _build_stop_words(self) -> Set[str]:
additional_stop_words = self.field.get_vectorizer_stop_words()
if additional_stop_words:
stop_words = set(ENGLISH_STOP_WORDS)
stop_words.update(additional_stop_words)
return stop_words
else:
return ENGLISH_STOP_WORDS