Пример #1
0
def test_flatten_stem_corpus():
    s = Stemmer()

    corpus = [
        s.compute_stem_hist(text) for text in [
            "chateau Châteaux Châteaux chateaux exemple EXEMPLE exemples EXEMPLES exemple",
            "Château café IRENE ça arène Noël",
            "J'ai acheté du pain, des croissants & des chocolatines ; ça fait beaucoup !"
        ]
    ]
    ans = s.flatten_stem_corpus(corpus)
    print("[" + str(ans) + "]")
    assert (ans == [{
        'chateau': 4,
        'exempl': 5
    }, {
        'caf': 1,
        'chateau': 1,
        'aren': 1,
        'iren': 1,
        'noel': 1,
    }, {
        'croiss': 1,
        'beaucoup': 1,
        'achet': 1,
        'chocolatin': 1,
        'pain': 1
    }])
Пример #2
0
def test_compute_stem_hist():
    s = Stemmer()

    txt = "chateau Châteaux chateaux exemple EXEMPLE exemples EXEMPLES exemple"
    ans = s.compute_stem_hist(txt)
    print("[" + str(ans) + "]")
    assert (sum(ans["chateau"].values()) == 3
            and sum(ans["exempl"].values()) == 5)
Пример #3
0
def test_languages():
    # If you read this test, you should try listening the zaaiuien word : translate.google.com/#nl/fr/zaaiuien
    s = Stemmer()
    txt = "zaaiuien"

    nl_hist = s.compute_stem_hist(txt, "NL")
    fr_hist = s.compute_stem_hist(txt, "FR")

    assert "zaaiui" in nl_hist and "zaaiui" not in fr_hist
Пример #4
0
def test_get_complete_vocabulary():
    s = Stemmer()

    corpus = [
        s.compute_stem_hist(text) for text in [
            "chateau Châteaux Châteaux chateaux exemple EXEMPLE exemples EXEMPLES exemple",
            "Château café IRENE ça arène Noël",
            "J'ai acheté du pain, des croissants & des chocolatines ; ça fait beaucoup !"
        ]
    ]
    ans = s.get_complete_vocabulary(corpus)
    print("[" + str(ans) + "]")
    assert (ans == {
        'achet', 'chateau', 'beaucoup', 'chocolatin', 'croiss', 'aren', 'iren',
        'pain', 'noel', 'caf', 'exempl'
    })