# Path: feet/utils/logger.py
# class LoggingMixin(object):
#     """
#     Mix in to classes that need their own logging object!
#     """
# 
#     @property
#     def logger(self):
#         """
#         Instantiates and returns a ServiceLogger instance
#         """
#         if not hasattr(self, '_logger') or not self._logger:
#             self._logger = ServiceLogger()
#         return self._logger
# 
# Path: feet/utils/decorators.py
# def timeit(func):
#     """
#     Returns the number of seconds that a function took along with the result
#     """
# 
#     @wraps(func)
#     def timer_wrapper(*args, **kwargs):
#         """
#         Inner function that uses the Timer context object
#         """
#         with Timer() as timer:
#             result = func(*args, **kwargs)
# 
#         return result, timer
# 
#     return timer_wrapper


from nltk import word_tokenize, sent_tokenize, ne_chunk, \
    RegexpParser, pos_tag
from nltk.tree import Tree
from collections import defaultdict
from langdetect import detect_langs
from jptools import JAParser
from feet.utils.logger import LoggingMixin
from feet.utils.decorators import timeit
import traceback
        """
        Tokenizes a text by splitting it into sentences that will be tokenized.
        """
        if lang is not None:
            lang = WORLD_2_NLTK[lang]
        else:
            lang = self._lang
        output = []
        if text is None:
            return output
        for sentence in self.sent_tokenize(text, lang):
            output.append(self.word_tokenize(sentence, lang))
        return output

    def _select_entities(self,
                         tree,
                         extra_classes=['NNP', 'NNPS', 'NN', 'NNS']):
        """
        Selects candidates of entities as chunks with specific grammatic tags.
        """
        entities = defaultdict(list)
        for chunk in tree:
            if isinstance(chunk, Tree):
                entities[chunk._label].append(
                    " ".join([token[0] for token in chunk.leaves()]))
            else:
                if chunk[1] in extra_classes:
                    entities['noun_phrase_leave'].append(chunk[0])
        return [i for key, value in dict(entities).iteritems() for i in value]


# Path: feet/utils/logger.py
# class LoggingMixin(object):
#     """
#     Mix in to classes that need their own logging object!
#     """
# 
#     @property
#     def logger(self):
#         """
#         Instantiates and returns a ServiceLogger instance
#         """
#         if not hasattr(self, '_logger') or not self._logger:
#             self._logger = ServiceLogger()
#         return self._logger
# 
# Path: feet/utils/decorators.py
# def timeit(func):
#     """
#     Returns the number of seconds that a function took along with the result
#     """
# 
#     @wraps(func)
#     def timer_wrapper(*args, **kwargs):
#         """
#         Inner function that uses the Timer context object
#         """
#         with Timer() as timer:
#             result = func(*args, **kwargs)
# 
#         return result, timer
# 
#     return timer_wrapper


# Path: feet/entities/nlp.py
from nltk import word_tokenize, sent_tokenize, ne_chunk, \
    RegexpParser, pos_tag
from nltk.tree import Tree
from collections import defaultdict
from langdetect import detect_langs
from jptools import JAParser
from feet.utils.logger import LoggingMixin
from feet.utils.decorators import timeit
import traceback

        """
        Tokenizes a text by splitting it into sentences that will be tokenized.
        """
        if lang is not None:
            lang = WORLD_2_NLTK[lang]
        else:
            lang = self._lang
        output = []
        if text is None:
            return output
        for sentence in self.sent_tokenize(text, lang):
            output.append(self.word_tokenize(sentence, lang))
        return output

    def _select_entities(self,
                         tree,
                         extra_classes=['NNP', 'NNPS', 'NN', 'NNS']):
        """
        Selects candidates of entities as chunks with specific grammatic tags.
        """
        entities = defaultdict(list)
        for chunk in tree:
            if isinstance(chunk, Tree):
                entities[chunk._label].append(
                    " ".join([token[0] for token in chunk.leaves()]))
            else:
                if chunk[1] in extra_classes:
                    entities['noun_phrase_leave'].append(chunk[0])
        return [i for key, value in dict(entities).iteritems() for i in value]


    @timeit