<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import io
import pickle

from spacy.lemmatizer import Lemmatizer, read_index, read_exc
from spacy import util

import pytest


@pytest.fixture
def path():
    return util.match_best_version('en', None,
                os.environ.get('SPACY_DATA', util.get_data_path()))


@pytest.fixture
def lemmatizer(path):
    return Lemmatizer.load(path)


def test_read_index(path):
    with (path / 'wordnet' / 'index.noun').open() as file_:
        index = read_index(file_)
    assert 'man' in index
    assert 'plantes' not in index
    assert 'plant' in index


def test_read_exc(path):
    with (path / 'wordnet' / 'verb.exc').open() as file_:
        exc = read_exc(file_)
    assert exc['was'] == ('be',)


def test_noun_lemmas(lemmatizer):
    do = lemmatizer.noun

    assert do('aardwolves') == set(['aardwolf'])
    assert do('aardwolf') == set(['aardwolf'])
    assert do('planets') == set(['planet'])
    assert do('ring') == set(['ring'])
    assert do('axes') == set(['axis', 'axe', 'ax'])

<commit_msg>Add test for Issue #435<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import io
import pickle

from spacy.lemmatizer import Lemmatizer, read_index, read_exc
from spacy import util

import pytest


@pytest.fixture
def path():
    return util.match_best_version('en', None,
                os.environ.get('SPACY_DATA', util.get_data_path()))


@pytest.fixture
def lemmatizer(path):
    return Lemmatizer.load(path)


def test_read_index(path):
    with (path / 'wordnet' / 'index.noun').open() as file_:
        index = read_index(file_)
    assert 'man' in index
    assert 'plantes' not in index
    assert 'plant' in index


def test_read_exc(path):
    with (path / 'wordnet' / 'verb.exc').open() as file_:
        exc = read_exc(file_)
    assert exc['was'] == ('be',)


def test_noun_lemmas(lemmatizer):
    do = lemmatizer.noun

    assert do('aardwolves') == set(['aardwolf'])
    assert do('aardwolf') == set(['aardwolf'])
    assert do('planets') == set(['planet'])
    assert do('ring') == set(['ring'])
    assert do('axes') == set(['axis', 'axe', 'ax'])


def test_base_form_dive(lemmatizer):
    do = lemmatizer.noun
    assert do('dive', number='sing') == set(['dive'])
    assert do('dive', number='plur') == set(['diva'])


{'fraction_non_alphanumeric': 0.15993265993265993, 'fraction_numerical': 0.0021043771043771043, 'mean_word_length': 3.725646123260437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2749039', 'n_tokens_mistral': 849, 'n_tokens_neox': 824, 'n_words': 206}