repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
pluralize
def pluralize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the plural of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if pos == NOUN: for a, b i...
python
def pluralize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the plural of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if pos == NOUN: for a, b i...
[ "def", "pluralize", "(", "word", ",", "pos", "=", "NOUN", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "custom", "=", "{", "}", ")", ":", "w", "=", "word", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "if", "word", "in"...
Returns the plural of a given word. The inflection is based on probability rather than gender and role.
[ "Returns", "the", "plural", "of", "a", "given", "word", ".", "The", "inflection", "is", "based", "on", "probability", "rather", "than", "gender", "and", "role", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L212-L262
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
singularize
def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the singular of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if word in singular: r...
python
def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the singular of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if word in singular: r...
[ "def", "singularize", "(", "word", ",", "pos", "=", "NOUN", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "custom", "=", "{", "}", ")", ":", "w", "=", "word", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "if", "word", "i...
Returns the singular of a given word. The inflection is based on probability rather than gender and role.
[ "Returns", "the", "singular", "of", "a", "given", "word", ".", "The", "inflection", "is", "based", "on", "probability", "rather", "than", "gender", "and", "role", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L317-L339
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
attributive
def attributive(adjective, gender=MALE, role=SUBJECT, article=None): """ For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative...
python
def attributive(adjective, gender=MALE, role=SUBJECT, article=None): """ For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative...
[ "def", "attributive", "(", "adjective", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "article", "=", "None", ")", ":", "w", ",", "g", ",", "c", ",", "a", "=", "adjective", ".", "lower", "(", ")", ",", "gender", "[", ":", "1", "...
For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative, accusative, dative, genitive).
[ "For", "a", "predicative", "adjective", "returns", "the", "attributive", "form", "(", "lowercase", ")", ".", "In", "German", "the", "attributive", "is", "formed", "with", "-", "e", "-", "em", "-", "en", "-", "er", "or", "-", "es", "depending", "on", "g...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L517-L541
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
predicative
def predicative(adjective): """ Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculi...
python
def predicative(adjective): """ Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculi...
[ "def", "predicative", "(", "adjective", ")", ":", "w", "=", "adjective", ".", "lower", "(", ")", "if", "len", "(", "w", ")", ">", "3", ":", "for", "suffix", "in", "(", "\"em\"", ",", "\"en\"", ",", "\"er\"", ",", "\"es\"", ",", "\"e\"", ")", ":",...
Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculine, nominative, etc. The pre...
[ "Returns", "the", "predicative", "adjective", "(", "lowercase", ")", ".", "In", "German", "the", "attributive", "form", "preceding", "a", "noun", "is", "always", "used", ":", "ein", "kleiner", "Junge", "=", ">", "strong", "masculine", "nominative", "eine", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L543-L561
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
grade
def grade(adjective, suffix=COMPARATIVE): """ Returns the comparative or superlative form of the given (inflected) adjective. """ b = predicative(adjective) # groß => großt, schön => schönst if suffix == SUPERLATIVE and b.endswith(("s", u"ß")): suffix = suffix[1:] # große => großere, sch...
python
def grade(adjective, suffix=COMPARATIVE): """ Returns the comparative or superlative form of the given (inflected) adjective. """ b = predicative(adjective) # groß => großt, schön => schönst if suffix == SUPERLATIVE and b.endswith(("s", u"ß")): suffix = suffix[1:] # große => großere, sch...
[ "def", "grade", "(", "adjective", ",", "suffix", "=", "COMPARATIVE", ")", ":", "b", "=", "predicative", "(", "adjective", ")", "# groß => großt, schön => schönst", "if", "suffix", "==", "SUPERLATIVE", "and", "b", ".", "endswith", "(", "(", "\"s\"", ",", "u\"...
Returns the comparative or superlative form of the given (inflected) adjective.
[ "Returns", "the", "comparative", "or", "superlative", "form", "of", "the", "given", "(", "inflected", ")", "adjective", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L568-L576
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.find_lemma
def find_lemma(self, verb): """ Returns the base form of the given inflected verb, using a rule-based approach. """ v = verb.lower() # Common prefixes: be-finden and emp-finden probably inflect like finden. if not (v.startswith("ge") and v.endswith("t")): # Probably gerund. ...
python
def find_lemma(self, verb): """ Returns the base form of the given inflected verb, using a rule-based approach. """ v = verb.lower() # Common prefixes: be-finden and emp-finden probably inflect like finden. if not (v.startswith("ge") and v.endswith("t")): # Probably gerund. ...
[ "def", "find_lemma", "(", "self", ",", "verb", ")", ":", "v", "=", "verb", ".", "lower", "(", ")", "# Common prefixes: be-finden and emp-finden probably inflect like finden.", "if", "not", "(", "v", ".", "startswith", "(", "\"ge\"", ")", "and", "v", ".", "ends...
Returns the base form of the given inflected verb, using a rule-based approach.
[ "Returns", "the", "base", "form", "of", "the", "given", "inflected", "verb", "using", "a", "rule", "-", "based", "approach", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L372-L413
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.find_lexeme
def find_lexeme(self, verb): """ For a regular verb (base form), returns the forms using a rule-based approach. """ v = verb.lower() # Stem = infinitive minus -en, -ln, -rn. b = b0 = re.sub("en$", "", re.sub("ln$", "l", re.sub("rn$", "r", v))) # Split common prefixes. ...
python
def find_lexeme(self, verb): """ For a regular verb (base form), returns the forms using a rule-based approach. """ v = verb.lower() # Stem = infinitive minus -en, -ln, -rn. b = b0 = re.sub("en$", "", re.sub("ln$", "l", re.sub("rn$", "r", v))) # Split common prefixes. ...
[ "def", "find_lexeme", "(", "self", ",", "verb", ")", ":", "v", "=", "verb", ".", "lower", "(", ")", "# Stem = infinitive minus -en, -ln, -rn.", "b", "=", "b0", "=", "re", ".", "sub", "(", "\"en$\"", ",", "\"\"", ",", "re", ".", "sub", "(", "\"ln$\"", ...
For a regular verb (base form), returns the forms using a rule-based approach.
[ "For", "a", "regular", "verb", "(", "base", "form", ")", "returns", "the", "forms", "using", "a", "rule", "-", "based", "approach", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L415-L464
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.tenses
def tenses(self, verb, parse=True): """ Returns a list of possible tenses for the given inflected verb. """ tenses = _Verbs.tenses(self, verb, parse) if len(tenses) == 0: # auswirkte => wirkte aus for prefix in prefix_separable: if verb.startswith(...
python
def tenses(self, verb, parse=True): """ Returns a list of possible tenses for the given inflected verb. """ tenses = _Verbs.tenses(self, verb, parse) if len(tenses) == 0: # auswirkte => wirkte aus for prefix in prefix_separable: if verb.startswith(...
[ "def", "tenses", "(", "self", ",", "verb", ",", "parse", "=", "True", ")", ":", "tenses", "=", "_Verbs", ".", "tenses", "(", "self", ",", "verb", ",", "parse", ")", "if", "len", "(", "tenses", ")", "==", "0", ":", "# auswirkte => wirkte aus", "for", ...
Returns a list of possible tenses for the given inflected verb.
[ "Returns", "a", "list", "of", "possible", "tenses", "for", "the", "given", "inflected", "verb", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L466-L476
train
markuskiller/textblob-de
textblob_de/classifiers.py
_get_words_from_dataset
def _get_words_from_dataset(dataset): """Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens. """ # Words may be either a string or a list of tokens. Return an iterator # of tokens ac...
python
def _get_words_from_dataset(dataset): """Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens. """ # Words may be either a string or a list of tokens. Return an iterator # of tokens ac...
[ "def", "_get_words_from_dataset", "(", "dataset", ")", ":", "# Words may be either a string or a list of tokens. Return an iterator", "# of tokens accordingly", "def", "tokenize", "(", "words", ")", ":", "if", "isinstance", "(", "words", ",", "basestring", ")", ":", "retu...
Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens.
[ "Return", "a", "set", "of", "all", "words", "in", "a", "dataset", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L57-L72
train
markuskiller/textblob-de
textblob_de/classifiers.py
basic_extractor
def basic_extractor(document, train_set): """A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list ...
python
def basic_extractor(document, train_set): """A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list ...
[ "def", "basic_extractor", "(", "document", ",", "train_set", ")", ":", "word_features", "=", "_get_words_from_dataset", "(", "train_set", ")", "tokens", "=", "_get_document_tokens", "(", "document", ")", "features", "=", "dict", "(", "(", "(", "u'contains({0})'", ...
A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list of tuples of the form ``(words, label)``.
[ "A", "basic", "document", "feature", "extractor", "that", "returns", "a", "dict", "indicating", "what", "words", "in", "train_set", "are", "contained", "in", "document", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L84-L97
train
markuskiller/textblob-de
textblob_de/classifiers.py
contains_extractor
def contains_extractor(document): """A basic document feature extractor that returns a dict of words that the document contains.""" tokens = _get_document_tokens(document) features = dict((u'contains({0})'.format(w), True) for w in tokens) return features
python
def contains_extractor(document): """A basic document feature extractor that returns a dict of words that the document contains.""" tokens = _get_document_tokens(document) features = dict((u'contains({0})'.format(w), True) for w in tokens) return features
[ "def", "contains_extractor", "(", "document", ")", ":", "tokens", "=", "_get_document_tokens", "(", "document", ")", "features", "=", "dict", "(", "(", "u'contains({0})'", ".", "format", "(", "w", ")", ",", "True", ")", "for", "w", "in", "tokens", ")", "...
A basic document feature extractor that returns a dict of words that the document contains.
[ "A", "basic", "document", "feature", "extractor", "that", "returns", "a", "dict", "of", "words", "that", "the", "document", "contains", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L100-L105
train
markuskiller/textblob-de
textblob_de/classifiers.py
BaseClassifier._read_data
def _read_data(self, dataset, format=None): """Reads a data file and returns and iterable that can be used as testing or training data.""" # Attempt to detect file format if "format" isn't specified if not format: format_class = formats.detect(dataset) else: ...
python
def _read_data(self, dataset, format=None): """Reads a data file and returns and iterable that can be used as testing or training data.""" # Attempt to detect file format if "format" isn't specified if not format: format_class = formats.detect(dataset) else: ...
[ "def", "_read_data", "(", "self", ",", "dataset", ",", "format", "=", "None", ")", ":", "# Attempt to detect file format if \"format\" isn't specified", "if", "not", "format", ":", "format_class", "=", "formats", ".", "detect", "(", "dataset", ")", "else", ":", ...
Reads a data file and returns and iterable that can be used as testing or training data.
[ "Reads", "a", "data", "file", "and", "returns", "and", "iterable", "that", "can", "be", "used", "as", "testing", "or", "training", "data", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L138-L148
train
markuskiller/textblob-de
textblob_de/classifiers.py
BaseClassifier.extract_features
def extract_features(self, text): """Extracts features from a body of text. :rtype: dictionary of features """ # Feature extractor may take one or two arguments try: return self.feature_extractor(text, self.train_set) except (TypeError, AttributeError): ...
python
def extract_features(self, text): """Extracts features from a body of text. :rtype: dictionary of features """ # Feature extractor may take one or two arguments try: return self.feature_extractor(text, self.train_set) except (TypeError, AttributeError): ...
[ "def", "extract_features", "(", "self", ",", "text", ")", ":", "# Feature extractor may take one or two arguments", "try", ":", "return", "self", ".", "feature_extractor", "(", "text", ",", "self", ".", "train_set", ")", "except", "(", "TypeError", ",", "Attribute...
Extracts features from a body of text. :rtype: dictionary of features
[ "Extracts", "features", "from", "a", "body", "of", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L167-L177
train
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.train
def train(self, *args, **kwargs): """Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in ...
python
def train(self, *args, **kwargs): """Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in ...
[ "def", "train", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "classifier", "=", "self", ".", "nltk_class", ".", "train", "(", "self", ".", "train_features", ",", "*", "args", ",", "*", "*", "kwargs", ...
Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in arguments to the ``train`` method of ...
[ "Train", "the", "classifier", "with", "a", "labeled", "feature", "set", "and", "return", "the", "classifier", ".", "Takes", "the", "same", "arguments", "as", "the", "wrapped", "NLTK", "class", ".", "This", "method", "is", "implicitly", "called", "when", "cal...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L224-L242
train
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.classify
def classify(self, text): """Classifies the text. :param str text: A string of text. """ text_features = self.extract_features(text) return self.classifier.classify(text_features)
python
def classify(self, text): """Classifies the text. :param str text: A string of text. """ text_features = self.extract_features(text) return self.classifier.classify(text_features)
[ "def", "classify", "(", "self", ",", "text", ")", ":", "text_features", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "classify", "(", "text_features", ")" ]
Classifies the text. :param str text: A string of text.
[ "Classifies", "the", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L248-L255
train
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.accuracy
def accuracy(self, test_set, format=None): """Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, wil...
python
def accuracy(self, test_set, format=None): """Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, wil...
[ "def", "accuracy", "(", "self", ",", "test_set", ",", "format", "=", "None", ")", ":", "if", "isinstance", "(", "test_set", ",", "basestring", ")", ":", "# test_set is a filename", "test_data", "=", "self", ".", "_read_data", "(", "test_set", ")", "else", ...
Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, will attempt to detect the file format.
[ "Compute", "the", "accuracy", "on", "a", "test", "set", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L257-L272
train
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.update
def update(self, new_data, *args, **kwargs): '''Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``. ''' self.train_set += new_data self.train_features = [(self...
python
def update(self, new_data, *args, **kwargs): '''Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``. ''' self.train_set += new_data self.train_features = [(self...
[ "def", "update", "(", "self", ",", "new_data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "train_set", "+=", "new_data", "self", ".", "train_features", "=", "[", "(", "self", ".", "extract_features", "(", "d", ")", ",", "c", ...
Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``.
[ "Update", "the", "classifier", "with", "new", "training", "data", "and", "re", "-", "trains", "the", "classifier", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L274-L290
train
markuskiller/textblob-de
textblob_de/classifiers.py
NaiveBayesClassifier.prob_classify
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> pro...
python
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> pro...
[ "def", "prob_classify", "(", "self", ",", "text", ")", ":", "text_features", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "prob_classify", "(", "text_features", ")" ]
Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_dist.max() 'positive' ...
[ "Return", "the", "label", "probability", "distribution", "for", "classifying", "a", "string", "of", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L312-L330
train
markuskiller/textblob-de
textblob_de/classifiers.py
PositiveNaiveBayesClassifier.train
def train(self, *args, **kwargs): """Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to al...
python
def train(self, *args, **kwargs): """Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to al...
[ "def", "train", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "classifier", "=", "self", ".", "nltk_class", ".", "train", "(", "self", ".", "positive_features", ",", "self", ".", "unlabeled_features", ",", "self", ".", ...
Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in arguments to the ``tra...
[ "Train", "the", "classifier", "with", "a", "labeled", "and", "unlabeled", "feature", "sets", "and", "return", "the", "classifier", ".", "Takes", "the", "same", "arguments", "as", "the", "wrapped", "NLTK", "class", ".", "This", "method", "is", "implicitly", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L453-L466
train
markuskiller/textblob-de
textblob_de/classifiers.py
PositiveNaiveBayesClassifier.update
def update(self, new_positive_data=None, new_unlabeled_data=None, positive_prob_prior=0.5, *args, **kwargs): '''Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_da...
python
def update(self, new_positive_data=None, new_unlabeled_data=None, positive_prob_prior=0.5, *args, **kwargs): '''Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_da...
[ "def", "update", "(", "self", ",", "new_positive_data", "=", "None", ",", "new_unlabeled_data", "=", "None", ",", "positive_prob_prior", "=", "0.5", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "positive_prob_prior", "=", "positive_prob_...
Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_data: List of new, unlabeled strings.
[ "Update", "the", "classifier", "with", "new", "data", "and", "re", "-", "trains", "the", "classifier", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L468-L490
train
markuskiller/textblob-de
textblob_de/classifiers.py
MaxEntClassifier.prob_classify
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_di...
python
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_di...
[ "def", "prob_classify", "(", "self", ",", "text", ")", ":", "feats", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "prob_classify", "(", "feats", ")" ]
Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_dist.max() 'positive' ...
[ "Return", "the", "label", "probability", "distribution", "for", "classifying", "a", "string", "of", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L497-L515
train
markuskiller/textblob-de
textblob_de/lemmatizers.py
PatternParserLemmatizer.lemmatize
def lemmatize(self, text): """Return a list of (lemma, tag) tuples. :param str text: A string. """ #: Do not process empty strings (Issue #3) if text.strip() == "": return [] parsed_sentences = self._parse_text(text) _lemmalist = [] for s in ...
python
def lemmatize(self, text): """Return a list of (lemma, tag) tuples. :param str text: A string. """ #: Do not process empty strings (Issue #3) if text.strip() == "": return [] parsed_sentences = self._parse_text(text) _lemmalist = [] for s in ...
[ "def", "lemmatize", "(", "self", ",", "text", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "parsed_sentences", "=", "self", ".", "_parse_text", "(", "text", ")", "_lemmal...
Return a list of (lemma, tag) tuples. :param str text: A string.
[ "Return", "a", "list", "of", "(", "lemma", "tag", ")", "tuples", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/lemmatizers.py#L43-L80
train
markuskiller/textblob-de
textblob_de/lemmatizers.py
PatternParserLemmatizer._parse_text
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...
python
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...
[ "def", "_parse_text", "(", "self", ",", "text", ")", ":", "# Fix for issue #1", "text", "=", "text", ".", "replace", "(", "\"/\"", ",", "\" FORWARDSLASH \"", ")", "_tokenized", "=", "\" \"", ".", "join", "(", "self", ".", "tokenizer", ".", "tokenize", "(",...
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.
[ "Parse", "text", "(", "string", ")", "and", "return", "list", "of", "parsed", "sentences", "(", "strings", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/lemmatizers.py#L82-L96
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
_match
def _match(string, pattern): """ Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression. """ p = pattern try: if p[:1] == WILDCARD and (p[-1:] == WILDCARD and p[1:-...
python
def _match(string, pattern): """ Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression. """ p = pattern try: if p[:1] == WILDCARD and (p[-1:] == WILDCARD and p[1:-...
[ "def", "_match", "(", "string", ",", "pattern", ")", ":", "p", "=", "pattern", "try", ":", "if", "p", "[", ":", "1", "]", "==", "WILDCARD", "and", "(", "p", "[", "-", "1", ":", "]", "==", "WILDCARD", "and", "p", "[", "1", ":", "-", "1", "]"...
Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression.
[ "Returns", "True", "if", "the", "pattern", "matches", "the", "given", "word", "string", ".", "The", "pattern", "can", "include", "a", "wildcard", "(", "*", "front", "back", "*", "*", "both", "*", "in", "*", "side", ")", "or", "it", "can", "be", "a", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L101-L121
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
unique
def unique(iterable): """ Returns a list copy in which each item occurs only once (in-order). """ seen = set() return [x for x in iterable if x not in seen and not seen.add(x)]
python
def unique(iterable): """ Returns a list copy in which each item occurs only once (in-order). """ seen = set() return [x for x in iterable if x not in seen and not seen.add(x)]
[ "def", "unique", "(", "iterable", ")", ":", "seen", "=", "set", "(", ")", "return", "[", "x", "for", "x", "in", "iterable", "if", "x", "not", "in", "seen", "and", "not", "seen", ".", "add", "(", "x", ")", "]" ]
Returns a list copy in which each item occurs only once (in-order).
[ "Returns", "a", "list", "copy", "in", "which", "each", "item", "occurs", "only", "once", "(", "in", "-", "order", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L127-L131
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
product
def product(*args, **kwargs): """ Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")] ...
python
def product(*args, **kwargs): """ Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")] ...
[ "def", "product", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "p", "=", "[", "[", "]", "]", "for", "iterable", "in", "map", "(", "tuple", ",", "args", ")", "*", "kwargs", ".", "get", "(", "\"repeat\"", ",", "1", ")", ":", "p", "=", ...
Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")]
[ "Yields", "all", "permutations", "with", "replacement", ":", "list", "(", "product", "(", "cat", "repeat", "=", "2", "))", "=", ">", "[", "(", "c", "c", ")", "(", "c", "a", ")", "(", "c", "t", ")", "(", "a", "c", ")", "(", "a", "a", ")", "(...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L144-L161
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
variations
def variations(iterable, optional=lambda x: False): """ Returns all possible variations of a sequence with optional items. """ # For example: variations(["A?", "B?", "C"], optional=lambda s: s.endswith("?")) # defines a sequence where constraint A and B are optional: # [("A?", "B?", "C"), ("B?", "C"...
python
def variations(iterable, optional=lambda x: False): """ Returns all possible variations of a sequence with optional items. """ # For example: variations(["A?", "B?", "C"], optional=lambda s: s.endswith("?")) # defines a sequence where constraint A and B are optional: # [("A?", "B?", "C"), ("B?", "C"...
[ "def", "variations", "(", "iterable", ",", "optional", "=", "lambda", "x", ":", "False", ")", ":", "# For example: variations([\"A?\", \"B?\", \"C\"], optional=lambda s: s.endswith(\"?\"))", "# defines a sequence where constraint A and B are optional:", "# [(\"A?\", \"B?\", \"C\"), (\"...
Returns all possible variations of a sequence with optional items.
[ "Returns", "all", "possible", "variations", "of", "a", "sequence", "with", "optional", "items", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L167-L187
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
compile
def compile(pattern, *args, **kwargs): """ Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts). """ id, p = repr(pattern) + repr(args), pattern if id in _cache and not kwargs:...
python
def compile(pattern, *args, **kwargs): """ Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts). """ id, p = repr(pattern) + repr(args), pattern if id in _cache and not kwargs:...
[ "def", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "id", ",", "p", "=", "repr", "(", "pattern", ")", "+", "repr", "(", "args", ")", ",", "pattern", "if", "id", "in", "_cache", "and", "not", "kwargs", ":", "re...
Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts).
[ "Returns", "a", "Pattern", "from", "the", "given", "string", "or", "regular", "expression", ".", "Recently", "compiled", "patterns", "are", "kept", "in", "cache", "(", "if", "they", "do", "not", "use", "taxonomies", "which", "are", "mutable", "dicts", ")", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L927-L946
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
scan
def scan(pattern, string, *args, **kwargs): """ Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ return compile(pattern, *args, **kwargs).scan(string)
python
def scan(pattern, string, *args, **kwargs): """ Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ return compile(pattern, *args, **kwargs).scan(string)
[ "def", "scan", "(", "pattern", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "scan", "(", "string", ")" ]
Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it.
[ "Returns", "True", "if", "pattern", ".", "search", "(", "Sentence", "(", "string", "))", "may", "yield", "matches", ".", "If", "is", "often", "faster", "to", "scan", "prior", "to", "creating", "a", "Sentence", "and", "searching", "it", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L948-L952
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
match
def match(pattern, sentence, *args, **kwargs): """ Returns the first match found in the given sentence, or None. """ return compile(pattern, *args, **kwargs).match(sentence)
python
def match(pattern, sentence, *args, **kwargs): """ Returns the first match found in the given sentence, or None. """ return compile(pattern, *args, **kwargs).match(sentence)
[ "def", "match", "(", "pattern", ",", "sentence", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "match", "(", "sentence", ")" ]
Returns the first match found in the given sentence, or None.
[ "Returns", "the", "first", "match", "found", "in", "the", "given", "sentence", "or", "None", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L954-L957
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
search
def search(pattern, sentence, *args, **kwargs): """ Returns a list of all matches found in the given sentence. """ return compile(pattern, *args, **kwargs).search(sentence)
python
def search(pattern, sentence, *args, **kwargs): """ Returns a list of all matches found in the given sentence. """ return compile(pattern, *args, **kwargs).search(sentence)
[ "def", "search", "(", "pattern", ",", "sentence", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "search", "(", "sentence", ")" ]
Returns a list of all matches found in the given sentence.
[ "Returns", "a", "list", "of", "all", "matches", "found", "in", "the", "given", "sentence", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L959-L962
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
odict.push
def push(self, kv): """ Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict. """ if kv[0] in self: self.__delitem__(kv[0]) self.__setitem__(kv[0], kv[1])
python
def push(self, kv): """ Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict. """ if kv[0] in self: self.__delitem__(kv[0]) self.__setitem__(kv[0], kv[1])
[ "def", "push", "(", "self", ",", "kv", ")", ":", "if", "kv", "[", "0", "]", "in", "self", ":", "self", ".", "__delitem__", "(", "kv", "[", "0", "]", ")", "self", ".", "__setitem__", "(", "kv", "[", "0", "]", ",", "kv", "[", "1", "]", ")" ]
Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict.
[ "Adds", "a", "new", "item", "from", "the", "given", "(", "key", "value", ")", "-", "tuple", ".", "If", "the", "key", "exists", "pushes", "the", "updated", "item", "to", "the", "head", "of", "the", "dict", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L211-L217
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.append
def append(self, term, type=None, value=None): """ Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200") """ term = self._normalize(term) ...
python
def append(self, term, type=None, value=None): """ Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200") """ term = self._normalize(term) ...
[ "def", "append", "(", "self", ",", "term", ",", "type", "=", "None", ",", "value", "=", "None", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "type", "=", "self", ".", "_normalize", "(", "type", ")", "self", ".", "setdefault",...
Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200")
[ "Appends", "the", "given", "term", "to", "the", "taxonomy", "and", "tags", "it", "as", "the", "given", "type", ".", "Optionally", "a", "disambiguation", "value", "can", "be", "supplied", ".", "For", "example", ":", "taxonomy", ".", "append", "(", "many", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L308-L317
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.classify
def classify(self, term, **kwargs): """ Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers. """ term = self._normalize(term) if dict.__contains__(self, term): re...
python
def classify(self, term, **kwargs): """ Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers. """ term = self._normalize(term) if dict.__contains__(self, term): re...
[ "def", "classify", "(", "self", ",", "term", ",", "*", "*", "kwargs", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "if", "dict", ".", "__contains__", "(", "self", ",", "term", ")", ":", "return", "self", "[", "term", "]", "...
Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers.
[ "Returns", "the", "(", "most", "recently", "added", ")", "semantic", "type", "for", "the", "given", "term", "(", "many", "=", ">", "quantity", ")", ".", "If", "the", "term", "is", "not", "in", "the", "dictionary", "try", "Taxonomy", ".", "classifiers", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L319-L333
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.parents
def parents(self, term, recursive=False, **kwargs): """ Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root. """ def dfs(term, recursive=False, visited={}, **kwargs): if term in visited: # Break on cyclic relations....
python
def parents(self, term, recursive=False, **kwargs): """ Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root. """ def dfs(term, recursive=False, visited={}, **kwargs): if term in visited: # Break on cyclic relations....
[ "def", "parents", "(", "self", ",", "term", ",", "recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "def", "dfs", "(", "term", ",", "recursive", "=", "False", ",", "visited", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "if", "t...
Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root.
[ "Returns", "a", "list", "of", "all", "semantic", "types", "for", "the", "given", "term", ".", "If", "recursive", "=", "True", "traverses", "parents", "up", "to", "the", "root", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L335-L350
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.value
def value(self, term, **kwargs): """ Returns the value of the given term ("many" => "50-200") """ term = self._normalize(term) if term in self._values: return self._values[term] for classifier in self.classifiers: v = classifier.value(term, **kwargs) ...
python
def value(self, term, **kwargs): """ Returns the value of the given term ("many" => "50-200") """ term = self._normalize(term) if term in self._values: return self._values[term] for classifier in self.classifiers: v = classifier.value(term, **kwargs) ...
[ "def", "value", "(", "self", ",", "term", ",", "*", "*", "kwargs", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "if", "term", "in", "self", ".", "_values", ":", "return", "self", ".", "_values", "[", "term", "]", "for", "cl...
Returns the value of the given term ("many" => "50-200")
[ "Returns", "the", "value", "of", "the", "given", "term", "(", "many", "=", ">", "50", "-", "200", ")" ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L369-L378
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Constraint.fromstring
def fromstring(cls, s, **kwargs): """ Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ def...
python
def fromstring(cls, s, **kwargs): """ Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ def...
[ "def", "fromstring", "(", "cls", ",", "s", ",", "*", "*", "kwargs", ")", ":", "C", "=", "cls", "(", "*", "*", "kwargs", ")", "s", "=", "s", ".", "strip", "(", ")", "s", "=", "s", ".", "strip", "(", "\"{}\"", ")", "s", "=", "s", ".", "stri...
Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ defines a constraint with spaces, e.g., "[Mac OS ...
[ "Returns", "a", "new", "Constraint", "from", "the", "given", "string", ".", "Uppercase", "words", "indicate", "either", "a", "tag", "(", "NN", "JJ", "VP", ")", "or", "a", "taxonomy", "term", "(", "e", ".", "g", ".", "PRODUCT", "PERSON", ")", ".", "Sy...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L487-L546
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Constraint.match
def match(self, word): """ Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. ...
python
def match(self, word): """ Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. ...
[ "def", "match", "(", "self", ",", "word", ")", ":", "# If the constraint has a custom function it must return True.", "if", "self", ".", "custom", "is", "not", "None", "and", "self", ".", "custom", "(", "word", ")", "is", "False", ":", "return", "False", "# If...
Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. Individual terms in Constra...
[ "Return", "True", "if", "the", "given", "Word", "is", "part", "of", "the", "constraint", ":", "-", "the", "word", "(", "or", "lemma", ")", "occurs", "in", "Constraint", ".", "words", "OR", "-", "the", "word", "(", "or", "lemma", ")", "occurs", "in", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L571-L650
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.fromstring
def fromstring(cls, s, *args, **kwargs): """ Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in []. """ s = s.replace("\(", "&lparen;") s = s.replace("\)", "&rparen;") ...
python
def fromstring(cls, s, *args, **kwargs): """ Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in []. """ s = s.replace("\(", "&lparen;") s = s.replace("\)", "&rparen;") ...
[ "def", "fromstring", "(", "cls", ",", "s", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "s", "=", "s", ".", "replace", "(", "\"\\(\"", ",", "\"&lparen;\"", ")", "s", "=", "s", ".", "replace", "(", "\"\\)\"", ",", "\"&rparen;\"", ")", "s",...
Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in [].
[ "Returns", "a", "new", "Pattern", "from", "the", "given", "string", ".", "Constraints", "are", "separated", "by", "a", "space", ".", "If", "a", "constraint", "contains", "a", "space", "it", "must", "be", "wrapped", "in", "[]", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L718-L767
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.scan
def scan(self, string): """ Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ # In the following example, first scan the string for "good" and "bad": # p = Pattern.fromstring("good|bad NN"...
python
def scan(self, string): """ Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ # In the following example, first scan the string for "good" and "bad": # p = Pattern.fromstring("good|bad NN"...
[ "def", "scan", "(", "self", ",", "string", ")", ":", "# In the following example, first scan the string for \"good\" and \"bad\":", "# p = Pattern.fromstring(\"good|bad NN\")", "# for s in open(\"parsed.txt\"):", "# if p.scan(s):", "# s = Sentence(s)", "# m = p.search(s...
Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it.
[ "Returns", "True", "if", "search", "(", "Sentence", "(", "string", "))", "may", "yield", "matches", ".", "If", "is", "often", "faster", "to", "scan", "prior", "to", "creating", "a", "Sentence", "and", "searching", "it", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L769-L786
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.search
def search(self, sentence): """ Returns a list of all matches found in the given sentence. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": a=[]; [a.extend(self.search(s)) for s in sen...
python
def search(self, sentence): """ Returns a list of all matches found in the given sentence. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": a=[]; [a.extend(self.search(s)) for s in sen...
[ "def", "search", "(", "self", ",", "sentence", ")", ":", "if", "sentence", ".", "__class__", ".", "__name__", "==", "\"Sentence\"", ":", "pass", "elif", "isinstance", "(", "sentence", ",", "list", ")", "or", "sentence", ".", "__class__", ".", "__name__", ...
Returns a list of all matches found in the given sentence.
[ "Returns", "a", "list", "of", "all", "matches", "found", "in", "the", "given", "sentence", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L788-L806
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.match
def match(self, sentence, start=0, _v=None, _u=None): """ Returns the first match found in the given sentence, or None. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": return find(lam...
python
def match(self, sentence, start=0, _v=None, _u=None): """ Returns the first match found in the given sentence, or None. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": return find(lam...
[ "def", "match", "(", "self", ",", "sentence", ",", "start", "=", "0", ",", "_v", "=", "None", ",", "_u", "=", "None", ")", ":", "if", "sentence", ".", "__class__", ".", "__name__", "==", "\"Sentence\"", ":", "pass", "elif", "isinstance", "(", "senten...
Returns the first match found in the given sentence, or None.
[ "Returns", "the", "first", "match", "found", "in", "the", "given", "sentence", "or", "None", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L808-L835
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constraint
def constraint(self, word): """ Returns the constraint that matches the given Word, or None. """ if word.index in self._map1: return self._map1[word.index]
python
def constraint(self, word): """ Returns the constraint that matches the given Word, or None. """ if word.index in self._map1: return self._map1[word.index]
[ "def", "constraint", "(", "self", ",", "word", ")", ":", "if", "word", ".", "index", "in", "self", ".", "_map1", ":", "return", "self", ".", "_map1", "[", "word", ".", "index", "]" ]
Returns the constraint that matches the given Word, or None.
[ "Returns", "the", "constraint", "that", "matches", "the", "given", "Word", "or", "None", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1005-L1009
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constraints
def constraints(self, chunk): """ Returns a list of constraints that match the given Chunk. """ a = [self._map1[w.index] for w in chunk.words if w.index in self._map1] b = []; [b.append(constraint) for constraint in a if constraint not in b] return b
python
def constraints(self, chunk): """ Returns a list of constraints that match the given Chunk. """ a = [self._map1[w.index] for w in chunk.words if w.index in self._map1] b = []; [b.append(constraint) for constraint in a if constraint not in b] return b
[ "def", "constraints", "(", "self", ",", "chunk", ")", ":", "a", "=", "[", "self", ".", "_map1", "[", "w", ".", "index", "]", "for", "w", "in", "chunk", ".", "words", "if", "w", ".", "index", "in", "self", ".", "_map1", "]", "b", "=", "[", "]"...
Returns a list of constraints that match the given Chunk.
[ "Returns", "a", "list", "of", "constraints", "that", "match", "the", "given", "Chunk", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1011-L1016
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constituents
def constituents(self, constraint=None): """ Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index. """ # Select only words th...
python
def constituents(self, constraint=None): """ Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index. """ # Select only words th...
[ "def", "constituents", "(", "self", ",", "constraint", "=", "None", ")", ":", "# Select only words that match the given constraint.", "# Note: this will only work with constraints from Match.pattern.sequence.", "W", "=", "self", ".", "words", "n", "=", "len", "(", "self", ...
Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index.
[ "Returns", "a", "list", "of", "Word", "and", "Chunk", "objects", "where", "words", "have", "been", "grouped", "into", "their", "chunks", "whenever", "possible", ".", "Optionally", "returns", "only", "chunks", "/", "words", "that", "match", "given", "constraint...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1018-L1049
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.group
def group(self, index, chunked=False): """ Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", S...
python
def group(self, index, chunked=False): """ Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", S...
[ "def", "group", "(", "self", ",", "index", ",", "chunked", "=", "False", ")", ":", "if", "index", "<", "0", "or", "index", ">", "len", "(", "self", ".", "pattern", ".", "groups", ")", ":", "raise", "IndexError", "(", "\"no such group\"", ")", "if", ...
Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", Sentence(parse("big black cat"))).group(1) => big bl...
[ "Returns", "a", "list", "of", "Word", "objects", "that", "match", "the", "given", "group", ".", "With", "chunked", "=", "True", "returns", "a", "list", "of", "Word", "+", "Chunk", "objects", "-", "see", "Match", ".", "constituents", "()", ".", "A", "gr...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1051-L1065
train
markuskiller/textblob-de
textblob_de/sentiments.py
PatternAnalyzer.analyze
def analyze(self, text): """Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated ...
python
def analyze(self, text): """Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated ...
[ "def", "analyze", "(", "self", ",", "text", ")", ":", "if", "self", ".", "lemmatize", ":", "text", "=", "self", ".", "_lemmatize", "(", "text", ")", "return", "self", ".", "RETURN_TYPE", "(", "*", "pattern_sentiment", "(", "text", ")", ")" ]
Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated lemmas (e.g. with pos tags) b...
[ "Return", "the", "sentiment", "as", "a", "tuple", "of", "the", "form", ":", "(", "polarity", "subjectivity", ")" ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/sentiments.py#L124-L142
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
stts2universal
def stts2universal(token, tag): """ Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP """ if tag in ("KON", "KOUI", "KOUS", "KOKOM"): return (token, CONJ) if tag in ("PTKZU", "PTKNEG", "PTKVZ", "PTKANT"): return (token, PRT) if tag in ("PDF", "PDAT"...
python
def stts2universal(token, tag): """ Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP """ if tag in ("KON", "KOUI", "KOUS", "KOKOM"): return (token, CONJ) if tag in ("PTKZU", "PTKNEG", "PTKVZ", "PTKANT"): return (token, PRT) if tag in ("PDF", "PDAT"...
[ "def", "stts2universal", "(", "token", ",", "tag", ")", ":", "if", "tag", "in", "(", "\"KON\"", ",", "\"KOUI\"", ",", "\"KOUS\"", ",", "\"KOKOM\"", ")", ":", "return", "(", "token", ",", "CONJ", ")", "if", "tag", "in", "(", "\"PTKZU\"", ",", "\"PTKNE...
Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP
[ "Converts", "an", "STTS", "tag", "to", "a", "universal", "tag", ".", "For", "example", ":", "ohne", "/", "APPR", "=", ">", "ohne", "/", "PREP" ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L160-L172
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
find_lemmata
def find_lemmata(tokens): """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list. """ for token in tokens: word, pos, lemma = token[0], token[1], token[0] if pos.startswith(("DT", "JJ")): lemma = pred...
python
def find_lemmata(tokens): """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list. """ for token in tokens: word, pos, lemma = token[0], token[1], token[0] if pos.startswith(("DT", "JJ")): lemma = pred...
[ "def", "find_lemmata", "(", "tokens", ")", ":", "for", "token", "in", "tokens", ":", "word", ",", "pos", ",", "lemma", "=", "token", "[", "0", "]", ",", "token", "[", "1", "]", ",", "token", "[", "0", "]", "if", "pos", ".", "startswith", "(", "...
Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list.
[ "Annotates", "the", "tokens", "with", "lemmata", "for", "plural", "nouns", "and", "conjugated", "verbs", "where", "each", "token", "is", "a", "[", "word", "part", "-", "of", "-", "speech", "]", "list", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L186-L199
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
tree
def tree(s, token=[WORD, POS, CHUNK, PNP, REL, LEMMA]): """ Returns a parsed Text from the given parsed string. """ return Text(s, token)
python
def tree(s, token=[WORD, POS, CHUNK, PNP, REL, LEMMA]): """ Returns a parsed Text from the given parsed string. """ return Text(s, token)
[ "def", "tree", "(", "s", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "LEMMA", "]", ")", ":", "return", "Text", "(", "s", ",", "token", ")" ]
Returns a parsed Text from the given parsed string.
[ "Returns", "a", "parsed", "Text", "from", "the", "given", "parsed", "string", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L250-L253
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
tag
def tag(s, tokenize=True, encoding="utf-8", **kwargs): """ Returns a list of (token, tag)-tuples from the given string. """ tags = [] for sentence in parse(s, tokenize, True, False, False, False, encoding, **kwargs).split(): for token in sentence: tags.append((token[0], token[1])) ...
python
def tag(s, tokenize=True, encoding="utf-8", **kwargs): """ Returns a list of (token, tag)-tuples from the given string. """ tags = [] for sentence in parse(s, tokenize, True, False, False, False, encoding, **kwargs).split(): for token in sentence: tags.append((token[0], token[1])) ...
[ "def", "tag", "(", "s", ",", "tokenize", "=", "True", ",", "encoding", "=", "\"utf-8\"", ",", "*", "*", "kwargs", ")", ":", "tags", "=", "[", "]", "for", "sentence", "in", "parse", "(", "s", ",", "tokenize", ",", "True", ",", "False", ",", "False...
Returns a list of (token, tag)-tuples from the given string.
[ "Returns", "a", "list", "of", "(", "token", "tag", ")", "-", "tuples", "from", "the", "given", "string", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L255-L262
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
keywords
def keywords(s, top=10, **kwargs): """ Returns a sorted list of keywords in the given string. """ return parser.find_keywords(s, top=top, frequency=parser.frequency)
python
def keywords(s, top=10, **kwargs): """ Returns a sorted list of keywords in the given string. """ return parser.find_keywords(s, top=top, frequency=parser.frequency)
[ "def", "keywords", "(", "s", ",", "top", "=", "10", ",", "*", "*", "kwargs", ")", ":", "return", "parser", ".", "find_keywords", "(", "s", ",", "top", "=", "top", ",", "frequency", "=", "parser", ".", "frequency", ")" ]
Returns a sorted list of keywords in the given string.
[ "Returns", "a", "sorted", "list", "of", "keywords", "in", "the", "given", "string", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L264-L267
train
markuskiller/textblob-de
textblob_de/tokenizers.py
sent_tokenize
def sent_tokenize(text, tokenizer=None): """Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. ...
python
def sent_tokenize(text, tokenizer=None): """Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. ...
[ "def", "sent_tokenize", "(", "text", ",", "tokenizer", "=", "None", ")", ":", "_tokenizer", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "NLTKPunktTokenizer", "(", ")", "return", "SentenceTokenizer", "(", "tokenizer", "=", "_tokenizer", ")...
Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. .. _TextBlob: http://textblob.readthedocs.org...
[ "Convenience", "function", "for", "tokenizing", "sentences", "(", "not", "iterable", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L306-L318
train
markuskiller/textblob-de
textblob_de/tokenizers.py
word_tokenize
def word_tokenize(text, tokenizer=None, include_punc=True, *args, **kwargs): """Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools ch...
python
def word_tokenize(text, tokenizer=None, include_punc=True, *args, **kwargs): """Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools ch...
[ "def", "word_tokenize", "(", "text", ",", "tokenizer", "=", "None", ",", "include_punc", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_tokenizer", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "NLTKPunktTokenizer",...
Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools chain object (generator).
[ "Convenience", "function", "for", "tokenizing", "text", "into", "words", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L321-L335
train
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.tokenize
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. :param nested: (optional) whether to return tokens as ...
python
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. :param nested: (optional) whether to return tokens as ...
[ "def", "tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ",", "nested", "=", "False", ")", ":", "self", ".", "tokens", "=", "[", "w", "for", "w", "in", "(", "self", ".", "word_tokenize", "(", "s", ",", "include_punc", ")", "fo...
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. :param nested: (optional) whether to return tokens as nested lists of sentences. Default to False.
[ "Return", "a", "list", "of", "word", "tokens", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L54-L72
train
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.sent_tokenize
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. """ ...
python
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. """ ...
[ "def", "sent_tokenize", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "sentences", "=", "self", ".", "sent_tok", ".", "tokenize", "(", "text", ",", "realign_boundaries", "=", "kwargs", ".", "get", "(", "\"realign_boundaries\"", ",", "True", ...
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.
[ "NLTK", "s", "sentence", "tokenizer", "(", "currently", "PunktSentenceTokenizer", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L75-L88
train
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.word_tokenize
def word_tokenize(self, text, include_punc=True): """The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the follow...
python
def word_tokenize(self, text, include_punc=True): """The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the follow...
[ "def", "word_tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "_tokens", "=", "self", ".", "word_tok", ...
The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the following steps: - split standard contractions, e.g. ``don...
[ "The", "Treebank", "tokenizer", "uses", "regular", "expressions", "to", "tokenize", "text", "as", "in", "Penn", "Treebank", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L90-L132
train
markuskiller/textblob-de
textblob_de/tokenizers.py
PatternTokenizer.sent_tokenize
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. ...
python
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. ...
[ "def", "sent_tokenize", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "sentences", "=", "find_sentences", "(", "text", ",", "punctuation", "=", "kwargs", ".", "get", "(", "\"punctuation\"", ",", "PUNCTUATION", ")", ",", "abbreviations", "=",...
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 ...
[ "Returns", "a", "list", "of", "sentences", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L173-L192
train
markuskiller/textblob-de
textblob_de/tokenizers.py
WordTokenizer.tokenize
def tokenize(self, text, include_punc=True, **kwargs): """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. """ return self.tokenizer.word_tokenize(text, inc...
python
def tokenize(self, text, include_punc=True, **kwargs): """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. """ return self.tokenizer.word_tokenize(text, inc...
[ "def", "tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "tokenizer", ".", "word_tokenize", "(", "text", ",", "include_punc", ",", "*", "*", "kwargs", ")" ]
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.
[ "Return", "a", "list", "of", "word", "tokens", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L254-L262
train
markuskiller/textblob-de
textblob_de/parsers.py
PatternParser.parse
def parse(self, text): """Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string. """ #: Do not pro...
python
def parse(self, text): """Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string. """ #: Do not pro...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "\"\"", "#: Do not process strings consisting of a single punctuation mark (Issue #4)", "elif", "text", "...
Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string.
[ "Parses", "the", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/parsers.py#L77-L116
train
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor.extract
def extract(self, text): """Return a list of noun phrases (strings) for a body of text. :param str text: A string. """ _extracted = [] if text.strip() == "": return _extracted parsed_sentences = self._parse_text(text) for s in parsed_sentences: ...
python
def extract(self, text): """Return a list of noun phrases (strings) for a body of text. :param str text: A string. """ _extracted = [] if text.strip() == "": return _extracted parsed_sentences = self._parse_text(text) for s in parsed_sentences: ...
[ "def", "extract", "(", "self", ",", "text", ")", ":", "_extracted", "=", "[", "]", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "_extracted", "parsed_sentences", "=", "self", ".", "_parse_text", "(", "text", ")", "for", "s", "in...
Return a list of noun phrases (strings) for a body of text. :param str text: A string.
[ "Return", "a", "list", "of", "noun", "phrases", "(", "strings", ")", "for", "a", "body", "of", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L88-L118
train
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor._filter_extracted
def _filter_extracted(self, extracted_list): """Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered ...
python
def _filter_extracted(self, extracted_list): """Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered ...
[ "def", "_filter_extracted", "(", "self", ",", "extracted_list", ")", ":", "_filtered", "=", "[", "]", "for", "np", "in", "extracted_list", ":", "_np", "=", "np", ".", "split", "(", ")", "if", "_np", "[", "0", "]", "in", "INSIGNIFICANT", ":", "_np", "...
Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered out by blob.noun_phrase method's np length (>1) ...
[ "Filter", "insignificant", "words", "for", "key", "noun", "phrase", "extraction", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L120-L146
train
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor._parse_text
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 '/') :par...
python
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 '/') :par...
[ "def", "_parse_text", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "self", ".", "tokenizer", ",", "PatternTokenizer", ")", ":", "parsed_text", "=", "pattern_parse", "(", "text", ",", "tokenize", "=", "True", ",", "lemmata", "=", "False", ...
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.
[ "Parse", "text", "(", "string", ")", "and", "return", "list", "of", "parsed", "sentences", "(", "strings", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L148-L169
train
markuskiller/textblob-de
textblob_de/taggers.py
PatternTagger.tag
def tag(self, sentence, tokenize=True): """Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string). """ #: Do not process empty ...
python
def tag(self, sentence, tokenize=True): """Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string). """ #: Do not process empty ...
[ "def", "tag", "(", "self", ",", "sentence", ",", "tokenize", "=", "True", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "sentence", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "#: Do not process strings consisting of a single punct...
Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string).
[ "Tag", "a", "string", "sentence", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/taggers.py#L60-L96
train
markuskiller/textblob-de
textblob_de/compat.py
decode_string
def decode_string(v, encoding="utf-8"): """Returns the given value as a Unicode string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, binary_type): for e in encoding: try: ...
python
def decode_string(v, encoding="utf-8"): """Returns the given value as a Unicode string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, binary_type): for e in encoding: try: ...
[ "def", "decode_string", "(", "v", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "encoding", ",", "basestring", ")", ":", "encoding", "=", "(", "(", "encoding", ",", ")", ",", ")", "+", "(", "(", "\"windows-1252\"", ",", ")", "...
Returns the given value as a Unicode string (if possible).
[ "Returns", "the", "given", "value", "as", "a", "Unicode", "string", "(", "if", "possible", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L112-L123
train
markuskiller/textblob-de
textblob_de/compat.py
encode_string
def encode_string(v, encoding="utf-8"): """Returns the given value as a Python byte string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, unicode): for e in encoding: try: ...
python
def encode_string(v, encoding="utf-8"): """Returns the given value as a Python byte string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, unicode): for e in encoding: try: ...
[ "def", "encode_string", "(", "v", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "encoding", ",", "basestring", ")", ":", "encoding", "=", "(", "(", "encoding", ",", ")", ",", ")", "+", "(", "(", "\"windows-1252\"", ",", ")", "...
Returns the given value as a Python byte string (if possible).
[ "Returns", "the", "given", "value", "as", "a", "Python", "byte", "string", "(", "if", "possible", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L126-L137
train
markuskiller/textblob-de
textblob_de/compat.py
_shutil_which
def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can b...
python
def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can b...
[ "def", "_shutil_which", "(", "cmd", ",", "mode", "=", "os", ".", "F_OK", "|", "os", ".", "X_OK", ",", "path", "=", "None", ")", ":", "# Check that a given file can be accessed with the correct mode.", "# Additionally check that `file` is not a directory, as on Windows", "...
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path.
[ "Given", "a", "command", "mode", "and", "a", "PATH", "string", "return", "the", "path", "which", "conforms", "to", "the", "given", "mode", "on", "the", "PATH", "or", "None", "if", "there", "is", "no", "such", "file", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L156-L215
train
markuskiller/textblob-de
textblob_de/blob.py
Word.translate
def translate(self, from_lang=None, to="de"): """Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``) """ if from_lang is None: from_lang = self.translator.detect(self.string) return self.translator.translate(se...
python
def translate(self, from_lang=None, to="de"): """Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``) """ if from_lang is None: from_lang = self.translator.detect(self.string) return self.translator.translate(se...
[ "def", "translate", "(", "self", ",", "from_lang", "=", "None", ",", "to", "=", "\"de\"", ")", ":", "if", "from_lang", "is", "None", ":", "from_lang", "=", "self", ".", "translator", ".", "detect", "(", "self", ".", "string", ")", "return", "self", "...
Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``)
[ "Translate", "the", "word", "to", "another", "language", "using", "Google", "s", "Translate", "API", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L100-L109
train
markuskiller/textblob-de
textblob_de/blob.py
WordList.lemmatize
def lemmatize(self): """Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property. """ _lemmatizer = PatternParserLem...
python
def lemmatize(self): """Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property. """ _lemmatizer = PatternParserLem...
[ "def", "lemmatize", "(", "self", ")", ":", "_lemmatizer", "=", "PatternParserLemmatizer", "(", "tokenizer", "=", "NLTKPunktTokenizer", "(", ")", ")", "# WordList object --> Sentence.string", "# add a period (improves parser accuracy)", "_raw", "=", "\" \"", ".", "join", ...
Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property.
[ "Return", "the", "lemma", "of", "each", "word", "in", "this", "WordList", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L305-L318
train
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.tokenize
def tokenize(self, tokenizer=None): """Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer. """ t = tokenizer if tokenizer is not None else self.tokenizer return WordList(t...
python
def tokenize(self, tokenizer=None): """Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer. """ t = tokenizer if tokenizer is not None else self.tokenizer return WordList(t...
[ "def", "tokenize", "(", "self", ",", "tokenizer", "=", "None", ")", ":", "t", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "self", ".", "tokenizer", "return", "WordList", "(", "t", ".", "tokenize", "(", "self", ".", "raw", ")", "...
Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer.
[ "Return", "a", "list", "of", "tokens", "using", "tokenizer", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L405-L413
train
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.noun_phrases
def noun_phrases(self): """Returns a list of noun phrases for this blob.""" return WordList([phrase.strip() for phrase in self.np_extractor.extract(self.raw) if len(phrase.split()) > 1])
python
def noun_phrases(self): """Returns a list of noun phrases for this blob.""" return WordList([phrase.strip() for phrase in self.np_extractor.extract(self.raw) if len(phrase.split()) > 1])
[ "def", "noun_phrases", "(", "self", ")", ":", "return", "WordList", "(", "[", "phrase", ".", "strip", "(", ")", "for", "phrase", "in", "self", ".", "np_extractor", ".", "extract", "(", "self", ".", "raw", ")", "if", "len", "(", "phrase", ".", "split"...
Returns a list of noun phrases for this blob.
[ "Returns", "a", "list", "of", "noun", "phrases", "for", "this", "blob", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L456-L460
train
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.pos_tags
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples """ return [(Word(...
python
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples """ return [(Word(...
[ "def", "pos_tags", "(", "self", ")", ":", "return", "[", "(", "Word", "(", "word", ",", "pos_tag", "=", "t", ")", ",", "unicode", "(", "t", ")", ")", "for", "word", ",", "t", "in", "self", ".", "pos_tagger", ".", "tag", "(", "self", ".", "raw",...
Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples
[ "Returns", "an", "list", "of", "tuples", "of", "the", "form", "(", "word", "POS", "tag", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L463-L479
train
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.word_counts
def word_counts(self): """Dictionary of word frequencies in this text.""" counts = defaultdict(int) stripped_words = [lowerstrip(word) for word in self.words] for word in stripped_words: counts[word] += 1 return counts
python
def word_counts(self): """Dictionary of word frequencies in this text.""" counts = defaultdict(int) stripped_words = [lowerstrip(word) for word in self.words] for word in stripped_words: counts[word] += 1 return counts
[ "def", "word_counts", "(", "self", ")", ":", "counts", "=", "defaultdict", "(", "int", ")", "stripped_words", "=", "[", "lowerstrip", "(", "word", ")", "for", "word", "in", "self", ".", "words", "]", "for", "word", "in", "stripped_words", ":", "counts", ...
Dictionary of word frequencies in this text.
[ "Dictionary", "of", "word", "frequencies", "in", "this", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L484-L490
train
markuskiller/textblob-de
textblob_de/blob.py
Sentence.dict
def dict(self): """The dict representation of this sentence.""" return { 'raw': self.raw, 'start_index': self.start_index, 'end_index': self.end_index, 'stripped': self.stripped, 'noun_phrases': self.noun_phrases, 'polarity': self.p...
python
def dict(self): """The dict representation of this sentence.""" return { 'raw': self.raw, 'start_index': self.start_index, 'end_index': self.end_index, 'stripped': self.stripped, 'noun_phrases': self.noun_phrases, 'polarity': self.p...
[ "def", "dict", "(", "self", ")", ":", "return", "{", "'raw'", ":", "self", ".", "raw", ",", "'start_index'", ":", "self", ".", "start_index", ",", "'end_index'", ":", "self", ".", "end_index", ",", "'stripped'", ":", "self", ".", "stripped", ",", "'nou...
The dict representation of this sentence.
[ "The", "dict", "representation", "of", "this", "sentence", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L614-L624
train
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.words
def words(self): """Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens. """ return WordList( word_tokenize...
python
def words(self): """Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens. """ return WordList( word_tokenize...
[ "def", "words", "(", "self", ")", ":", "return", "WordList", "(", "word_tokenize", "(", "self", ".", "raw", ",", "self", ".", "tokenizer", ",", "include_punc", "=", "False", ")", ")" ]
Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens.
[ "Return", "a", "list", "of", "word", "tokens", ".", "This", "excludes", "punctuation", "characters", ".", "If", "you", "want", "to", "include", "punctuation", "characters", "access", "the", "tokens", "property", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L650-L659
train
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.sentiment
def sentiment(self): """Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Senti...
python
def sentiment(self): """Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Senti...
[ "def", "sentiment", "(", "self", ")", ":", "#: Enhancement Issue #2", "#: adapted from 'textblob.en.sentiments.py'", "#: Return type declaration", "_RETURN_TYPE", "=", "namedtuple", "(", "'Sentiment'", ",", "[", "'polarity'", ",", "'subjectivity'", "]", ")", "_polarity", ...
Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Sentiment(polarity=0.0, subjectivity=...
[ "Return", "a", "tuple", "of", "form", "(", "polarity", "subjectivity", ")", "where", "polarity", "is", "a", "float", "within", "the", "range", "[", "-", "1", ".", "0", "1", ".", "0", "]", "and", "subjectivity", "is", "a", "float", "within", "the", "r...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L667-L692
train
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.to_json
def to_json(self, *args, **kwargs): """Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``) """ return json.dumps(self.serialized, *args, **kwargs)
python
def to_json(self, *args, **kwargs): """Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``) """ return json.dumps(self.serialized, *args, **kwargs)
[ "def", "to_json", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "serialized", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``)
[ "Return", "a", "json", "representation", "(", "str", ")", "of", "this", "blob", ".", "Takes", "the", "same", "arguments", "as", "json", ".", "dumps", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L728-L735
train
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE._create_sentence_objects
def _create_sentence_objects(self): """Returns a list of Sentence objects from the raw text.""" sentence_objects = [] sentences = sent_tokenize(self.raw, tokenizer=self.tokenizer) char_index = 0 # Keeps track of character index within the blob for sent in sentences: ...
python
def _create_sentence_objects(self): """Returns a list of Sentence objects from the raw text.""" sentence_objects = [] sentences = sent_tokenize(self.raw, tokenizer=self.tokenizer) char_index = 0 # Keeps track of character index within the blob for sent in sentences: ...
[ "def", "_create_sentence_objects", "(", "self", ")", ":", "sentence_objects", "=", "[", "]", "sentences", "=", "sent_tokenize", "(", "self", ".", "raw", ",", "tokenizer", "=", "self", ".", "tokenizer", ")", "char_index", "=", "0", "# Keeps track of character ind...
Returns a list of Sentence objects from the raw text.
[ "Returns", "a", "list", "of", "Sentence", "objects", "from", "the", "raw", "text", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L748-L779
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
ngrams
def ngrams(string, n=3, punctuation=PUNCTUATION, continuous=False): """ Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punc...
python
def ngrams(string, n=3, punctuation=PUNCTUATION, continuous=False): """ Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punc...
[ "def", "ngrams", "(", "string", ",", "n", "=", "3", ",", "punctuation", "=", "PUNCTUATION", ",", "continuous", "=", "False", ")", ":", "def", "strip_punctuation", "(", "s", ",", "punctuation", "=", "set", "(", "punctuation", ")", ")", ":", "return", "[...
Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punctuation marks are stripped from words.
[ "Returns", "a", "list", "of", "n", "-", "grams", "(", "tuples", "of", "n", "successive", "words", ")", "from", "the", "given", "string", ".", "Alternatively", "you", "can", "supply", "a", "Text", "or", "Sentence", "object", ".", "With", "continuous", "="...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L79-L101
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
deflood
def deflood(s, n=3): """ Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..." """ if n == 0: return s[0:0] return re.sub(r"((.)\2{%s,})" % (n-1), lambda m: m.group(1)[0] * n, s)
python
def deflood(s, n=3): """ Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..." """ if n == 0: return s[0:0] return re.sub(r"((.)\2{%s,})" % (n-1), lambda m: m.group(1)[0] * n, s)
[ "def", "deflood", "(", "s", ",", "n", "=", "3", ")", ":", "if", "n", "==", "0", ":", "return", "s", "[", "0", ":", "0", "]", "return", "re", ".", "sub", "(", "r\"((.)\\2{%s,})\"", "%", "(", "n", "-", "1", ")", ",", "lambda", "m", ":", "m", ...
Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..."
[ "Returns", "the", "string", "with", "no", "more", "than", "n", "repeated", "characters", "e", ".", "g", ".", "deflood", "(", "NIIIICE!!", "n", "=", "1", ")", "=", ">", "Nice!", "deflood", "(", "nice", ".....", "n", "=", "3", ")", "=", ">", "nice", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L103-L110
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
pprint
def pprint(string, token=[WORD, POS, CHUNK, PNP], column=4): """ Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object. """ if isinstance(string, basestring): print("\n\n".join([table(sentence, fill=colu...
python
def pprint(string, token=[WORD, POS, CHUNK, PNP], column=4): """ Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object. """ if isinstance(string, basestring): print("\n\n".join([table(sentence, fill=colu...
[ "def", "pprint", "(", "string", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", "]", ",", "column", "=", "4", ")", ":", "if", "isinstance", "(", "string", ",", "basestring", ")", ":", "print", "(", "\"\\n\\n\"", ".", "join", ...
Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object.
[ "Pretty", "-", "prints", "the", "output", "of", "Parser", ".", "parse", "()", "as", "a", "table", "with", "outlined", "columns", ".", "Alternatively", "you", "can", "supply", "a", "tree", ".", "Text", "or", "tree", ".", "Sentence", "object", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L112-L121
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_read
def _read(path, encoding="utf-8", comment=";;;"): """ Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode. """ if path: if isinstance(path, basestring) and os.path.exists(path): # From file path. if P...
python
def _read(path, encoding="utf-8", comment=";;;"): """ Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode. """ if path: if isinstance(path, basestring) and os.path.exists(path): # From file path. if P...
[ "def", "_read", "(", "path", ",", "encoding", "=", "\"utf-8\"", ",", "comment", "=", "\";;;\"", ")", ":", "if", "path", ":", "if", "isinstance", "(", "path", ",", "basestring", ")", "and", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "#...
Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode.
[ "Returns", "an", "iterator", "over", "the", "lines", "in", "the", "file", "at", "the", "given", "path", "strippping", "comments", "and", "decoding", "each", "line", "to", "Unicode", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L218-L242
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
penntreebank2universal
def penntreebank2universal(token, tag): """ Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. """ if tag.startswith(("NNP-", "NNPS-")): return (token, "%s-%s" % (NOUN, tag.split("-")[-1])) if tag in ("NN", "NNS", "NNP", "NNPS", "NP"): return (token, NOUN) i...
python
def penntreebank2universal(token, tag): """ Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. """ if tag.startswith(("NNP-", "NNPS-")): return (token, "%s-%s" % (NOUN, tag.split("-")[-1])) if tag in ("NN", "NNS", "NNP", "NNPS", "NP"): return (token, NOUN) i...
[ "def", "penntreebank2universal", "(", "token", ",", "tag", ")", ":", "if", "tag", ".", "startswith", "(", "(", "\"NNP-\"", ",", "\"NNPS-\"", ")", ")", ":", "return", "(", "token", ",", "\"%s-%s\"", "%", "(", "NOUN", ",", "tag", ".", "split", "(", "\"...
Returns a (token, tag)-tuple with a simplified universal part-of-speech tag.
[ "Returns", "a", "(", "token", "tag", ")", "-", "tuple", "with", "a", "simplified", "universal", "part", "-", "of", "-", "speech", "tag", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L891-L920
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_tokens
def find_tokens(string, punctuation=PUNCTUATION, abbreviations=ABBREVIATIONS, replace=replacements, linebreak=r"\n{2,}"): """ 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...
python
def find_tokens(string, punctuation=PUNCTUATION, abbreviations=ABBREVIATIONS, replace=replacements, linebreak=r"\n{2,}"): """ 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...
[ "def", "find_tokens", "(", "string", ",", "punctuation", "=", "PUNCTUATION", ",", "abbreviations", "=", "ABBREVIATIONS", ",", "replace", "=", "replacements", ",", "linebreak", "=", "r\"\\n{2,}\"", ")", ":", "# Handle periods separately.", "punctuation", "=", "tuple"...
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 brea...
[ "Returns", "a", "list", "of", "sentences", ".", "Each", "sentence", "is", "a", "space", "-", "separated", "string", "of", "tokens", "(", "words", ")", ".", "Handles", "common", "cases", "of", "abbreviations", "(", "e", ".", "g", ".", "etc", ".", "...",...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L976-L1046
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_suffix_rules
def _suffix_rules(token, tag="NN"): """ Default morphological tagging rules for English, based on word suffixes. """ if isinstance(token, (list, tuple)): token, tag = token if token.endswith("ing"): tag = "VBG" if token.endswith("ly"): tag = "RB" if token.endswith("s") an...
python
def _suffix_rules(token, tag="NN"): """ Default morphological tagging rules for English, based on word suffixes. """ if isinstance(token, (list, tuple)): token, tag = token if token.endswith("ing"): tag = "VBG" if token.endswith("ly"): tag = "RB" if token.endswith("s") an...
[ "def", "_suffix_rules", "(", "token", ",", "tag", "=", "\"NN\"", ")", ":", "if", "isinstance", "(", "token", ",", "(", "list", ",", "tuple", ")", ")", ":", "token", ",", "tag", "=", "token", "if", "token", ".", "endswith", "(", "\"ing\"", ")", ":",...
Default morphological tagging rules for English, based on word suffixes.
[ "Default", "morphological", "tagging", "rules", "for", "English", "based", "on", "word", "suffixes", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1053-L1070
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_tags
def find_tags(tokens, lexicon={}, model=None, morphology=None, context=None, entities=None, default=("NN", "NNP", "CD"), language="en", map=None, **kwargs): """ Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] ...
python
def find_tags(tokens, lexicon={}, model=None, morphology=None, context=None, entities=None, default=("NN", "NNP", "CD"), language="en", map=None, **kwargs): """ Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] ...
[ "def", "find_tags", "(", "tokens", ",", "lexicon", "=", "{", "}", ",", "model", "=", "None", ",", "morphology", "=", "None", ",", "context", "=", "None", ",", "entities", "=", "None", ",", "default", "=", "(", "\"NN\"", ",", "\"NNP\"", ",", "\"CD\"",...
Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] Words are tagged using the given lexicon of (word, tag)-items. Unknown words are tagged NN by default. Unknown words that start with a capital lette...
[ "Returns", "a", "list", "of", "[", "token", "tag", "]", "-", "items", "for", "the", "given", "list", "of", "tokens", ":", "[", "The", "cat", "purs", "]", "=", ">", "[[", "The", "DT", "]", "[", "cat", "NN", "]", "[", "purs", "VB", "]]", "Words",...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1072-L1123
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_chunks
def find_chunks(tagged, language="en"): """ The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O """ chunked = [x for x in tagg...
python
def find_chunks(tagged, language="en"): """ The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O """ chunked = [x for x in tagg...
[ "def", "find_chunks", "(", "tagged", ",", "language", "=", "\"en\"", ")", ":", "chunked", "=", "[", "x", "for", "x", "in", "tagged", "]", "tags", "=", "\"\"", ".", "join", "(", "\"%s%s\"", "%", "(", "tag", ",", "SEPARATOR", ")", "for", "token", ","...
The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ":", "The", "/", "DT", "nice", "/", "JJ", "fish", "/", "NN", "is", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1171-L1216
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_prepositions
def find_prepositions(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk. """ # Tokens that are not part of a preposition just get the O-tag. for ch in chunked...
python
def find_prepositions(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk. """ # Tokens that are not part of a preposition just get the O-tag. for ch in chunked...
[ "def", "find_prepositions", "(", "chunked", ")", ":", "# Tokens that are not part of a preposition just get the O-tag.", "for", "ch", "in", "chunked", ":", "ch", ".", "append", "(", "\"O\"", ")", "for", "i", ",", "chunk", "in", "enumerate", "(", "chunked", ")", ...
The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk.
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "preposition", "]", "-", "items", ".", "PP", "-", "chunks", "followed", "by", "NP...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1218-L1242
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_relations
def find_relations(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object. "...
python
def find_relations(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object. "...
[ "def", "find_relations", "(", "chunked", ")", ":", "tag", "=", "lambda", "token", ":", "token", "[", "2", "]", ".", "split", "(", "\"-\"", ")", "[", "-", "1", "]", "# B-NP => NP", "# Group successive tokens with the same chunk-tag.", "chunks", "=", "[", "]",...
The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object.
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "relation", "]", "-", "items", ".", "A", "noun", "phrase", "preceding", "a", "ver...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1250-L1296
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_keywords
def find_keywords(string, parser, top=10, frequency={}, **kwargs): """ Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequenc...
python
def find_keywords(string, parser, top=10, frequency={}, **kwargs): """ Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequenc...
[ "def", "find_keywords", "(", "string", ",", "parser", ",", "top", "=", "10", ",", "frequency", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "lemmata", "=", "kwargs", ".", "pop", "(", "\"lemmata\"", ",", "kwargs", ".", "pop", "(", "\"stem\"", "...
Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequency (df, 0.0-1.0) for each lemma, e.g., {"the": 0.8, "cat": 0.1, ......
[ "Returns", "a", "sorted", "list", "of", "keywords", "in", "the", "given", "string", ".", "The", "given", "parser", "(", "e", ".", "g", ".", "pattern", ".", "en", ".", "parser", ")", "is", "used", "to", "identify", "noun", "phrases", ".", "The", "give...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1300-L1366
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
tense_id
def tense_id(*args, **kwargs): """ Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated. """ # Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)): if len(args) == 1 and isinstance(args[0], (list,...
python
def tense_id(*args, **kwargs): """ Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated. """ # Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)): if len(args) == 1 and isinstance(args[0], (list,...
[ "def", "tense_id", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)):", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", "(", "list", ",", "tu...
Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated.
[ "Returns", "the", "tense", "id", "for", "a", "given", "(", "tense", "person", "number", "mood", "aspect", "negated", ")", ".", "Aliases", "and", "compound", "forms", "(", "e", ".", "g", ".", "IMPERFECT", ")", "are", "disambiguated", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1594-L1641
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_multilingual
def _multilingual(function, *args, **kwargs): """ Returns the value from the function with the given name in the given language module. By default, language="en". """ return getattr(_module(kwargs.pop("language", "en")), function)(*args, **kwargs)
python
def _multilingual(function, *args, **kwargs): """ Returns the value from the function with the given name in the given language module. By default, language="en". """ return getattr(_module(kwargs.pop("language", "en")), function)(*args, **kwargs)
[ "def", "_multilingual", "(", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "_module", "(", "kwargs", ".", "pop", "(", "\"language\"", ",", "\"en\"", ")", ")", ",", "function", ")", "(", "*", "args", ",", ...
Returns the value from the function with the given name in the given language module. By default, language="en".
[ "Returns", "the", "value", "from", "the", "function", "with", "the", "given", "name", "in", "the", "given", "language", "module", ".", "By", "default", "language", "=", "en", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2188-L2192
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
language
def language(s): """ Returns a (language, confidence)-tuple for the given string. """ s = decode_utf8(s) s = set(w.strip(PUNCTUATION) for w in s.replace("'", "' ").split()) n = float(len(s) or 1) p = {} for xx in LANGUAGES: lexicon = _module(xx).__dict__["lexicon"] p[xx] = su...
python
def language(s): """ Returns a (language, confidence)-tuple for the given string. """ s = decode_utf8(s) s = set(w.strip(PUNCTUATION) for w in s.replace("'", "' ").split()) n = float(len(s) or 1) p = {} for xx in LANGUAGES: lexicon = _module(xx).__dict__["lexicon"] p[xx] = su...
[ "def", "language", "(", "s", ")", ":", "s", "=", "decode_utf8", "(", "s", ")", "s", "=", "set", "(", "w", ".", "strip", "(", "PUNCTUATION", ")", "for", "w", "in", "s", ".", "replace", "(", "\"'\"", ",", "\"' \"", ")", ".", "split", "(", ")", ...
Returns a (language, confidence)-tuple for the given string.
[ "Returns", "a", "(", "language", "confidence", ")", "-", "tuple", "for", "the", "given", "string", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2194-L2204
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
lazylist._lazy
def _lazy(self, method, *args): """ If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it. """ if list.__len__(self) == 0: self.load() setattr(self, method, types.MethodType(getattr(list, method), self)) ...
python
def _lazy(self, method, *args): """ If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it. """ if list.__len__(self) == 0: self.load() setattr(self, method, types.MethodType(getattr(list, method), self)) ...
[ "def", "_lazy", "(", "self", ",", "method", ",", "*", "args", ")", ":", "if", "list", ".", "__len__", "(", "self", ")", "==", "0", ":", "self", ".", "load", "(", ")", "setattr", "(", "self", ",", "method", ",", "types", ".", "MethodType", "(", ...
If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it.
[ "If", "the", "list", "is", "empty", "calls", "lazylist", ".", "load", "()", ".", "Replaces", "lazylist", ".", "method", "()", "with", "list", ".", "method", "()", "and", "calls", "it", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L179-L186
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.train
def train(self, token, tag, previous=None, next=None): """ Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples. """ self._classifier.train(self._v(token, previous, next), type=tag)
python
def train(self, token, tag, previous=None, next=None): """ Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples. """ self._classifier.train(self._v(token, previous, next), type=tag)
[ "def", "train", "(", "self", ",", "token", ",", "tag", ",", "previous", "=", "None", ",", "next", "=", "None", ")", ":", "self", ".", "_classifier", ".", "train", "(", "self", ".", "_v", "(", "token", ",", "previous", ",", "next", ")", ",", "type...
Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Trains", "the", "model", "to", "predict", "the", "given", "tag", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L323-L327
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.classify
def classify(self, token, previous=None, next=None, **kwargs): """ Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples. """ return self._classifier.classify(self._v(token, previous, next), **kwargs)
python
def classify(self, token, previous=None, next=None, **kwargs): """ Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples. """ return self._classifier.classify(self._v(token, previous, next), **kwargs)
[ "def", "classify", "(", "self", ",", "token", ",", "previous", "=", "None", ",", "next", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_classifier", ".", "classify", "(", "self", ".", "_v", "(", "token", ",", "previous", "...
Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Returns", "the", "predicted", "tag", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L329-L333
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.apply
def apply(self, token, previous=(None, None), next=(None, None)): """ Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples. """ return [token[0], self._classifier.classify(self._v(token[0], previous, next))]
python
def apply(self, token, previous=(None, None), next=(None, None)): """ Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples. """ return [token[0], self._classifier.classify(self._v(token[0], previous, next))]
[ "def", "apply", "(", "self", ",", "token", ",", "previous", "=", "(", "None", ",", "None", ")", ",", "next", "=", "(", "None", ",", "None", ")", ")", ":", "return", "[", "token", "[", "0", "]", ",", "self", ".", "_classifier", ".", "classify", ...
Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Returns", "a", "(", "token", "tag", ")", "-", "tuple", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L335-L339
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model._v
def _v(self, token, previous=None, next=None): """ Returns a training vector for the given (word, tag)-tuple and its context. """ def f(v, s1, s2): if s2: v[s1 + " " + s2] = 1 p, n = previous, next p = ("", "") if not p else (p[0] or "", p[1] or "") ...
python
def _v(self, token, previous=None, next=None): """ Returns a training vector for the given (word, tag)-tuple and its context. """ def f(v, s1, s2): if s2: v[s1 + " " + s2] = 1 p, n = previous, next p = ("", "") if not p else (p[0] or "", p[1] or "") ...
[ "def", "_v", "(", "self", ",", "token", ",", "previous", "=", "None", ",", "next", "=", "None", ")", ":", "def", "f", "(", "v", ",", "s1", ",", "s2", ")", ":", "if", "s2", ":", "v", "[", "s1", "+", "\" \"", "+", "s2", "]", "=", "1", "p", ...
Returns a training vector for the given (word, tag)-tuple and its context.
[ "Returns", "a", "training", "vector", "for", "the", "given", "(", "word", "tag", ")", "-", "tuple", "and", "its", "context", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L341-L360
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Morphology.apply
def apply(self, token, previous=(None, None), next=(None, None)): """ Applies lexical rules to the given token, which is a [word, tag] list. """ w = token[0] for r in self: if r[1] in self._cmd: # Rule = ly hassuf 2 RB x f, x, pos, cmd = bool(0), r[0], r[-2], ...
python
def apply(self, token, previous=(None, None), next=(None, None)): """ Applies lexical rules to the given token, which is a [word, tag] list. """ w = token[0] for r in self: if r[1] in self._cmd: # Rule = ly hassuf 2 RB x f, x, pos, cmd = bool(0), r[0], r[-2], ...
[ "def", "apply", "(", "self", ",", "token", ",", "previous", "=", "(", "None", ",", "None", ")", ",", "next", "=", "(", "None", ",", "None", ")", ")", ":", "w", "=", "token", "[", "0", "]", "for", "r", "in", "self", ":", "if", "r", "[", "1",...
Applies lexical rules to the given token, which is a [word, tag] list.
[ "Applies", "lexical", "rules", "to", "the", "given", "token", "which", "is", "a", "[", "word", "tag", "]", "list", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L403-L425
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Morphology.insert
def insert(self, i, tag, affix, cmd="hassuf", tagged=None): """ Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly"). """ if affix.startswith("-") and affix.endswith("-"): affix, cmd = affix[+1:-1], "char" ...
python
def insert(self, i, tag, affix, cmd="hassuf", tagged=None): """ Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly"). """ if affix.startswith("-") and affix.endswith("-"): affix, cmd = affix[+1:-1], "char" ...
[ "def", "insert", "(", "self", ",", "i", ",", "tag", ",", "affix", ",", "cmd", "=", "\"hassuf\"", ",", "tagged", "=", "None", ")", ":", "if", "affix", ".", "startswith", "(", "\"-\"", ")", "and", "affix", ".", "endswith", "(", "\"-\"", ")", ":", "...
Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly").
[ "Inserts", "a", "new", "rule", "that", "assigns", "the", "given", "tag", "to", "words", "with", "the", "given", "affix", "e", ".", "g", ".", "Morphology", ".", "append", "(", "RB", "-", "ly", ")", "." ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L427-L441
train