# Path: textblob_de/packages.py
# HERE = os.path.dirname(os.path.abspath(__file__))
# 
# Path: textblob_de/tokenizers.py
# class PatternTokenizer(BaseTokenizer):
# 
#     """Tokenizer included in ``pattern.de`` package.
# 
#     **PROs:**
# 
#     * handling of emoticons
#     * flexible implementations of abbreviations
#     * can be adapted very easily
# 
#     **CONs:**
# 
#     * ordinal numbers cause sentence breaks
#     * indices of Sentence() objects cannot be computed
# 
#     """
# 
#     def __init__(self):
#         self.tokens = []
# 
#     def tokenize(self, text, include_punc=True, nested=False):
#         """Return a list of word tokens.
# 
#         :param text: string of text.
#         :param include_punc: (optional) whether to include punctuation as separate
#             tokens. Default to True.
# 
#         """
#         self.tokens = [
#             w for w in (
#                 self.word_tokenize(
#                     s,
#                     include_punc) for s in self.sent_tokenize(text))]
#         if nested:
#             return self.tokens
#         else:
#             return list(chain.from_iterable(self.tokens))
# 
#     def sent_tokenize(self, text, **kwargs):
#         """Returns a list of sentences.
# 
#         Each sentence is a space-separated string of tokens (words).
#         Handles common cases of abbreviations (e.g., etc., ...).
#         Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence.
#         Headings without an ending period are inferred by line breaks.
# 
#         """
# 
#         sentences = find_sentences(text,
#                                    punctuation=kwargs.get(
#                                        "punctuation",
#                                        PUNCTUATION),
#                                    abbreviations=kwargs.get(
#                                        "abbreviations",
#                                        ABBREVIATIONS_DE),
#                                    replace=kwargs.get("replace", replacements),
#                                    linebreak=r"\n{2,}")
#         return sentences
# 
#     def word_tokenize(self, sentences, include_punc=True):
#         #: Do not process empty strings (Issue #3)
#         if sentences.strip() == "":
#             return []
#         _tokens = sentences.split(" ")
#         #: Handle strings consisting of a single punctuation mark seperately (Issue #4)
#         if len(_tokens) == 1:
#             if _tokens[0] in PUNCTUATION:
#                 if include_punc:
#                     return _tokens
#                 else:
#                     return []
#         if include_punc:
#             last_word = _tokens[-1]
#             # Make sure that you do not separate '.' tokens into ['', '.']
#             # (Issue #5)
#             if last_word.endswith('.') and len(last_word) > 1:
#                 _tokens = _tokens[:-1] + [last_word[:-1], '.']
#             return _tokens
#         else:
#             # Return each word token
#             # Strips punctuation unless the word comes from a contraction
#             # e.g. "gibt's" => ["gibt", "'s"] in "Heute gibt's viel zu tun!"
#             # e.g. "hat's" => ["hat", "'s"]
#             # e.g. "home." => ['home']
#             words = [
#                 word if word.startswith("'") else strip_punc(
#                     word,
#                     all=False) for word in _tokens if strip_punc(
#                     word,
#                     all=False)]
#             return list(words)
# 
# @requires_nltk_corpus
# def sent_tokenize(self, text, **kwargs):
#     """NLTK's sentence tokenizer (currently PunktSentenceTokenizer).
# 
#     Uses an unsupervised algorithm to build a model for abbreviation
#     words, collocations, and words that start sentences, then uses
#     that to find sentence boundaries.
# 
#     """
#     sentences = self.sent_tok.tokenize(
#         text,
#         realign_boundaries=kwargs.get(
#             "realign_boundaries",
#             True))
#     return sentences


