partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | unique | Returns a list copy in which each item occurs only once (in-order). | textblob_de/ext/_pattern/text/search.py | 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):
""" 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)] | [
"Returns",
"a",
"list",
"copy",
"in",
"which",
"each",
"item",
"occurs",
"only",
"once",
"(",
"in",
"-",
"order",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L127-L131 | [
"def",
"unique",
"(",
"iterable",
")",
":",
"seen",
"=",
"set",
"(",
")",
"return",
"[",
"x",
"for",
"x",
"in",
"iterable",
"if",
"x",
"not",
"in",
"seen",
"and",
"not",
"seen",
".",
"add",
"(",
"x",
")",
"]"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | product | 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")] | textblob_de/ext/_pattern/text/search.py | 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):
""" 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",
")",
"(... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L144-L161 | [
"def",
"product",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"[",
"[",
"]",
"]",
"for",
"iterable",
"in",
"map",
"(",
"tuple",
",",
"args",
")",
"*",
"kwargs",
".",
"get",
"(",
"\"repeat\"",
",",
"1",
")",
":",
"p",
"=",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | variations | Returns all possible variations of a sequence with optional items. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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"... | [
"Returns",
"all",
"possible",
"variations",
"of",
"a",
"sequence",
"with",
"optional",
"items",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L167-L187 | [
"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\"), (\"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | compile | 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). | textblob_de/ext/_pattern/text/search.py | 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):
""" 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:... | [
"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",
")",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L927-L946 | [
"def",
"compile",
"(",
"pattern",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"id",
",",
"p",
"=",
"repr",
"(",
"pattern",
")",
"+",
"repr",
"(",
"args",
")",
",",
"pattern",
"if",
"id",
"in",
"_cache",
"and",
"not",
"kwargs",
":",
"re... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | scan | Returns True if pattern.search(Sentence(string)) may yield matches.
If is often faster to scan prior to creating a Sentence and searching it. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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) | [
"Returns",
"True",
"if",
"pattern",
".",
"search",
"(",
"Sentence",
"(",
"string",
"))",
"may",
"yield",
"matches",
".",
"If",
"is",
"often",
"faster",
"to",
"scan",
"prior",
"to",
"creating",
"a",
"Sentence",
"and",
"searching",
"it",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L948-L952 | [
"def",
"scan",
"(",
"pattern",
",",
"string",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"compile",
"(",
"pattern",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"scan",
"(",
"string",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | match | Returns the first match found in the given sentence, or None. | textblob_de/ext/_pattern/text/search.py | 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):
""" Returns the first match found in the given sentence, or None.
"""
return compile(pattern, *args, **kwargs).match(sentence) | [
"Returns",
"the",
"first",
"match",
"found",
"in",
"the",
"given",
"sentence",
"or",
"None",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L954-L957 | [
"def",
"match",
"(",
"pattern",
",",
"sentence",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"compile",
"(",
"pattern",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"match",
"(",
"sentence",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | search | Returns a list of all matches found in the given sentence. | textblob_de/ext/_pattern/text/search.py | 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):
""" Returns a list of all matches found in the given sentence.
"""
return compile(pattern, *args, **kwargs).search(sentence) | [
"Returns",
"a",
"list",
"of",
"all",
"matches",
"found",
"in",
"the",
"given",
"sentence",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L959-L962 | [
"def",
"search",
"(",
"pattern",
",",
"sentence",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"compile",
"(",
"pattern",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"search",
"(",
"sentence",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | odict.push | Adds a new item from the given (key, value)-tuple.
If the key exists, pushes the updated item to the head of the dict. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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]) | [
"Adds",
"a",
"new",
"item",
"from",
"the",
"given",
"(",
"key",
"value",
")",
"-",
"tuple",
".",
"If",
"the",
"key",
"exists",
"pushes",
"the",
"updated",
"item",
"to",
"the",
"head",
"of",
"the",
"dict",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L211-L217 | [
"def",
"push",
"(",
"self",
",",
"kv",
")",
":",
"if",
"kv",
"[",
"0",
"]",
"in",
"self",
":",
"self",
".",
"__delitem__",
"(",
"kv",
"[",
"0",
"]",
")",
"self",
".",
"__setitem__",
"(",
"kv",
"[",
"0",
"]",
",",
"kv",
"[",
"1",
"]",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Taxonomy.append | 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") | textblob_de/ext/_pattern/text/search.py | 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):
""" 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)
... | [
"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",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L308-L317 | [
"def",
"append",
"(",
"self",
",",
"term",
",",
"type",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"term",
"=",
"self",
".",
"_normalize",
"(",
"term",
")",
"type",
"=",
"self",
".",
"_normalize",
"(",
"type",
")",
"self",
".",
"setdefault",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Taxonomy.classify | Returns the (most recently added) semantic type for the given term ("many" => "quantity").
If the term is not in the dictionary, try Taxonomy.classifiers. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"Returns",
"the",
"(",
"most",
"recently",
"added",
")",
"semantic",
"type",
"for",
"the",
"given",
"term",
"(",
"many",
"=",
">",
"quantity",
")",
".",
"If",
"the",
"term",
"is",
"not",
"in",
"the",
"dictionary",
"try",
"Taxonomy",
".",
"classifiers",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L319-L333 | [
"def",
"classify",
"(",
"self",
",",
"term",
",",
"*",
"*",
"kwargs",
")",
":",
"term",
"=",
"self",
".",
"_normalize",
"(",
"term",
")",
"if",
"dict",
".",
"__contains__",
"(",
"self",
",",
"term",
")",
":",
"return",
"self",
"[",
"term",
"]",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Taxonomy.parents | Returns a list of all semantic types for the given term.
If recursive=True, traverses parents up to the root. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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.... | [
"Returns",
"a",
"list",
"of",
"all",
"semantic",
"types",
"for",
"the",
"given",
"term",
".",
"If",
"recursive",
"=",
"True",
"traverses",
"parents",
"up",
"to",
"the",
"root",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L335-L350 | [
"def",
"parents",
"(",
"self",
",",
"term",
",",
"recursive",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"dfs",
"(",
"term",
",",
"recursive",
"=",
"False",
",",
"visited",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"t... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Taxonomy.value | Returns the value of the given term ("many" => "50-200") | textblob_de/ext/_pattern/text/search.py | 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):
""" 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)
... | [
"Returns",
"the",
"value",
"of",
"the",
"given",
"term",
"(",
"many",
"=",
">",
"50",
"-",
"200",
")"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L369-L378 | [
"def",
"value",
"(",
"self",
",",
"term",
",",
"*",
"*",
"kwargs",
")",
":",
"term",
"=",
"self",
".",
"_normalize",
"(",
"term",
")",
"if",
"term",
"in",
"self",
".",
"_values",
":",
"return",
"self",
".",
"_values",
"[",
"term",
"]",
"for",
"cl... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Constraint.fromstring | 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 ... | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L487-L546 | [
"def",
"fromstring",
"(",
"cls",
",",
"s",
",",
"*",
"*",
"kwargs",
")",
":",
"C",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"s",
"=",
"s",
".",
"strip",
"(",
")",
"s",
"=",
"s",
".",
"strip",
"(",
"\"{}\"",
")",
"s",
"=",
"s",
".",
"stri... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Constraint.match | 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... | textblob_de/ext/_pattern/text/search.py | 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):
""" 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.
... | [
"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",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L571-L650 | [
"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... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Pattern.fromstring | 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 []. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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;")
... | [
"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",
"[]",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L718-L767 | [
"def",
"fromstring",
"(",
"cls",
",",
"s",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"\"\\(\"",
",",
"\"&lparen;\"",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"\"\\)\"",
",",
"\"&rparen;\"",
")",
"s",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Pattern.scan | Returns True if search(Sentence(string)) may yield matches.
If is often faster to scan prior to creating a Sentence and searching it. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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"... | [
"Returns",
"True",
"if",
"search",
"(",
"Sentence",
"(",
"string",
"))",
"may",
"yield",
"matches",
".",
"If",
"is",
"often",
"faster",
"to",
"scan",
"prior",
"to",
"creating",
"a",
"Sentence",
"and",
"searching",
"it",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L769-L786 | [
"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... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Pattern.search | Returns a list of all matches found in the given sentence. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"Returns",
"a",
"list",
"of",
"all",
"matches",
"found",
"in",
"the",
"given",
"sentence",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L788-L806 | [
"def",
"search",
"(",
"self",
",",
"sentence",
")",
":",
"if",
"sentence",
".",
"__class__",
".",
"__name__",
"==",
"\"Sentence\"",
":",
"pass",
"elif",
"isinstance",
"(",
"sentence",
",",
"list",
")",
"or",
"sentence",
".",
"__class__",
".",
"__name__",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Pattern.match | Returns the first match found in the given sentence, or None. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"Returns",
"the",
"first",
"match",
"found",
"in",
"the",
"given",
"sentence",
"or",
"None",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L808-L835 | [
"def",
"match",
"(",
"self",
",",
"sentence",
",",
"start",
"=",
"0",
",",
"_v",
"=",
"None",
",",
"_u",
"=",
"None",
")",
":",
"if",
"sentence",
".",
"__class__",
".",
"__name__",
"==",
"\"Sentence\"",
":",
"pass",
"elif",
"isinstance",
"(",
"senten... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Match.constraint | Returns the constraint that matches the given Word, or None. | textblob_de/ext/_pattern/text/search.py | 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):
""" Returns the constraint that matches the given Word, or None.
"""
if word.index in self._map1:
return self._map1[word.index] | [
"Returns",
"the",
"constraint",
"that",
"matches",
"the",
"given",
"Word",
"or",
"None",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1005-L1009 | [
"def",
"constraint",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
".",
"index",
"in",
"self",
".",
"_map1",
":",
"return",
"self",
".",
"_map1",
"[",
"word",
".",
"index",
"]"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Match.constraints | Returns a list of constraints that match the given Chunk. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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 | [
"Returns",
"a",
"list",
"of",
"constraints",
"that",
"match",
"the",
"given",
"Chunk",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1011-L1016 | [
"def",
"constraints",
"(",
"self",
",",
"chunk",
")",
":",
"a",
"=",
"[",
"self",
".",
"_map1",
"[",
"w",
".",
"index",
"]",
"for",
"w",
"in",
"chunk",
".",
"words",
"if",
"w",
".",
"index",
"in",
"self",
".",
"_map1",
"]",
"b",
"=",
"[",
"]"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Match.constituents | 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. | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1018-L1049 | [
"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",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Match.group | 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... | textblob_de/ext/_pattern/text/search.py | 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):
""" 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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1051-L1065 | [
"def",
"group",
"(",
"self",
",",
"index",
",",
"chunked",
"=",
"False",
")",
":",
"if",
"index",
"<",
"0",
"or",
"index",
">",
"len",
"(",
"self",
".",
"pattern",
".",
"groups",
")",
":",
"raise",
"IndexError",
"(",
"\"no such group\"",
")",
"if",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternAnalyzer.analyze | 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... | textblob_de/sentiments.py | 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):
"""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
... | [
"Return",
"the",
"sentiment",
"as",
"a",
"tuple",
"of",
"the",
"form",
":",
"(",
"polarity",
"subjectivity",
")"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/sentiments.py#L124-L142 | [
"def",
"analyze",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"lemmatize",
":",
"text",
"=",
"self",
".",
"_lemmatize",
"(",
"text",
")",
"return",
"self",
".",
"RETURN_TYPE",
"(",
"*",
"pattern_sentiment",
"(",
"text",
")",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | stts2universal | Converts an STTS tag to a universal tag.
For example: ohne/APPR => ohne/PREP | textblob_de/ext/_pattern/text/de/__init__.py | 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):
""" 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"... | [
"Converts",
"an",
"STTS",
"tag",
"to",
"a",
"universal",
"tag",
".",
"For",
"example",
":",
"ohne",
"/",
"APPR",
"=",
">",
"ohne",
"/",
"PREP"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L160-L172 | [
"def",
"stts2universal",
"(",
"token",
",",
"tag",
")",
":",
"if",
"tag",
"in",
"(",
"\"KON\"",
",",
"\"KOUI\"",
",",
"\"KOUS\"",
",",
"\"KOKOM\"",
")",
":",
"return",
"(",
"token",
",",
"CONJ",
")",
"if",
"tag",
"in",
"(",
"\"PTKZU\"",
",",
"\"PTKNE... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_lemmata | Annotates the tokens with lemmata for plural nouns and conjugated verbs,
where each token is a [word, part-of-speech] list. | textblob_de/ext/_pattern/text/de/__init__.py | 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):
""" 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... | [
"Annotates",
"the",
"tokens",
"with",
"lemmata",
"for",
"plural",
"nouns",
"and",
"conjugated",
"verbs",
"where",
"each",
"token",
"is",
"a",
"[",
"word",
"part",
"-",
"of",
"-",
"speech",
"]",
"list",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L186-L199 | [
"def",
"find_lemmata",
"(",
"tokens",
")",
":",
"for",
"token",
"in",
"tokens",
":",
"word",
",",
"pos",
",",
"lemma",
"=",
"token",
"[",
"0",
"]",
",",
"token",
"[",
"1",
"]",
",",
"token",
"[",
"0",
"]",
"if",
"pos",
".",
"startswith",
"(",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | tree | Returns a parsed Text from the given parsed string. | textblob_de/ext/_pattern/text/de/__init__.py | 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]):
""" Returns a parsed Text from the given parsed string.
"""
return Text(s, token) | [
"Returns",
"a",
"parsed",
"Text",
"from",
"the",
"given",
"parsed",
"string",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L250-L253 | [
"def",
"tree",
"(",
"s",
",",
"token",
"=",
"[",
"WORD",
",",
"POS",
",",
"CHUNK",
",",
"PNP",
",",
"REL",
",",
"LEMMA",
"]",
")",
":",
"return",
"Text",
"(",
"s",
",",
"token",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | tag | Returns a list of (token, tag)-tuples from the given string. | textblob_de/ext/_pattern/text/de/__init__.py | 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):
""" 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]))
... | [
"Returns",
"a",
"list",
"of",
"(",
"token",
"tag",
")",
"-",
"tuples",
"from",
"the",
"given",
"string",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L255-L262 | [
"def",
"tag",
"(",
"s",
",",
"tokenize",
"=",
"True",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"*",
"*",
"kwargs",
")",
":",
"tags",
"=",
"[",
"]",
"for",
"sentence",
"in",
"parse",
"(",
"s",
",",
"tokenize",
",",
"True",
",",
"False",
",",
"False... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | keywords | Returns a sorted list of keywords in the given string. | textblob_de/ext/_pattern/text/de/__init__.py | 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):
""" Returns a sorted list of keywords in the given string.
"""
return parser.find_keywords(s, top=top, frequency=parser.frequency) | [
"Returns",
"a",
"sorted",
"list",
"of",
"keywords",
"in",
"the",
"given",
"string",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L264-L267 | [
"def",
"keywords",
"(",
"s",
",",
"top",
"=",
"10",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"parser",
".",
"find_keywords",
"(",
"s",
",",
"top",
"=",
"top",
",",
"frequency",
"=",
"parser",
".",
"frequency",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | sent_tokenize | 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... | textblob_de/tokenizers.py | 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):
"""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.
... | [
"Convenience",
"function",
"for",
"tokenizing",
"sentences",
"(",
"not",
"iterable",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L306-L318 | [
"def",
"sent_tokenize",
"(",
"text",
",",
"tokenizer",
"=",
"None",
")",
":",
"_tokenizer",
"=",
"tokenizer",
"if",
"tokenizer",
"is",
"not",
"None",
"else",
"NLTKPunktTokenizer",
"(",
")",
"return",
"SentenceTokenizer",
"(",
"tokenizer",
"=",
"_tokenizer",
")... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | word_tokenize | 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). | textblob_de/tokenizers.py | 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):
"""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... | [
"Convenience",
"function",
"for",
"tokenizing",
"text",
"into",
"words",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L321-L335 | [
"def",
"word_tokenize",
"(",
"text",
",",
"tokenizer",
"=",
"None",
",",
"include_punc",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_tokenizer",
"=",
"tokenizer",
"if",
"tokenizer",
"is",
"not",
"None",
"else",
"NLTKPunktTokenizer",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | NLTKPunktTokenizer.tokenize | 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. | textblob_de/tokenizers.py | 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):
"""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 ... | [
"Return",
"a",
"list",
"of",
"word",
"tokens",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L54-L72 | [
"def",
"tokenize",
"(",
"self",
",",
"text",
",",
"include_punc",
"=",
"True",
",",
"nested",
"=",
"False",
")",
":",
"self",
".",
"tokens",
"=",
"[",
"w",
"for",
"w",
"in",
"(",
"self",
".",
"word_tokenize",
"(",
"s",
",",
"include_punc",
")",
"fo... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | NLTKPunktTokenizer.sent_tokenize | 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. | textblob_de/tokenizers.py | 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):
"""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",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L75-L88 | [
"def",
"sent_tokenize",
"(",
"self",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"sentences",
"=",
"self",
".",
"sent_tok",
".",
"tokenize",
"(",
"text",
",",
"realign_boundaries",
"=",
"kwargs",
".",
"get",
"(",
"\"realign_boundaries\"",
",",
"True",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | NLTKPunktTokenizer.word_tokenize | 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... | textblob_de/tokenizers.py | 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):
"""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... | [
"The",
"Treebank",
"tokenizer",
"uses",
"regular",
"expressions",
"to",
"tokenize",
"text",
"as",
"in",
"Penn",
"Treebank",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L90-L132 | [
"def",
"word_tokenize",
"(",
"self",
",",
"text",
",",
"include_punc",
"=",
"True",
")",
":",
"#: Do not process empty strings (Issue #3)",
"if",
"text",
".",
"strip",
"(",
")",
"==",
"\"\"",
":",
"return",
"[",
"]",
"_tokens",
"=",
"self",
".",
"word_tok",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternTokenizer.sent_tokenize | 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 ... | textblob_de/tokenizers.py | 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):
"""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.
... | [
"Returns",
"a",
"list",
"of",
"sentences",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L173-L192 | [
"def",
"sent_tokenize",
"(",
"self",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"sentences",
"=",
"find_sentences",
"(",
"text",
",",
"punctuation",
"=",
"kwargs",
".",
"get",
"(",
"\"punctuation\"",
",",
"PUNCTUATION",
")",
",",
"abbreviations",
"=",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | WordTokenizer.tokenize | 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. | textblob_de/tokenizers.py | 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 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... | [
"Return",
"a",
"list",
"of",
"word",
"tokens",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L254-L262 | [
"def",
"tokenize",
"(",
"self",
",",
"text",
",",
"include_punc",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"tokenizer",
".",
"word_tokenize",
"(",
"text",
",",
"include_punc",
",",
"*",
"*",
"kwargs",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternParser.parse | 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. | textblob_de/parsers.py | 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):
"""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... | [
"Parses",
"the",
"text",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/parsers.py#L77-L116 | [
"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",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternParserNPExtractor.extract | Return a list of noun phrases (strings) for a body of text.
:param str text: A string. | textblob_de/np_extractors.py | 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):
"""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:
... | [
"Return",
"a",
"list",
"of",
"noun",
"phrases",
"(",
"strings",
")",
"for",
"a",
"body",
"of",
"text",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L88-L118 | [
"def",
"extract",
"(",
"self",
",",
"text",
")",
":",
"_extracted",
"=",
"[",
"]",
"if",
"text",
".",
"strip",
"(",
")",
"==",
"\"\"",
":",
"return",
"_extracted",
"parsed_sentences",
"=",
"self",
".",
"_parse_text",
"(",
"text",
")",
"for",
"s",
"in... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternParserNPExtractor._filter_extracted | 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) ... | textblob_de/np_extractors.py | 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):
"""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 ... | [
"Filter",
"insignificant",
"words",
"for",
"key",
"noun",
"phrase",
"extraction",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L120-L146 | [
"def",
"_filter_extracted",
"(",
"self",
",",
"extracted_list",
")",
":",
"_filtered",
"=",
"[",
"]",
"for",
"np",
"in",
"extracted_list",
":",
"_np",
"=",
"np",
".",
"split",
"(",
")",
"if",
"_np",
"[",
"0",
"]",
"in",
"INSIGNIFICANT",
":",
"_np",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternParserNPExtractor._parse_text | Parse text (string) and return list of parsed sentences (strings).
Each sentence consists of space separated token elements and the
token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA)
(separated by a forward slash '/')
:param str text: A string. | textblob_de/np_extractors.py | 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):
"""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... | [
"Parse",
"text",
"(",
"string",
")",
"and",
"return",
"list",
"of",
"parsed",
"sentences",
"(",
"strings",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L148-L169 | [
"def",
"_parse_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"tokenizer",
",",
"PatternTokenizer",
")",
":",
"parsed_text",
"=",
"pattern_parse",
"(",
"text",
",",
"tokenize",
"=",
"True",
",",
"lemmata",
"=",
"False",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | PatternTagger.tag | 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). | textblob_de/taggers.py | 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):
"""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 ... | [
"Tag",
"a",
"string",
"sentence",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/taggers.py#L60-L96 | [
"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... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | decode_string | Returns the given value as a Unicode string (if possible). | textblob_de/compat.py | 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"):
"""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:
... | [
"Returns",
"the",
"given",
"value",
"as",
"a",
"Unicode",
"string",
"(",
"if",
"possible",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L112-L123 | [
"def",
"decode_string",
"(",
"v",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"encoding",
",",
"basestring",
")",
":",
"encoding",
"=",
"(",
"(",
"encoding",
",",
")",
",",
")",
"+",
"(",
"(",
"\"windows-1252\"",
",",
")",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | encode_string | Returns the given value as a Python byte string (if possible). | textblob_de/compat.py | 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"):
"""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:
... | [
"Returns",
"the",
"given",
"value",
"as",
"a",
"Python",
"byte",
"string",
"(",
"if",
"possible",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L126-L137 | [
"def",
"encode_string",
"(",
"v",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"encoding",
",",
"basestring",
")",
":",
"encoding",
"=",
"(",
"(",
"encoding",
",",
")",
",",
")",
"+",
"(",
"(",
"\"windows-1252\"",
",",
")",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | _shutil_which | 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. | textblob_de/compat.py | 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):
"""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... | [
"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",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L156-L215 | [
"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",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Word.translate | Translate the word to another language using Google's Translate API.
.. versionadded:: 0.5.0 (``textblob``) | textblob_de/blob.py | 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"):
"""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... | [
"Translate",
"the",
"word",
"to",
"another",
"language",
"using",
"Google",
"s",
"Translate",
"API",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L100-L109 | [
"def",
"translate",
"(",
"self",
",",
"from_lang",
"=",
"None",
",",
"to",
"=",
"\"de\"",
")",
":",
"if",
"from_lang",
"is",
"None",
":",
"from_lang",
"=",
"self",
".",
"translator",
".",
"detect",
"(",
"self",
".",
"string",
")",
"return",
"self",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | WordList.lemmatize | 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. | textblob_de/blob.py | 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):
"""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... | [
"Return",
"the",
"lemma",
"of",
"each",
"word",
"in",
"this",
"WordList",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L305-L318 | [
"def",
"lemmatize",
"(",
"self",
")",
":",
"_lemmatizer",
"=",
"PatternParserLemmatizer",
"(",
"tokenizer",
"=",
"NLTKPunktTokenizer",
"(",
")",
")",
"# WordList object --> Sentence.string",
"# add a period (improves parser accuracy)",
"_raw",
"=",
"\" \"",
".",
"join",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | BaseBlob.tokenize | Return a list of tokens, using ``tokenizer``.
:param tokenizer: (optional) A tokenizer object. If None, defaults to
this blob's default tokenizer. | textblob_de/blob.py | 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):
"""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... | [
"Return",
"a",
"list",
"of",
"tokens",
"using",
"tokenizer",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L405-L413 | [
"def",
"tokenize",
"(",
"self",
",",
"tokenizer",
"=",
"None",
")",
":",
"t",
"=",
"tokenizer",
"if",
"tokenizer",
"is",
"not",
"None",
"else",
"self",
".",
"tokenizer",
"return",
"WordList",
"(",
"t",
".",
"tokenize",
"(",
"self",
".",
"raw",
")",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | BaseBlob.noun_phrases | Returns a list of noun phrases for this blob. | textblob_de/blob.py | 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):
"""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]) | [
"Returns",
"a",
"list",
"of",
"noun",
"phrases",
"for",
"this",
"blob",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L456-L460 | [
"def",
"noun_phrases",
"(",
"self",
")",
":",
"return",
"WordList",
"(",
"[",
"phrase",
".",
"strip",
"(",
")",
"for",
"phrase",
"in",
"self",
".",
"np_extractor",
".",
"extract",
"(",
"self",
".",
"raw",
")",
"if",
"len",
"(",
"phrase",
".",
"split"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | BaseBlob.pos_tags | 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 | textblob_de/blob.py | 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):
"""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(... | [
"Returns",
"an",
"list",
"of",
"tuples",
"of",
"the",
"form",
"(",
"word",
"POS",
"tag",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L463-L479 | [
"def",
"pos_tags",
"(",
"self",
")",
":",
"return",
"[",
"(",
"Word",
"(",
"word",
",",
"pos_tag",
"=",
"t",
")",
",",
"unicode",
"(",
"t",
")",
")",
"for",
"word",
",",
"t",
"in",
"self",
".",
"pos_tagger",
".",
"tag",
"(",
"self",
".",
"raw",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | BaseBlob.word_counts | Dictionary of word frequencies in this text. | textblob_de/blob.py | 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):
"""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 | [
"Dictionary",
"of",
"word",
"frequencies",
"in",
"this",
"text",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L484-L490 | [
"def",
"word_counts",
"(",
"self",
")",
":",
"counts",
"=",
"defaultdict",
"(",
"int",
")",
"stripped_words",
"=",
"[",
"lowerstrip",
"(",
"word",
")",
"for",
"word",
"in",
"self",
".",
"words",
"]",
"for",
"word",
"in",
"stripped_words",
":",
"counts",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Sentence.dict | The dict representation of this sentence. | textblob_de/blob.py | 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):
"""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... | [
"The",
"dict",
"representation",
"of",
"this",
"sentence",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L614-L624 | [
"def",
"dict",
"(",
"self",
")",
":",
"return",
"{",
"'raw'",
":",
"self",
".",
"raw",
",",
"'start_index'",
":",
"self",
".",
"start_index",
",",
"'end_index'",
":",
"self",
".",
"end_index",
",",
"'stripped'",
":",
"self",
".",
"stripped",
",",
"'nou... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | TextBlobDE.words | 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. | textblob_de/blob.py | 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 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... | [
"Return",
"a",
"list",
"of",
"word",
"tokens",
".",
"This",
"excludes",
"punctuation",
"characters",
".",
"If",
"you",
"want",
"to",
"include",
"punctuation",
"characters",
"access",
"the",
"tokens",
"property",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L650-L659 | [
"def",
"words",
"(",
"self",
")",
":",
"return",
"WordList",
"(",
"word_tokenize",
"(",
"self",
".",
"raw",
",",
"self",
".",
"tokenizer",
",",
"include_punc",
"=",
"False",
")",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | TextBlobDE.sentiment | 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=... | textblob_de/blob.py | 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):
"""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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L667-L692 | [
"def",
"sentiment",
"(",
"self",
")",
":",
"#: Enhancement Issue #2",
"#: adapted from 'textblob.en.sentiments.py'",
"#: Return type declaration",
"_RETURN_TYPE",
"=",
"namedtuple",
"(",
"'Sentiment'",
",",
"[",
"'polarity'",
",",
"'subjectivity'",
"]",
")",
"_polarity",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | TextBlobDE.to_json | Return a json representation (str) of this blob. Takes the same
arguments as json.dumps.
.. versionadded:: 0.5.1 (``textblob``) | textblob_de/blob.py | 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 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) | [
"Return",
"a",
"json",
"representation",
"(",
"str",
")",
"of",
"this",
"blob",
".",
"Takes",
"the",
"same",
"arguments",
"as",
"json",
".",
"dumps",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L728-L735 | [
"def",
"to_json",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"serialized",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | TextBlobDE._create_sentence_objects | Returns a list of Sentence objects from the raw text. | textblob_de/blob.py | 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):
"""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:
... | [
"Returns",
"a",
"list",
"of",
"Sentence",
"objects",
"from",
"the",
"raw",
"text",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L748-L779 | [
"def",
"_create_sentence_objects",
"(",
"self",
")",
":",
"sentence_objects",
"=",
"[",
"]",
"sentences",
"=",
"sent_tokenize",
"(",
"self",
".",
"raw",
",",
"tokenizer",
"=",
"self",
".",
"tokenizer",
")",
"char_index",
"=",
"0",
"# Keeps track of character ind... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | ngrams | 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. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"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",
"="... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L79-L101 | [
"def",
"ngrams",
"(",
"string",
",",
"n",
"=",
"3",
",",
"punctuation",
"=",
"PUNCTUATION",
",",
"continuous",
"=",
"False",
")",
":",
"def",
"strip_punctuation",
"(",
"s",
",",
"punctuation",
"=",
"set",
"(",
"punctuation",
")",
")",
":",
"return",
"[... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | deflood | Returns the string with no more than n repeated characters, e.g.,
deflood("NIIIICE!!", n=1) => "Nice!"
deflood("nice.....", n=3) => "nice..." | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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) | [
"Returns",
"the",
"string",
"with",
"no",
"more",
"than",
"n",
"repeated",
"characters",
"e",
".",
"g",
".",
"deflood",
"(",
"NIIIICE!!",
"n",
"=",
"1",
")",
"=",
">",
"Nice!",
"deflood",
"(",
"nice",
".....",
"n",
"=",
"3",
")",
"=",
">",
"nice",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L103-L110 | [
"def",
"deflood",
"(",
"s",
",",
"n",
"=",
"3",
")",
":",
"if",
"n",
"==",
"0",
":",
"return",
"s",
"[",
"0",
":",
"0",
"]",
"return",
"re",
".",
"sub",
"(",
"r\"((.)\\2{%s,})\"",
"%",
"(",
"n",
"-",
"1",
")",
",",
"lambda",
"m",
":",
"m",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | pprint | Pretty-prints the output of Parser.parse() as a table with outlined columns.
Alternatively, you can supply a tree.Text or tree.Sentence object. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"Pretty",
"-",
"prints",
"the",
"output",
"of",
"Parser",
".",
"parse",
"()",
"as",
"a",
"table",
"with",
"outlined",
"columns",
".",
"Alternatively",
"you",
"can",
"supply",
"a",
"tree",
".",
"Text",
"or",
"tree",
".",
"Sentence",
"object",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L112-L121 | [
"def",
"pprint",
"(",
"string",
",",
"token",
"=",
"[",
"WORD",
",",
"POS",
",",
"CHUNK",
",",
"PNP",
"]",
",",
"column",
"=",
"4",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"basestring",
")",
":",
"print",
"(",
"\"\\n\\n\"",
".",
"join",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | _read | Returns an iterator over the lines in the file at the given path,
strippping comments and decoding each line to Unicode. | textblob_de/ext/_pattern/text/__init__.py | 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=";;;"):
""" 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... | [
"Returns",
"an",
"iterator",
"over",
"the",
"lines",
"in",
"the",
"file",
"at",
"the",
"given",
"path",
"strippping",
"comments",
"and",
"decoding",
"each",
"line",
"to",
"Unicode",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L218-L242 | [
"def",
"_read",
"(",
"path",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"comment",
"=",
"\";;;\"",
")",
":",
"if",
"path",
":",
"if",
"isinstance",
"(",
"path",
",",
"basestring",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"#... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | penntreebank2universal | Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"Returns",
"a",
"(",
"token",
"tag",
")",
"-",
"tuple",
"with",
"a",
"simplified",
"universal",
"part",
"-",
"of",
"-",
"speech",
"tag",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L891-L920 | [
"def",
"penntreebank2universal",
"(",
"token",
",",
"tag",
")",
":",
"if",
"tag",
".",
"startswith",
"(",
"(",
"\"NNP-\"",
",",
"\"NNPS-\"",
")",
")",
":",
"return",
"(",
"token",
",",
"\"%s-%s\"",
"%",
"(",
"NOUN",
",",
"tag",
".",
"split",
"(",
"\"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_tokens | 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... | textblob_de/ext/_pattern/text/__init__.py | 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,}"):
""" 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... | [
"Returns",
"a",
"list",
"of",
"sentences",
".",
"Each",
"sentence",
"is",
"a",
"space",
"-",
"separated",
"string",
"of",
"tokens",
"(",
"words",
")",
".",
"Handles",
"common",
"cases",
"of",
"abbreviations",
"(",
"e",
".",
"g",
".",
"etc",
".",
"...",... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L976-L1046 | [
"def",
"find_tokens",
"(",
"string",
",",
"punctuation",
"=",
"PUNCTUATION",
",",
"abbreviations",
"=",
"ABBREVIATIONS",
",",
"replace",
"=",
"replacements",
",",
"linebreak",
"=",
"r\"\\n{2,}\"",
")",
":",
"# Handle periods separately.",
"punctuation",
"=",
"tuple"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | _suffix_rules | Default morphological tagging rules for English, based on word suffixes. | textblob_de/ext/_pattern/text/__init__.py | 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"):
""" 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... | [
"Default",
"morphological",
"tagging",
"rules",
"for",
"English",
"based",
"on",
"word",
"suffixes",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1053-L1070 | [
"def",
"_suffix_rules",
"(",
"token",
",",
"tag",
"=",
"\"NN\"",
")",
":",
"if",
"isinstance",
"(",
"token",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"token",
",",
"tag",
"=",
"token",
"if",
"token",
".",
"endswith",
"(",
"\"ing\"",
")",
":",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_tags | 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... | textblob_de/ext/_pattern/text/__init__.py | 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"), 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"]]
... | [
"Returns",
"a",
"list",
"of",
"[",
"token",
"tag",
"]",
"-",
"items",
"for",
"the",
"given",
"list",
"of",
"tokens",
":",
"[",
"The",
"cat",
"purs",
"]",
"=",
">",
"[[",
"The",
"DT",
"]",
"[",
"cat",
"NN",
"]",
"[",
"purs",
"VB",
"]]",
"Words",... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1072-L1123 | [
"def",
"find_tags",
"(",
"tokens",
",",
"lexicon",
"=",
"{",
"}",
",",
"model",
"=",
"None",
",",
"morphology",
"=",
"None",
",",
"context",
"=",
"None",
",",
"entities",
"=",
"None",
",",
"default",
"=",
"(",
"\"NN\"",
",",
"\"NNP\"",
",",
"\"CD\"",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_chunks | 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 | textblob_de/ext/_pattern/text/__init__.py | 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"):
""" 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... | [
"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",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1171-L1216 | [
"def",
"find_chunks",
"(",
"tagged",
",",
"language",
"=",
"\"en\"",
")",
":",
"chunked",
"=",
"[",
"x",
"for",
"x",
"in",
"tagged",
"]",
"tags",
"=",
"\"\"",
".",
"join",
"(",
"\"%s%s\"",
"%",
"(",
"tag",
",",
"SEPARATOR",
")",
"for",
"token",
","... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_prepositions | 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. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1218-L1242 | [
"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",
")",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_relations | 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. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1250-L1296 | [
"def",
"find_relations",
"(",
"chunked",
")",
":",
"tag",
"=",
"lambda",
"token",
":",
"token",
"[",
"2",
"]",
".",
"split",
"(",
"\"-\"",
")",
"[",
"-",
"1",
"]",
"# B-NP => NP",
"# Group successive tokens with the same chunk-tag.",
"chunks",
"=",
"[",
"]",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | find_keywords | 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, ...... | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"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... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1300-L1366 | [
"def",
"find_keywords",
"(",
"string",
",",
"parser",
",",
"top",
"=",
"10",
",",
"frequency",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"lemmata",
"=",
"kwargs",
".",
"pop",
"(",
"\"lemmata\"",
",",
"kwargs",
".",
"pop",
"(",
"\"stem\"",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | tense_id | Returns the tense id for a given (tense, person, number, mood, aspect, negated).
Aliases and compound forms (e.g., IMPERFECT) are disambiguated. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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,... | [
"Returns",
"the",
"tense",
"id",
"for",
"a",
"given",
"(",
"tense",
"person",
"number",
"mood",
"aspect",
"negated",
")",
".",
"Aliases",
"and",
"compound",
"forms",
"(",
"e",
".",
"g",
".",
"IMPERFECT",
")",
"are",
"disambiguated",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1594-L1641 | [
"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... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | _multilingual | Returns the value from the function with the given name in the given language module.
By default, language="en". | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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) | [
"Returns",
"the",
"value",
"from",
"the",
"function",
"with",
"the",
"given",
"name",
"in",
"the",
"given",
"language",
"module",
".",
"By",
"default",
"language",
"=",
"en",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2188-L2192 | [
"def",
"_multilingual",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"getattr",
"(",
"_module",
"(",
"kwargs",
".",
"pop",
"(",
"\"language\"",
",",
"\"en\"",
")",
")",
",",
"function",
")",
"(",
"*",
"args",
",",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | language | Returns a (language, confidence)-tuple for the given string. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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... | [
"Returns",
"a",
"(",
"language",
"confidence",
")",
"-",
"tuple",
"for",
"the",
"given",
"string",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2194-L2204 | [
"def",
"language",
"(",
"s",
")",
":",
"s",
"=",
"decode_utf8",
"(",
"s",
")",
"s",
"=",
"set",
"(",
"w",
".",
"strip",
"(",
"PUNCTUATION",
")",
"for",
"w",
"in",
"s",
".",
"replace",
"(",
"\"'\"",
",",
"\"' \"",
")",
".",
"split",
"(",
")",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | lazylist._lazy | If the list is empty, calls lazylist.load().
Replaces lazylist.method() with list.method() and calls it. | textblob_de/ext/_pattern/text/__init__.py | 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 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))
... | [
"If",
"the",
"list",
"is",
"empty",
"calls",
"lazylist",
".",
"load",
"()",
".",
"Replaces",
"lazylist",
".",
"method",
"()",
"with",
"list",
".",
"method",
"()",
"and",
"calls",
"it",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L179-L186 | [
"def",
"_lazy",
"(",
"self",
",",
"method",
",",
"*",
"args",
")",
":",
"if",
"list",
".",
"__len__",
"(",
"self",
")",
"==",
"0",
":",
"self",
".",
"load",
"(",
")",
"setattr",
"(",
"self",
",",
"method",
",",
"types",
".",
"MethodType",
"(",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Model.train | Trains the model to predict the given tag for the given token,
in context of the given previous and next (token, tag)-tuples. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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) | [
"Trains",
"the",
"model",
"to",
"predict",
"the",
"given",
"tag",
"for",
"the",
"given",
"token",
"in",
"context",
"of",
"the",
"given",
"previous",
"and",
"next",
"(",
"token",
"tag",
")",
"-",
"tuples",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L323-L327 | [
"def",
"train",
"(",
"self",
",",
"token",
",",
"tag",
",",
"previous",
"=",
"None",
",",
"next",
"=",
"None",
")",
":",
"self",
".",
"_classifier",
".",
"train",
"(",
"self",
".",
"_v",
"(",
"token",
",",
"previous",
",",
"next",
")",
",",
"type... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Model.classify | Returns the predicted tag for the given token,
in context of the given previous and next (token, tag)-tuples. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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) | [
"Returns",
"the",
"predicted",
"tag",
"for",
"the",
"given",
"token",
"in",
"context",
"of",
"the",
"given",
"previous",
"and",
"next",
"(",
"token",
"tag",
")",
"-",
"tuples",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L329-L333 | [
"def",
"classify",
"(",
"self",
",",
"token",
",",
"previous",
"=",
"None",
",",
"next",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_classifier",
".",
"classify",
"(",
"self",
".",
"_v",
"(",
"token",
",",
"previous",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Model.apply | Returns a (token, tag)-tuple for the given token,
in context of the given previous and next (token, tag)-tuples. | textblob_de/ext/_pattern/text/__init__.py | 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)):
""" 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))] | [
"Returns",
"a",
"(",
"token",
"tag",
")",
"-",
"tuple",
"for",
"the",
"given",
"token",
"in",
"context",
"of",
"the",
"given",
"previous",
"and",
"next",
"(",
"token",
"tag",
")",
"-",
"tuples",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L335-L339 | [
"def",
"apply",
"(",
"self",
",",
"token",
",",
"previous",
"=",
"(",
"None",
",",
"None",
")",
",",
"next",
"=",
"(",
"None",
",",
"None",
")",
")",
":",
"return",
"[",
"token",
"[",
"0",
"]",
",",
"self",
".",
"_classifier",
".",
"classify",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Model._v | Returns a training vector for the given (word, tag)-tuple and its context. | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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 "")
... | [
"Returns",
"a",
"training",
"vector",
"for",
"the",
"given",
"(",
"word",
"tag",
")",
"-",
"tuple",
"and",
"its",
"context",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L341-L360 | [
"def",
"_v",
"(",
"self",
",",
"token",
",",
"previous",
"=",
"None",
",",
"next",
"=",
"None",
")",
":",
"def",
"f",
"(",
"v",
",",
"s1",
",",
"s2",
")",
":",
"if",
"s2",
":",
"v",
"[",
"s1",
"+",
"\" \"",
"+",
"s2",
"]",
"=",
"1",
"p",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Morphology.apply | Applies lexical rules to the given token, which is a [word, tag] list. | textblob_de/ext/_pattern/text/__init__.py | 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)):
""" 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], ... | [
"Applies",
"lexical",
"rules",
"to",
"the",
"given",
"token",
"which",
"is",
"a",
"[",
"word",
"tag",
"]",
"list",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L403-L425 | [
"def",
"apply",
"(",
"self",
",",
"token",
",",
"previous",
"=",
"(",
"None",
",",
"None",
")",
",",
"next",
"=",
"(",
"None",
",",
"None",
")",
")",
":",
"w",
"=",
"token",
"[",
"0",
"]",
"for",
"r",
"in",
"self",
":",
"if",
"r",
"[",
"1",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Morphology.insert | Inserts a new rule that assigns the given tag to words with the given affix,
e.g., Morphology.append("RB", "-ly"). | textblob_de/ext/_pattern/text/__init__.py | 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):
""" 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"
... | [
"Inserts",
"a",
"new",
"rule",
"that",
"assigns",
"the",
"given",
"tag",
"to",
"words",
"with",
"the",
"given",
"affix",
"e",
".",
"g",
".",
"Morphology",
".",
"append",
"(",
"RB",
"-",
"ly",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L427-L441 | [
"def",
"insert",
"(",
"self",
",",
"i",
",",
"tag",
",",
"affix",
",",
"cmd",
"=",
"\"hassuf\"",
",",
"tagged",
"=",
"None",
")",
":",
"if",
"affix",
".",
"startswith",
"(",
"\"-\"",
")",
"and",
"affix",
".",
"endswith",
"(",
"\"-\"",
")",
":",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Context.apply | Applies contextual rules to the given list of tokens,
where each token is a [word, tag] list. | textblob_de/ext/_pattern/text/__init__.py | def apply(self, tokens):
""" Applies contextual rules to the given list of tokens,
where each token is a [word, tag] list.
"""
o = [("STAART", "STAART")] * 3 # Empty delimiters for look ahead/back.
t = o + tokens + o
for i, token in enumerate(t):
for r in ... | def apply(self, tokens):
""" Applies contextual rules to the given list of tokens,
where each token is a [word, tag] list.
"""
o = [("STAART", "STAART")] * 3 # Empty delimiters for look ahead/back.
t = o + tokens + o
for i, token in enumerate(t):
for r in ... | [
"Applies",
"contextual",
"rules",
"to",
"the",
"given",
"list",
"of",
"tokens",
"where",
"each",
"token",
"is",
"a",
"[",
"word",
"tag",
"]",
"list",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L498-L538 | [
"def",
"apply",
"(",
"self",
",",
"tokens",
")",
":",
"o",
"=",
"[",
"(",
"\"STAART\"",
",",
"\"STAART\"",
")",
"]",
"*",
"3",
"# Empty delimiters for look ahead/back.",
"t",
"=",
"o",
"+",
"tokens",
"+",
"o",
"for",
"i",
",",
"token",
"in",
"enumerate... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Context.insert | Inserts a new rule that updates words with tag1 to tag2,
given constraints x and y, e.g., Context.append("TO < NN", "VB") | textblob_de/ext/_pattern/text/__init__.py | def insert(self, i, tag1, tag2, cmd="prevtag", x=None, y=None):
""" Inserts a new rule that updates words with tag1 to tag2,
given constraints x and y, e.g., Context.append("TO < NN", "VB")
"""
if " < " in tag1 and not x and not y:
tag1, x = tag1.split(" < "); cmd="prevta... | def insert(self, i, tag1, tag2, cmd="prevtag", x=None, y=None):
""" Inserts a new rule that updates words with tag1 to tag2,
given constraints x and y, e.g., Context.append("TO < NN", "VB")
"""
if " < " in tag1 and not x and not y:
tag1, x = tag1.split(" < "); cmd="prevta... | [
"Inserts",
"a",
"new",
"rule",
"that",
"updates",
"words",
"with",
"tag1",
"to",
"tag2",
"given",
"constraints",
"x",
"and",
"y",
"e",
".",
"g",
".",
"Context",
".",
"append",
"(",
"TO",
"<",
"NN",
"VB",
")"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L540-L548 | [
"def",
"insert",
"(",
"self",
",",
"i",
",",
"tag1",
",",
"tag2",
",",
"cmd",
"=",
"\"prevtag\"",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"if",
"\" < \"",
"in",
"tag1",
"and",
"not",
"x",
"and",
"not",
"y",
":",
"tag1",
",",
"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Entities.apply | Applies the named entity recognizer to the given list of tokens,
where each token is a [word, tag] list. | textblob_de/ext/_pattern/text/__init__.py | def apply(self, tokens):
""" Applies the named entity recognizer to the given list of tokens,
where each token is a [word, tag] list.
"""
# Note: we could also scan for patterns, e.g.,
# "my|his|her name is|was *" => NNP-PERS.
i = 0
while i < len(tokens):
... | def apply(self, tokens):
""" Applies the named entity recognizer to the given list of tokens,
where each token is a [word, tag] list.
"""
# Note: we could also scan for patterns, e.g.,
# "my|his|her name is|was *" => NNP-PERS.
i = 0
while i < len(tokens):
... | [
"Applies",
"the",
"named",
"entity",
"recognizer",
"to",
"the",
"given",
"list",
"of",
"tokens",
"where",
"each",
"token",
"is",
"a",
"[",
"word",
"tag",
"]",
"list",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L588-L616 | [
"def",
"apply",
"(",
"self",
",",
"tokens",
")",
":",
"# Note: we could also scan for patterns, e.g.,",
"# \"my|his|her name is|was *\" => NNP-PERS.",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"tokens",
")",
":",
"w",
"=",
"tokens",
"[",
"i",
"]",
"[",
"0"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Entities.append | Appends a named entity to the lexicon,
e.g., Entities.append("Hooloovoo", "PERS") | textblob_de/ext/_pattern/text/__init__.py | def append(self, entity, name="pers"):
""" Appends a named entity to the lexicon,
e.g., Entities.append("Hooloovoo", "PERS")
"""
e = map(lambda s: s.lower(), entity.split(" ") + [name])
self.setdefault(e[0], []).append(e) | def append(self, entity, name="pers"):
""" Appends a named entity to the lexicon,
e.g., Entities.append("Hooloovoo", "PERS")
"""
e = map(lambda s: s.lower(), entity.split(" ") + [name])
self.setdefault(e[0], []).append(e) | [
"Appends",
"a",
"named",
"entity",
"to",
"the",
"lexicon",
"e",
".",
"g",
".",
"Entities",
".",
"append",
"(",
"Hooloovoo",
"PERS",
")"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L618-L623 | [
"def",
"append",
"(",
"self",
",",
"entity",
",",
"name",
"=",
"\"pers\"",
")",
":",
"e",
"=",
"map",
"(",
"lambda",
"s",
":",
"s",
".",
"lower",
"(",
")",
",",
"entity",
".",
"split",
"(",
"\" \"",
")",
"+",
"[",
"name",
"]",
")",
"self",
".... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Parser.find_keywords | Returns a sorted list of keywords in the given string. | textblob_de/ext/_pattern/text/__init__.py | def find_keywords(self, string, **kwargs):
""" Returns a sorted list of keywords in the given string.
"""
return find_keywords(string,
parser = self,
top = kwargs.pop("top", 10),
frequency = kwargs.pop("frequency", {}), **kwargs
... | def find_keywords(self, string, **kwargs):
""" Returns a sorted list of keywords in the given string.
"""
return find_keywords(string,
parser = self,
top = kwargs.pop("top", 10),
frequency = kwargs.pop("frequency", {}), **kwargs
... | [
"Returns",
"a",
"sorted",
"list",
"of",
"keywords",
"in",
"the",
"given",
"string",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L710-L717 | [
"def",
"find_keywords",
"(",
"self",
",",
"string",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"find_keywords",
"(",
"string",
",",
"parser",
"=",
"self",
",",
"top",
"=",
"kwargs",
".",
"pop",
"(",
"\"top\"",
",",
"10",
")",
",",
"frequency",
"=",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Parser.find_tokens | Returns a list of sentences from the given string.
Punctuation marks are separated from each word by a space. | textblob_de/ext/_pattern/text/__init__.py | def find_tokens(self, string, **kwargs):
""" Returns a list of sentences from the given string.
Punctuation marks are separated from each word by a space.
"""
# "The cat purs." => ["The cat purs ."]
return find_tokens(string,
punctuation = kwargs.get( "punctu... | def find_tokens(self, string, **kwargs):
""" Returns a list of sentences from the given string.
Punctuation marks are separated from each word by a space.
"""
# "The cat purs." => ["The cat purs ."]
return find_tokens(string,
punctuation = kwargs.get( "punctu... | [
"Returns",
"a",
"list",
"of",
"sentences",
"from",
"the",
"given",
"string",
".",
"Punctuation",
"marks",
"are",
"separated",
"from",
"each",
"word",
"by",
"a",
"space",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L719-L728 | [
"def",
"find_tokens",
"(",
"self",
",",
"string",
",",
"*",
"*",
"kwargs",
")",
":",
"# \"The cat purs.\" => [\"The cat purs .\"]",
"return",
"find_tokens",
"(",
"string",
",",
"punctuation",
"=",
"kwargs",
".",
"get",
"(",
"\"punctuation\"",
",",
"PUNCTUATION",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Parser.find_tags | Annotates the given list of tokens with part-of-speech tags.
Returns a list of tokens, where each token is now a [word, tag]-list. | textblob_de/ext/_pattern/text/__init__.py | def find_tags(self, tokens, **kwargs):
""" Annotates the given list of tokens with part-of-speech tags.
Returns a list of tokens, where each token is now a [word, tag]-list.
"""
# ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]]
return find_tags(tokens... | def find_tags(self, tokens, **kwargs):
""" Annotates the given list of tokens with part-of-speech tags.
Returns a list of tokens, where each token is now a [word, tag]-list.
"""
# ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]]
return find_tags(tokens... | [
"Annotates",
"the",
"given",
"list",
"of",
"tokens",
"with",
"part",
"-",
"of",
"-",
"speech",
"tags",
".",
"Returns",
"a",
"list",
"of",
"tokens",
"where",
"each",
"token",
"is",
"now",
"a",
"[",
"word",
"tag",
"]",
"-",
"list",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L730-L743 | [
"def",
"find_tags",
"(",
"self",
",",
"tokens",
",",
"*",
"*",
"kwargs",
")",
":",
"# [\"The\", \"cat\", \"purs\"] => [[\"The\", \"DT\"], [\"cat\", \"NN\"], [\"purs\", \"VB\"]]",
"return",
"find_tags",
"(",
"tokens",
",",
"lexicon",
"=",
"kwargs",
".",
"get",
"(",
"\"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Parser.find_chunks | Annotates the given list of tokens with chunk tags.
Several tags can be added, for example chunk + preposition tags. | textblob_de/ext/_pattern/text/__init__.py | def find_chunks(self, tokens, **kwargs):
""" Annotates the given list of tokens with chunk tags.
Several tags can be added, for example chunk + preposition tags.
"""
# [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] =>
# [["The", "DT", "B-NP"], ["cat", "NN", "I-NP"], ["purs", ... | def find_chunks(self, tokens, **kwargs):
""" Annotates the given list of tokens with chunk tags.
Several tags can be added, for example chunk + preposition tags.
"""
# [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] =>
# [["The", "DT", "B-NP"], ["cat", "NN", "I-NP"], ["purs", ... | [
"Annotates",
"the",
"given",
"list",
"of",
"tokens",
"with",
"chunk",
"tags",
".",
"Several",
"tags",
"can",
"be",
"added",
"for",
"example",
"chunk",
"+",
"preposition",
"tags",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L745-L753 | [
"def",
"find_chunks",
"(",
"self",
",",
"tokens",
",",
"*",
"*",
"kwargs",
")",
":",
"# [[\"The\", \"DT\"], [\"cat\", \"NN\"], [\"purs\", \"VB\"]] =>",
"# [[\"The\", \"DT\", \"B-NP\"], [\"cat\", \"NN\", \"I-NP\"], [\"purs\", \"VB\", \"B-VP\"]]",
"return",
"find_prepositions",
"(",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Parser.parse | Takes a string (sentences) and returns a tagged Unicode string (TaggedString).
Sentences in the output are separated by newlines.
With tokenize=True, punctuation is split from words and sentences are separated by \n.
With tags=True, part-of-speech tags are parsed (NN, VB, IN, ...).
... | textblob_de/ext/_pattern/text/__init__.py | def parse(self, s, tokenize=True, tags=True, chunks=True, relations=False, lemmata=False, encoding="utf-8", **kwargs):
""" Takes a string (sentences) and returns a tagged Unicode string (TaggedString).
Sentences in the output are separated by newlines.
With tokenize=True, punctuation is ... | def parse(self, s, tokenize=True, tags=True, chunks=True, relations=False, lemmata=False, encoding="utf-8", **kwargs):
""" Takes a string (sentences) and returns a tagged Unicode string (TaggedString).
Sentences in the output are separated by newlines.
With tokenize=True, punctuation is ... | [
"Takes",
"a",
"string",
"(",
"sentences",
")",
"and",
"returns",
"a",
"tagged",
"Unicode",
"string",
"(",
"TaggedString",
")",
".",
"Sentences",
"in",
"the",
"output",
"are",
"separated",
"by",
"newlines",
".",
"With",
"tokenize",
"=",
"True",
"punctuation",... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L770-L834 | [
"def",
"parse",
"(",
"self",
",",
"s",
",",
"tokenize",
"=",
"True",
",",
"tags",
"=",
"True",
",",
"chunks",
"=",
"True",
",",
"relations",
"=",
"False",
",",
"lemmata",
"=",
"False",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"*",
"*",
"kwargs",
")"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | TaggedString.split | Returns a list of sentences, where each sentence is a list of tokens,
where each token is a list of word + tags. | textblob_de/ext/_pattern/text/__init__.py | def split(self, sep=TOKENS):
""" Returns a list of sentences, where each sentence is a list of tokens,
where each token is a list of word + tags.
"""
if sep != TOKENS:
return unicode.split(self, sep)
if len(self) == 0:
return []
return [[[x.rep... | def split(self, sep=TOKENS):
""" Returns a list of sentences, where each sentence is a list of tokens,
where each token is a list of word + tags.
"""
if sep != TOKENS:
return unicode.split(self, sep)
if len(self) == 0:
return []
return [[[x.rep... | [
"Returns",
"a",
"list",
"of",
"sentences",
"where",
"each",
"sentence",
"is",
"a",
"list",
"of",
"tokens",
"where",
"each",
"token",
"is",
"a",
"list",
"of",
"word",
"+",
"tags",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L861-L871 | [
"def",
"split",
"(",
"self",
",",
"sep",
"=",
"TOKENS",
")",
":",
"if",
"sep",
"!=",
"TOKENS",
":",
"return",
"unicode",
".",
"split",
"(",
"self",
",",
"sep",
")",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"return",
"[",
"]",
"return",
"[... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Verbs.TENSES | Yields a list of tenses for this language, excluding negations.
Each tense is a (tense, person, number, mood, aspect)-tuple. | textblob_de/ext/_pattern/text/__init__.py | def TENSES(self):
""" Yields a list of tenses for this language, excluding negations.
Each tense is a (tense, person, number, mood, aspect)-tuple.
"""
a = set(TENSES[id] for id in self._format)
a = a.union(set(TENSES[id] for id in self._default.keys()))
a = a.union(se... | def TENSES(self):
""" Yields a list of tenses for this language, excluding negations.
Each tense is a (tense, person, number, mood, aspect)-tuple.
"""
a = set(TENSES[id] for id in self._format)
a = a.union(set(TENSES[id] for id in self._default.keys()))
a = a.union(se... | [
"Yields",
"a",
"list",
"of",
"tenses",
"for",
"this",
"language",
"excluding",
"negations",
".",
"Each",
"tense",
"is",
"a",
"(",
"tense",
"person",
"number",
"mood",
"aspect",
")",
"-",
"tuple",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1699-L1707 | [
"def",
"TENSES",
"(",
"self",
")",
":",
"a",
"=",
"set",
"(",
"TENSES",
"[",
"id",
"]",
"for",
"id",
"in",
"self",
".",
"_format",
")",
"a",
"=",
"a",
".",
"union",
"(",
"set",
"(",
"TENSES",
"[",
"id",
"]",
"for",
"id",
"in",
"self",
".",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Verbs.lemma | Returns the infinitive form of the given verb, or None. | textblob_de/ext/_pattern/text/__init__.py | def lemma(self, verb, parse=True):
""" Returns the infinitive form of the given verb, or None.
"""
if dict.__len__(self) == 0:
self.load()
if verb.lower() in self._inverse:
return self._inverse[verb.lower()]
if verb in self._inverse:
return sel... | def lemma(self, verb, parse=True):
""" Returns the infinitive form of the given verb, or None.
"""
if dict.__len__(self) == 0:
self.load()
if verb.lower() in self._inverse:
return self._inverse[verb.lower()]
if verb in self._inverse:
return sel... | [
"Returns",
"the",
"infinitive",
"form",
"of",
"the",
"given",
"verb",
"or",
"None",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1709-L1719 | [
"def",
"lemma",
"(",
"self",
",",
"verb",
",",
"parse",
"=",
"True",
")",
":",
"if",
"dict",
".",
"__len__",
"(",
"self",
")",
"==",
"0",
":",
"self",
".",
"load",
"(",
")",
"if",
"verb",
".",
"lower",
"(",
")",
"in",
"self",
".",
"_inverse",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Verbs.lexeme | Returns a list of all possible inflections of the given verb. | textblob_de/ext/_pattern/text/__init__.py | def lexeme(self, verb, parse=True):
""" Returns a list of all possible inflections of the given verb.
"""
a = []
b = self.lemma(verb, parse=parse)
if b in self:
a = [x for x in self[b] if x != ""]
elif parse is True: # rule-based
a = self.find_lexe... | def lexeme(self, verb, parse=True):
""" Returns a list of all possible inflections of the given verb.
"""
a = []
b = self.lemma(verb, parse=parse)
if b in self:
a = [x for x in self[b] if x != ""]
elif parse is True: # rule-based
a = self.find_lexe... | [
"Returns",
"a",
"list",
"of",
"all",
"possible",
"inflections",
"of",
"the",
"given",
"verb",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1721-L1731 | [
"def",
"lexeme",
"(",
"self",
",",
"verb",
",",
"parse",
"=",
"True",
")",
":",
"a",
"=",
"[",
"]",
"b",
"=",
"self",
".",
"lemma",
"(",
"verb",
",",
"parse",
"=",
"parse",
")",
"if",
"b",
"in",
"self",
":",
"a",
"=",
"[",
"x",
"for",
"x",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Verbs.conjugate | Inflects the verb and returns the given tense (or None).
For example: be
- Verbs.conjugate("is", INFINITVE) => be
- Verbs.conjugate("be", PRESENT, 1, SINGULAR) => I am
- Verbs.conjugate("be", PRESENT, 1, PLURAL) => we are
- Verbs.conjugate("be", PAST, 3, SINGU... | textblob_de/ext/_pattern/text/__init__.py | def conjugate(self, verb, *args, **kwargs):
""" Inflects the verb and returns the given tense (or None).
For example: be
- Verbs.conjugate("is", INFINITVE) => be
- Verbs.conjugate("be", PRESENT, 1, SINGULAR) => I am
- Verbs.conjugate("be", PRESENT, 1, PLURAL) => w... | def conjugate(self, verb, *args, **kwargs):
""" Inflects the verb and returns the given tense (or None).
For example: be
- Verbs.conjugate("is", INFINITVE) => be
- Verbs.conjugate("be", PRESENT, 1, SINGULAR) => I am
- Verbs.conjugate("be", PRESENT, 1, PLURAL) => w... | [
"Inflects",
"the",
"verb",
"and",
"returns",
"the",
"given",
"tense",
"(",
"or",
"None",
")",
".",
"For",
"example",
":",
"be",
"-",
"Verbs",
".",
"conjugate",
"(",
"is",
"INFINITVE",
")",
"=",
">",
"be",
"-",
"Verbs",
".",
"conjugate",
"(",
"be",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1733-L1760 | [
"def",
"conjugate",
"(",
"self",
",",
"verb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"id",
"=",
"tense_id",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# Get the tense index from the format description (or a default).",
"i1",
"=",
"self",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Verbs.tenses | Returns a list of possible tenses for the given inflected verb. | textblob_de/ext/_pattern/text/__init__.py | def tenses(self, verb, parse=True):
""" Returns a list of possible tenses for the given inflected verb.
"""
verb = verb.lower()
a = set()
b = self.lemma(verb, parse=parse)
v = []
if b in self:
v = self[b]
elif parse is True: # rule-based
... | def tenses(self, verb, parse=True):
""" Returns a list of possible tenses for the given inflected verb.
"""
verb = verb.lower()
a = set()
b = self.lemma(verb, parse=parse)
v = []
if b in self:
v = self[b]
elif parse is True: # rule-based
... | [
"Returns",
"a",
"list",
"of",
"possible",
"tenses",
"for",
"the",
"given",
"inflected",
"verb",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1762-L1789 | [
"def",
"tenses",
"(",
"self",
",",
"verb",
",",
"parse",
"=",
"True",
")",
":",
"verb",
"=",
"verb",
".",
"lower",
"(",
")",
"a",
"=",
"set",
"(",
")",
"b",
"=",
"self",
".",
"lemma",
"(",
"verb",
",",
"parse",
"=",
"parse",
")",
"v",
"=",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Sentiment.load | Loads the XML-file (with sentiment annotations) from the given path.
By default, Sentiment.path is lazily loaded. | textblob_de/ext/_pattern/text/__init__.py | def load(self, path=None):
""" Loads the XML-file (with sentiment annotations) from the given path.
By default, Sentiment.path is lazily loaded.
"""
# <word form="great" wordnet_id="a-01123879" pos="JJ" polarity="1.0" subjectivity="1.0" intensity="1.0" />
# <word form="damnmi... | def load(self, path=None):
""" Loads the XML-file (with sentiment annotations) from the given path.
By default, Sentiment.path is lazily loaded.
"""
# <word form="great" wordnet_id="a-01123879" pos="JJ" polarity="1.0" subjectivity="1.0" intensity="1.0" />
# <word form="damnmi... | [
"Loads",
"the",
"XML",
"-",
"file",
"(",
"with",
"sentiment",
"annotations",
")",
"from",
"the",
"given",
"path",
".",
"By",
"default",
"Sentiment",
".",
"path",
"is",
"lazily",
"loaded",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1878-L1922 | [
"def",
"load",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"# <word form=\"great\" wordnet_id=\"a-01123879\" pos=\"JJ\" polarity=\"1.0\" subjectivity=\"1.0\" intensity=\"1.0\" />",
"# <word form=\"damnmit\" polarity=\"-0.75\" subjectivity=\"1.0\" label=\"profanity\" />",
"if",
"not",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Sentiment.synset | Returns a (polarity, subjectivity)-tuple for the given synset id.
For example, the adjective "horrible" has id 193480 in WordNet:
Sentiment.synset(193480, pos="JJ") => (-0.6, 1.0, 1.0). | textblob_de/ext/_pattern/text/__init__.py | def synset(self, id, pos=ADJECTIVE):
""" Returns a (polarity, subjectivity)-tuple for the given synset id.
For example, the adjective "horrible" has id 193480 in WordNet:
Sentiment.synset(193480, pos="JJ") => (-0.6, 1.0, 1.0).
"""
id = str(id).zfill(8)
if not id.s... | def synset(self, id, pos=ADJECTIVE):
""" Returns a (polarity, subjectivity)-tuple for the given synset id.
For example, the adjective "horrible" has id 193480 in WordNet:
Sentiment.synset(193480, pos="JJ") => (-0.6, 1.0, 1.0).
"""
id = str(id).zfill(8)
if not id.s... | [
"Returns",
"a",
"(",
"polarity",
"subjectivity",
")",
"-",
"tuple",
"for",
"the",
"given",
"synset",
"id",
".",
"For",
"example",
"the",
"adjective",
"horrible",
"has",
"id",
"193480",
"in",
"WordNet",
":",
"Sentiment",
".",
"synset",
"(",
"193480",
"pos",... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1924-L1944 | [
"def",
"synset",
"(",
"self",
",",
"id",
",",
"pos",
"=",
"ADJECTIVE",
")",
":",
"id",
"=",
"str",
"(",
"id",
")",
".",
"zfill",
"(",
"8",
")",
"if",
"not",
"id",
".",
"startswith",
"(",
"(",
"\"n-\"",
",",
"\"v-\"",
",",
"\"a-\"",
",",
"\"r-\"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Sentiment.assessments | Returns a list of (chunk, polarity, subjectivity, label)-tuples for the given list of words:
where chunk is a list of successive words: a known word optionally
preceded by a modifier ("very good") or a negation ("not good"). | textblob_de/ext/_pattern/text/__init__.py | def assessments(self, words=[], negation=True):
""" Returns a list of (chunk, polarity, subjectivity, label)-tuples for the given list of words:
where chunk is a list of successive words: a known word optionally
preceded by a modifier ("very good") or a negation ("not good").
"""... | def assessments(self, words=[], negation=True):
""" Returns a list of (chunk, polarity, subjectivity, label)-tuples for the given list of words:
where chunk is a list of successive words: a known word optionally
preceded by a modifier ("very good") or a negation ("not good").
"""... | [
"Returns",
"a",
"list",
"of",
"(",
"chunk",
"polarity",
"subjectivity",
"label",
")",
"-",
"tuples",
"for",
"the",
"given",
"list",
"of",
"words",
":",
"where",
"chunk",
"is",
"a",
"list",
"of",
"successive",
"words",
":",
"a",
"known",
"word",
"optional... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2004-L2078 | [
"def",
"assessments",
"(",
"self",
",",
"words",
"=",
"[",
"]",
",",
"negation",
"=",
"True",
")",
":",
"a",
"=",
"[",
"]",
"m",
"=",
"None",
"# Preceding modifier (i.e., adverb or adjective).",
"n",
"=",
"None",
"# Preceding negation (e.g., \"not beautiful\").",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Sentiment.annotate | Annotates the given word with polarity, subjectivity and intensity scores,
and optionally a semantic label (e.g., MOOD for emoticons, IRONY for "(!)"). | textblob_de/ext/_pattern/text/__init__.py | def annotate(self, word, pos=None, polarity=0.0, subjectivity=0.0, intensity=1.0, label=None):
""" Annotates the given word with polarity, subjectivity and intensity scores,
and optionally a semantic label (e.g., MOOD for emoticons, IRONY for "(!)").
"""
w = self.setdefault(word, {})... | def annotate(self, word, pos=None, polarity=0.0, subjectivity=0.0, intensity=1.0, label=None):
""" Annotates the given word with polarity, subjectivity and intensity scores,
and optionally a semantic label (e.g., MOOD for emoticons, IRONY for "(!)").
"""
w = self.setdefault(word, {})... | [
"Annotates",
"the",
"given",
"word",
"with",
"polarity",
"subjectivity",
"and",
"intensity",
"scores",
"and",
"optionally",
"a",
"semantic",
"label",
"(",
"e",
".",
"g",
".",
"MOOD",
"for",
"emoticons",
"IRONY",
"for",
"(",
"!",
")",
")",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2080-L2087 | [
"def",
"annotate",
"(",
"self",
",",
"word",
",",
"pos",
"=",
"None",
",",
"polarity",
"=",
"0.0",
",",
"subjectivity",
"=",
"0.0",
",",
"intensity",
"=",
"1.0",
",",
"label",
"=",
"None",
")",
":",
"w",
"=",
"self",
".",
"setdefault",
"(",
"word",... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Spelling.train | Counts the words in the given string and saves the probabilities at the given path.
This can be used to generate a new model for the Spelling() constructor. | textblob_de/ext/_pattern/text/__init__.py | def train(self, s, path="spelling.txt"):
""" Counts the words in the given string and saves the probabilities at the given path.
This can be used to generate a new model for the Spelling() constructor.
"""
model = {}
for w in re.findall("[a-z]+", s.lower()):
model... | def train(self, s, path="spelling.txt"):
""" Counts the words in the given string and saves the probabilities at the given path.
This can be used to generate a new model for the Spelling() constructor.
"""
model = {}
for w in re.findall("[a-z]+", s.lower()):
model... | [
"Counts",
"the",
"words",
"in",
"the",
"given",
"string",
"and",
"saves",
"the",
"probabilities",
"at",
"the",
"given",
"path",
".",
"This",
"can",
"be",
"used",
"to",
"generate",
"a",
"new",
"model",
"for",
"the",
"Spelling",
"()",
"constructor",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2113-L2124 | [
"def",
"train",
"(",
"self",
",",
"s",
",",
"path",
"=",
"\"spelling.txt\"",
")",
":",
"model",
"=",
"{",
"}",
"for",
"w",
"in",
"re",
".",
"findall",
"(",
"\"[a-z]+\"",
",",
"s",
".",
"lower",
"(",
")",
")",
":",
"model",
"[",
"w",
"]",
"=",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Spelling._edit1 | Returns a set of words with edit distance 1 from the given word. | textblob_de/ext/_pattern/text/__init__.py | def _edit1(self, w):
""" Returns a set of words with edit distance 1 from the given word.
"""
# Of all spelling errors, 80% is covered by edit distance 1.
# Edit distance 1 = one character deleted, swapped, replaced or inserted.
split = [(w[:i], w[i:]) for i in range(len(w) + 1)]... | def _edit1(self, w):
""" Returns a set of words with edit distance 1 from the given word.
"""
# Of all spelling errors, 80% is covered by edit distance 1.
# Edit distance 1 = one character deleted, swapped, replaced or inserted.
split = [(w[:i], w[i:]) for i in range(len(w) + 1)]... | [
"Returns",
"a",
"set",
"of",
"words",
"with",
"edit",
"distance",
"1",
"from",
"the",
"given",
"word",
"."
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2126-L2138 | [
"def",
"_edit1",
"(",
"self",
",",
"w",
")",
":",
"# Of all spelling errors, 80% is covered by edit distance 1.",
"# Edit distance 1 = one character deleted, swapped, replaced or inserted.",
"split",
"=",
"[",
"(",
"w",
"[",
":",
"i",
"]",
",",
"w",
"[",
"i",
":",
"]"... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Spelling._edit2 | Returns a set of words with edit distance 2 from the given word | textblob_de/ext/_pattern/text/__init__.py | def _edit2(self, w):
""" Returns a set of words with edit distance 2 from the given word
"""
# Of all spelling errors, 99% is covered by edit distance 2.
# Only keep candidates that are actually known words (20% speedup).
return set(e2 for e1 in self._edit1(w) for e2 in self._edi... | def _edit2(self, w):
""" Returns a set of words with edit distance 2 from the given word
"""
# Of all spelling errors, 99% is covered by edit distance 2.
# Only keep candidates that are actually known words (20% speedup).
return set(e2 for e1 in self._edit1(w) for e2 in self._edi... | [
"Returns",
"a",
"set",
"of",
"words",
"with",
"edit",
"distance",
"2",
"from",
"the",
"given",
"word"
] | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2140-L2145 | [
"def",
"_edit2",
"(",
"self",
",",
"w",
")",
":",
"# Of all spelling errors, 99% is covered by edit distance 2.",
"# Only keep candidates that are actually known words (20% speedup).",
"return",
"set",
"(",
"e2",
"for",
"e1",
"in",
"self",
".",
"_edit1",
"(",
"w",
")",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | Spelling.suggest | Return a list of (word, confidence) spelling corrections for the given word,
based on the probability of known words with edit distance 1-2 from the given word. | textblob_de/ext/_pattern/text/__init__.py | def suggest(self, w):
""" Return a list of (word, confidence) spelling corrections for the given word,
based on the probability of known words with edit distance 1-2 from the given word.
"""
if len(self) == 0:
self.load()
if len(w) == 1:
return [(w, 1.... | def suggest(self, w):
""" Return a list of (word, confidence) spelling corrections for the given word,
based on the probability of known words with edit distance 1-2 from the given word.
"""
if len(self) == 0:
self.load()
if len(w) == 1:
return [(w, 1.... | [
"Return",
"a",
"list",
"of",
"(",
"word",
"confidence",
")",
"spelling",
"corrections",
"for",
"the",
"given",
"word",
"based",
"on",
"the",
"probability",
"of",
"known",
"words",
"with",
"edit",
"distance",
"1",
"-",
"2",
"from",
"the",
"given",
"word",
... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2152-L2172 | [
"def",
"suggest",
"(",
"self",
",",
"w",
")",
":",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"self",
".",
"load",
"(",
")",
"if",
"len",
"(",
"w",
")",
"==",
"1",
":",
"return",
"[",
"(",
"w",
",",
"1.0",
")",
"]",
"# I",
"if",
"w",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
train | zip | Returns a list of tuples, where the i-th tuple contains the i-th element
from each of the argument sequences or iterables (or default if too short). | textblob_de/ext/_pattern/text/tree.py | def zip(*args, **kwargs):
""" Returns a list of tuples, where the i-th tuple contains the i-th element
from each of the argument sequences or iterables (or default if too short).
"""
args = [list(iterable) for iterable in args]
n = max(map(len, args))
v = kwargs.get("default", None)
ret... | def zip(*args, **kwargs):
""" Returns a list of tuples, where the i-th tuple contains the i-th element
from each of the argument sequences or iterables (or default if too short).
"""
args = [list(iterable) for iterable in args]
n = max(map(len, args))
v = kwargs.get("default", None)
ret... | [
"Returns",
"a",
"list",
"of",
"tuples",
"where",
"the",
"i",
"-",
"th",
"tuple",
"contains",
"the",
"i",
"-",
"th",
"element",
"from",
"each",
"of",
"the",
"argument",
"sequences",
"or",
"iterables",
"(",
"or",
"default",
"if",
"too",
"short",
")",
"."... | markuskiller/textblob-de | python | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L89-L96 | [
"def",
"zip",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"[",
"list",
"(",
"iterable",
")",
"for",
"iterable",
"in",
"args",
"]",
"n",
"=",
"max",
"(",
"map",
"(",
"len",
",",
"args",
")",
")",
"v",
"=",
"kwargs",
".",
... | 1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.