<commit_before>
# encoding: utf-8
# Practical Natural Language Processing Tools (practNLPTools-lite):
#               Combination of Senna and Stanford dependency Extractor
# Copyright (C) 2017 PractNLP-lite Project
# Current Author: <NAME> <<EMAIL>>
# URL: https://jawahar273.gitbooks.io (or) https://github.com/jawahar273


from __future__ import generators, print_function, unicode_literals
import subprocess

import os
from platform import architecture, system

try:
    from colorama import init
    from colorama.Fore import RED, BLUE
    init(autoreset=True)
except ImportError:
    RED = " "
    BLUE = " "


class Annotator:
    """
    :param str senna_dir: path where is located
    :param str dep_model: Stanford dependencie mode
    :param str stp_dir: path of stanford parser jar
    :param str raise_e: raise exception if stanford-parser.jar
                        is not found
    """

    def __init__(self, senna_dir='', stp_dir='',
                 dep_model='edu.stanford.nlp.trees.'
                           'EnglishGrammaticalStructure',
                 raise_e=False):
        """
        init function of Annotator class
        """
        self.senna_path = ''
        self.dep_par_path = ''

        if not senna_dir:
            if 'SENNA' in os.environ:
                self.senna_path = os.path.normpath(os.environ['SENNA'])
                self.senna_path + os.path.sep
                exe_file_2 = self.get_senna_bin(self.senna_path)
                if not os.path.isfile(exe_file_2):
                    raise OSError(RED +
                                  "Senna executable expected at %s or"
                                  " %s but not found"
                                  % (self.senna_path, exe_file_2))
        elif senna_dir.startswith('.'):
            self.senna_path = os.path.realpath(senna_dir)
        else:
            self.senna_path = senna_dir.strip()
            self.senna_path = self.senna_path.rstrip(os.path.sep) + os.path.sep

        if not stp_dir:
            import pntl.tools as Tfile
            self.dep_par_path = Tfile.__file__.rsplit(
                                                      os.path.sep, 1)[0] + os.path.sep
            self.check_stp_jar(self.dep_par_path, raise_e=True)
        else:
            self.dep_par_path = stp_dir + os.path.sep
            self.check_stp_jar(self.dep_par_path, raise_e)

        self.dep_par_model = dep_model
        print(dep_model)

        self.default_jar_cli = ['java', '-cp', 'stanford-parser.jar',
                                self.dep_par_model,
                                '-treeFile', 'in.parse', '-collapsed']
        self.print_values()

    def print_values(self):
        """ displays the current set of values
        such as SENNA location, stanford parser jar,
        jar command interface<commit_msg>update in finding senna path<commit_after>
# encoding: utf-8
# Practical Natural Language Processing Tools (practNLPTools-lite):
#               Combination of Senna and Stanford dependency Extractor
# Copyright (C) 2017 PractNLP-lite Project
# Current Author: <NAME> <<EMAIL>>
# URL: https://jawahar273.gitbooks.io (or) https://github.com/jawahar273


from __future__ import generators, print_function, unicode_literals
import subprocess

import os
from platform import architecture, system

try:
    from colorama import init
    from colorama.Fore import RED, BLUE
    init(autoreset=True)
except ImportError:
    RED = " "
    BLUE = " "


class Annotator:
    """
    :param str senna_dir: path where is located
    :param str dep_model: Stanford dependencie mode
    :param str stp_dir: path of stanford parser jar
    :param str raise_e: raise exception if stanford-parser.jar
                        is not found
    """

    def __init__(self, senna_dir='', stp_dir='',
                 dep_model='edu.stanford.nlp.trees.'
                           'EnglishGrammaticalStructure',
                 raise_e=False):
        """
        init function of Annotator class
        """
        self.senna_path = ''
        self.dep_par_path = ''

        if not senna_dir:
            if 'SENNA' in os.environ:
                self.senna_path = os.path.normpath(os.environ['SENNA'])
                self.senna_path + os.path.sep
                exe_file_2 = self.get_senna_bin(self.senna_path)
                if not os.path.isfile(exe_file_2):
                    raise OSError(RED +
                                  "Senna executable expected at %s or"
                                  " %s but not found"
                                  % (self.senna_path, exe_file_2))
        elif senna_dir.startswith('.'):
            self.senna_path = os.path.realpath(senna_dir) + os.path.sep
        else:
            self.senna_path = senna_dir.strip()
            self.senna_path = self.senna_path.rstrip(os.path.sep) + os.path.sep

        if not stp_dir:
            import pntl.tools as Tfile
            self.dep_par_path = Tfile.__file__.rsplit(os.path.sep, 1)[0] + os.path.sep
            self.check_stp_jar(self.dep_par_path, raise_e=True)
        else:
            self.dep_par_path = stp_dir + os.path.sep
            self.check_stp_jar(self.dep_par_path, raise_e)

        self.dep_par_model = dep_model
        print(dep_model)

        self.default_jar_cli = ['java', '-cp', 'stanford-parser.jar',
                                self.dep_par_model,
                                '-treeFile', 'in.parse', '-collapsed']
        self.print_values()

    def print_values(self):
        """ displays the current set of values
        such as SENNA location, stanford parser jar,
        jar command interface
{'fraction_non_alphanumeric': 0.09195199435227674, 'fraction_numerical': 0.0056477232615601836, 'mean_word_length': 1.856350806451613, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1944726', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1692, 'n_words': 395}