import os
from collections import defaultdict
from textblob.base import BaseNPExtractor
from textblob_de.packages import pattern_de
from textblob_de.tokenizers import PatternTokenizer, sent_tokenize
        :param list extracted_list: A list of noun phrases extracted from parser output.

        """
        _filtered = []
        for np in extracted_list:
            _np = np.split()
            if _np[0] in INSIGNIFICANT:
                _np.pop(0)
            try:
                if _np[-1] in INSIGNIFICANT:
                    _np.pop(-1)
                # e.g. 'welcher die ...'
                if _np[0] in INSIGNIFICANT:
                    _np.pop(0)
            except IndexError:
                _np = []
            if len(_np) > 0:
                _filtered.append(" ".join(_np))
        return _filtered

    def _parse_text(self, text):
        """Parse text (string) and return list of parsed sentences (strings).

        Each sentence consists of space separated token elements and the
        token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA)
        (separated by a forward slash '/')

        :param str text: A string.

        """

# Path: textblob_de/packages.py
# HERE = os.path.dirname(os.path.abspath(__file__))
# 
# Path: textblob_de/tokenizers.py
# class PatternTokenizer(BaseTokenizer):
# 
#     """Tokenizer included in ``pattern.de`` package.
# 
#     **PROs:**
# 
#     * handling of emoticons
#     * flexible implementations of abbreviations
#     * can be adapted very easily
# 
#     **CONs:**
# 
#     * ordinal numbers cause sentence breaks
#     * indices of Sentence() objects cannot be computed
# 
#     """
# 
#     def __init__(self):
#         self.tokens = []
# 
#     def tokenize(self, text, include_punc=True, nested=False):
#         """Return a list of word tokens.
# 
#         :param text: string of text.
#         :param include_punc: (optional) whether to include punctuation as separate
#             tokens. Default to True.
# 
#         """
#         self.tokens = [
#             w for w in (
#                 self.word_tokenize(
#                     s,
#                     include_punc) for s in self.sent_tokenize(text))]
#         if nested:
#             return self.tokens
#         else:
#             return list(chain.from_iterable(self.tokens))
# 
#     def sent_tokenize(self, text, **kwargs):
#         """Returns a list of sentences.
# 
#         Each sentence is a space-separated string of tokens (words).
#         Handles common cases of abbreviations (e.g., etc., ...).
#         Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence.
#         Headings without an ending period are inferred by line breaks.
# 
#         """
# 
#         sentences = find_sentences(text,
#                                    punctuation=kwargs.get(
#                                        "punctuation",
#                                        PUNCTUATION),
#                                    abbreviations=kwargs.get(
#                                        "abbreviations",
#                                        ABBREVIATIONS_DE),
#                                    replace=kwargs.get("replace", replacements),
#                                    linebreak=r"\n{2,}")
#         return sentences
# 
#     def word_tokenize(self, sentences, include_punc=True):
#         #: Do not process empty strings (Issue #3)
#         if sentences.strip() == "":
#             return []
#         _tokens = sentences.split(" ")
#         #: Handle strings consisting of a single punctuation mark seperately (Issue #4)
#         if len(_tokens) == 1:
#             if _tokens[0] in PUNCTUATION:
#                 if include_punc:
#                     return _tokens
#                 else:
#                     return []
#         if include_punc:
#             last_word = _tokens[-1]
#             # Make sure that you do not separate '.' tokens into ['', '.']
#             # (Issue #5)
#             if last_word.endswith('.') and len(last_word) > 1:
#                 _tokens = _tokens[:-1] + [last_word[:-1], '.']
#             return _tokens
#         else:
#             # Return each word token
#             # Strips punctuation unless the word comes from a contraction
#             # e.g. "gibt's" => ["gibt", "'s"] in "Heute gibt's viel zu tun!"
#             # e.g. "hat's" => ["hat", "'s"]
#             # e.g. "home." => ['home']
#             words = [
#                 word if word.startswith("'") else strip_punc(
#                     word,
#                     all=False) for word in _tokens if strip_punc(
#                     word,
#                     all=False)]
#             return list(words)
# 
# @requires_nltk_corpus
# def sent_tokenize(self, text, **kwargs):
#     """NLTK's sentence tokenizer (currently PunktSentenceTokenizer).
# 
#     Uses an unsupervised algorithm to build a model for abbreviation
#     words, collocations, and words that start sentences, then uses
#     that to find sentence boundaries.
# 
#     """
#     sentences = self.sent_tok.tokenize(
#         text,
#         realign_boundaries=kwargs.get(
#             "realign_boundaries",
#             True))
#     return sentences


# Path: textblob_de/np_extractors.py
import os
from collections import defaultdict
from textblob.base import BaseNPExtractor
from textblob_de.packages import pattern_de
from textblob_de.tokenizers import PatternTokenizer, sent_tokenize

        :param list extracted_list: A list of noun phrases extracted from parser output.

        """
        _filtered = []
        for np in extracted_list:
            _np = np.split()
            if _np[0] in INSIGNIFICANT:
                _np.pop(0)
            try:
                if _np[-1] in INSIGNIFICANT:
                    _np.pop(-1)
                # e.g. 'welcher die ...'
                if _np[0] in INSIGNIFICANT:
                    _np.pop(0)
            except IndexError:
                _np = []
            if len(_np) > 0:
                _filtered.append(" ".join(_np))
        return _filtered

    def _parse_text(self, text):
        """Parse text (string) and return list of parsed sentences (strings).

        Each sentence consists of space separated token elements and the
        token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA)
        (separated by a forward slash '/')

        :param str text: A string.

        """

        if isinstance(self.tokenizer, PatternTokenizer):