コード例 #1
0
def get_hamlet_term_doc_matrix():
    # type: () -> TermDocMatrix
    hamlet_docs = get_hamlet_docs()

    hamlet_term_doc_matrix = build_from_category_whitespace_delimited_text([
        (get_hamlet_snippet_binary_category(text), text)
        for i, text in enumerate(hamlet_docs)
    ])
    return hamlet_term_doc_matrix
コード例 #2
0
def get_hamlet_term_doc_matrix():
    # type: () -> TermDocMatrix
    hamlet_docs = get_hamlet_docs()

    hamlet_term_doc_matrix = build_from_category_whitespace_delimited_text(
        [(get_hamlet_snippet_binary_category(text), text)
         for i, text in enumerate(hamlet_docs)]
    )
    return hamlet_term_doc_matrix
コード例 #3
0
 def test_single_category_term_doc_matrix_should_error(self):
     with self.assertRaisesRegex(
             expected_exception=
             CannotCreateATermDocMatrixWithASignleCategoryException,
             expected_regex=
             'Documents must be labeled with more than one category. '
             'All documents were labeled with category: "a"'):
         single_category_tdm = build_from_category_whitespace_delimited_text(
             [['a', text]
              for category, text in get_test_categories_and_documents()])
コード例 #4
0
 def test_single_category_term_doc_matrix_should_error(self):
     with self.assertRaisesRegex(
             expected_exception=CannotCreateATermDocMatrixWithASignleCategoryException,
             expected_regex='Documents must be labeled with more than one category. '
                            'All documents were labeled with category: "a"'):
         single_category_tdm = build_from_category_whitespace_delimited_text(
             [['a', text]
              for category, text
              in get_test_categories_and_documents()]
         )
コード例 #5
0
def make_a_test_term_doc_matrix():
    # type: () -> TermDocMatrix
    return build_from_category_whitespace_delimited_text(
        get_test_categories_and_documents())
コード例 #6
0
def make_a_test_term_doc_matrix():
    # type: () -> TermDocMatrix
    return build_from_category_whitespace_delimited_text(
        get_test_categories_and_documents()
    )