<commit_before>from __future__ import unicode_literals
from os import path

from .. import orth
from ..vocab import Vocab
from ..tokenizer import Tokenizer
from ..syntax.parser import GreedyParser
from ..tokens import Tokens
from .pos import EnPosTagger
from .pos import POS_TAGS
from .attrs import get_flags


def get_lex_props(string):
    return {'flags': get_flags(string), 'dense': 1}


class English(object):
    def __init__(self, data_dir=None, tag=True, parse=False):
        if data_dir is None:
            data_dir = path.join(path.dirname(__file__), 'data')
        self.vocab = Vocab(data_dir=data_dir, get_lex_props=get_lex_props)
        self.tokenizer = Tokenizer.from_dir(self.vocab, data_dir)
        self.tagger = EnPosTagger(self.vocab.strings, data_dir) if tag else None
        self.parser = GreedyParser(data_dir) if parse else None

    def __call__(self, text, tag=True, parse=True):
        tokens = self.tokenizer.tokenize(text)
        if self.tagger and tag:
            self.tagger(tokens)
        if self.parser and parse:
            self.parser.parse(tokens)
        return tokens<commit_msg>* Fix path to parser model<commit_after>from __future__ import unicode_literals
from os import path

from .. import orth
from ..vocab import Vocab
from ..tokenizer import Tokenizer
from ..syntax.parser import GreedyParser
from ..tokens import Tokens
from .pos import EnPosTagger
from .pos import POS_TAGS
from .attrs import get_flags


def get_lex_props(string):
    return {'flags': get_flags(string), 'dense': 1}


class English(object):
    def __init__(self, data_dir=None, tag=True, parse=False):
        if data_dir is None:
            data_dir = path.join(path.dirname(__file__), 'data')
        self.vocab = Vocab(data_dir=data_dir, get_lex_props=get_lex_props)
        self.tokenizer = Tokenizer.from_dir(self.vocab, data_dir)
        self.tagger = EnPosTagger(self.vocab.strings, data_dir) if tag else None
        self.parser = GreedyParser(path.join(data_dir, 'deps')) if parse else None

    def __call__(self, text, tag=True, parse=True):
        tokens = self.tokenizer.tokenize(text)
        if self.tagger and tag:
            self.tagger(tokens)
        if self.parser and parse:
            self.parser.parse(tokens)
        return tokens
{'fraction_non_alphanumeric': 0.09325744308231174, 'fraction_numerical': 0.0008756567425569177, 'mean_word_length': 3.311320754716981, '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': '7619060', 'n_tokens_mistral': 736, 'n_tokens_neox': 715, 'n_words': 201}