repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
ngrams
def ngrams(string, n=3, punctuation=PUNCTUATION, continuous=False): """ Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punc...
python
def ngrams(string, n=3, punctuation=PUNCTUATION, continuous=False): """ Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punc...
[ "def", "ngrams", "(", "string", ",", "n", "=", "3", ",", "punctuation", "=", "PUNCTUATION", ",", "continuous", "=", "False", ")", ":", "def", "strip_punctuation", "(", "s", ",", "punctuation", "=", "set", "(", "punctuation", ")", ")", ":", "return", "[...
Returns a list of n-grams (tuples of n successive words) from the given string. Alternatively, you can supply a Text or Sentence object. With continuous=False, n-grams will not run over sentence markers (i.e., .!?). Punctuation marks are stripped from words.
[ "Returns", "a", "list", "of", "n", "-", "grams", "(", "tuples", "of", "n", "successive", "words", ")", "from", "the", "given", "string", ".", "Alternatively", "you", "can", "supply", "a", "Text", "or", "Sentence", "object", ".", "With", "continuous", "="...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L79-L101
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
deflood
def deflood(s, n=3): """ Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..." """ if n == 0: return s[0:0] return re.sub(r"((.)\2{%s,})" % (n-1), lambda m: m.group(1)[0] * n, s)
python
def deflood(s, n=3): """ Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..." """ if n == 0: return s[0:0] return re.sub(r"((.)\2{%s,})" % (n-1), lambda m: m.group(1)[0] * n, s)
[ "def", "deflood", "(", "s", ",", "n", "=", "3", ")", ":", "if", "n", "==", "0", ":", "return", "s", "[", "0", ":", "0", "]", "return", "re", ".", "sub", "(", "r\"((.)\\2{%s,})\"", "%", "(", "n", "-", "1", ")", ",", "lambda", "m", ":", "m", ...
Returns the string with no more than n repeated characters, e.g., deflood("NIIIICE!!", n=1) => "Nice!" deflood("nice.....", n=3) => "nice..."
[ "Returns", "the", "string", "with", "no", "more", "than", "n", "repeated", "characters", "e", ".", "g", ".", "deflood", "(", "NIIIICE!!", "n", "=", "1", ")", "=", ">", "Nice!", "deflood", "(", "nice", ".....", "n", "=", "3", ")", "=", ">", "nice", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L103-L110
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
pprint
def pprint(string, token=[WORD, POS, CHUNK, PNP], column=4): """ Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object. """ if isinstance(string, basestring): print("\n\n".join([table(sentence, fill=colu...
python
def pprint(string, token=[WORD, POS, CHUNK, PNP], column=4): """ Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object. """ if isinstance(string, basestring): print("\n\n".join([table(sentence, fill=colu...
[ "def", "pprint", "(", "string", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", "]", ",", "column", "=", "4", ")", ":", "if", "isinstance", "(", "string", ",", "basestring", ")", ":", "print", "(", "\"\\n\\n\"", ".", "join", ...
Pretty-prints the output of Parser.parse() as a table with outlined columns. Alternatively, you can supply a tree.Text or tree.Sentence object.
[ "Pretty", "-", "prints", "the", "output", "of", "Parser", ".", "parse", "()", "as", "a", "table", "with", "outlined", "columns", ".", "Alternatively", "you", "can", "supply", "a", "tree", ".", "Text", "or", "tree", ".", "Sentence", "object", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L112-L121
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_read
def _read(path, encoding="utf-8", comment=";;;"): """ Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode. """ if path: if isinstance(path, basestring) and os.path.exists(path): # From file path. if P...
python
def _read(path, encoding="utf-8", comment=";;;"): """ Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode. """ if path: if isinstance(path, basestring) and os.path.exists(path): # From file path. if P...
[ "def", "_read", "(", "path", ",", "encoding", "=", "\"utf-8\"", ",", "comment", "=", "\";;;\"", ")", ":", "if", "path", ":", "if", "isinstance", "(", "path", ",", "basestring", ")", "and", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "#...
Returns an iterator over the lines in the file at the given path, strippping comments and decoding each line to Unicode.
[ "Returns", "an", "iterator", "over", "the", "lines", "in", "the", "file", "at", "the", "given", "path", "strippping", "comments", "and", "decoding", "each", "line", "to", "Unicode", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L218-L242
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
penntreebank2universal
def penntreebank2universal(token, tag): """ Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. """ if tag.startswith(("NNP-", "NNPS-")): return (token, "%s-%s" % (NOUN, tag.split("-")[-1])) if tag in ("NN", "NNS", "NNP", "NNPS", "NP"): return (token, NOUN) i...
python
def penntreebank2universal(token, tag): """ Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. """ if tag.startswith(("NNP-", "NNPS-")): return (token, "%s-%s" % (NOUN, tag.split("-")[-1])) if tag in ("NN", "NNS", "NNP", "NNPS", "NP"): return (token, NOUN) i...
[ "def", "penntreebank2universal", "(", "token", ",", "tag", ")", ":", "if", "tag", ".", "startswith", "(", "(", "\"NNP-\"", ",", "\"NNPS-\"", ")", ")", ":", "return", "(", "token", ",", "\"%s-%s\"", "%", "(", "NOUN", ",", "tag", ".", "split", "(", "\"...
Returns a (token, tag)-tuple with a simplified universal part-of-speech tag.
[ "Returns", "a", "(", "token", "tag", ")", "-", "tuple", "with", "a", "simplified", "universal", "part", "-", "of", "-", "speech", "tag", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L891-L920
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_tokens
def find_tokens(string, punctuation=PUNCTUATION, abbreviations=ABBREVIATIONS, replace=replacements, linebreak=r"\n{2,}"): """ Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split...
python
def find_tokens(string, punctuation=PUNCTUATION, abbreviations=ABBREVIATIONS, replace=replacements, linebreak=r"\n{2,}"): """ Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split...
[ "def", "find_tokens", "(", "string", ",", "punctuation", "=", "PUNCTUATION", ",", "abbreviations", "=", "ABBREVIATIONS", ",", "replace", "=", "replacements", ",", "linebreak", "=", "r\"\\n{2,}\"", ")", ":", "# Handle periods separately.", "punctuation", "=", "tuple"...
Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence. Headings without an ending period are inferred by line brea...
[ "Returns", "a", "list", "of", "sentences", ".", "Each", "sentence", "is", "a", "space", "-", "separated", "string", "of", "tokens", "(", "words", ")", ".", "Handles", "common", "cases", "of", "abbreviations", "(", "e", ".", "g", ".", "etc", ".", "...",...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L976-L1046
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_suffix_rules
def _suffix_rules(token, tag="NN"): """ Default morphological tagging rules for English, based on word suffixes. """ if isinstance(token, (list, tuple)): token, tag = token if token.endswith("ing"): tag = "VBG" if token.endswith("ly"): tag = "RB" if token.endswith("s") an...
python
def _suffix_rules(token, tag="NN"): """ Default morphological tagging rules for English, based on word suffixes. """ if isinstance(token, (list, tuple)): token, tag = token if token.endswith("ing"): tag = "VBG" if token.endswith("ly"): tag = "RB" if token.endswith("s") an...
[ "def", "_suffix_rules", "(", "token", ",", "tag", "=", "\"NN\"", ")", ":", "if", "isinstance", "(", "token", ",", "(", "list", ",", "tuple", ")", ")", ":", "token", ",", "tag", "=", "token", "if", "token", ".", "endswith", "(", "\"ing\"", ")", ":",...
Default morphological tagging rules for English, based on word suffixes.
[ "Default", "morphological", "tagging", "rules", "for", "English", "based", "on", "word", "suffixes", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1053-L1070
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_tags
def find_tags(tokens, lexicon={}, model=None, morphology=None, context=None, entities=None, default=("NN", "NNP", "CD"), language="en", map=None, **kwargs): """ Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] ...
python
def find_tags(tokens, lexicon={}, model=None, morphology=None, context=None, entities=None, default=("NN", "NNP", "CD"), language="en", map=None, **kwargs): """ Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] ...
[ "def", "find_tags", "(", "tokens", ",", "lexicon", "=", "{", "}", ",", "model", "=", "None", ",", "morphology", "=", "None", ",", "context", "=", "None", ",", "entities", "=", "None", ",", "default", "=", "(", "\"NN\"", ",", "\"NNP\"", ",", "\"CD\"",...
Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] Words are tagged using the given lexicon of (word, tag)-items. Unknown words are tagged NN by default. Unknown words that start with a capital lette...
[ "Returns", "a", "list", "of", "[", "token", "tag", "]", "-", "items", "for", "the", "given", "list", "of", "tokens", ":", "[", "The", "cat", "purs", "]", "=", ">", "[[", "The", "DT", "]", "[", "cat", "NN", "]", "[", "purs", "VB", "]]", "Words",...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1072-L1123
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_chunks
def find_chunks(tagged, language="en"): """ The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O """ chunked = [x for x in tagg...
python
def find_chunks(tagged, language="en"): """ The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O """ chunked = [x for x in tagg...
[ "def", "find_chunks", "(", "tagged", ",", "language", "=", "\"en\"", ")", ":", "chunked", "=", "[", "x", "for", "x", "in", "tagged", "]", "tags", "=", "\"\"", ".", "join", "(", "\"%s%s\"", "%", "(", "tag", ",", "SEPARATOR", ")", "for", "token", ","...
The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ":", "The", "/", "DT", "nice", "/", "JJ", "fish", "/", "NN", "is", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1171-L1216
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_prepositions
def find_prepositions(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk. """ # Tokens that are not part of a preposition just get the O-tag. for ch in chunked...
python
def find_prepositions(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk. """ # Tokens that are not part of a preposition just get the O-tag. for ch in chunked...
[ "def", "find_prepositions", "(", "chunked", ")", ":", "# Tokens that are not part of a preposition just get the O-tag.", "for", "ch", "in", "chunked", ":", "ch", ".", "append", "(", "\"O\"", ")", "for", "i", ",", "chunk", "in", "enumerate", "(", "chunked", ")", ...
The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk.
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "preposition", "]", "-", "items", ".", "PP", "-", "chunks", "followed", "by", "NP...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1218-L1242
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_relations
def find_relations(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object. "...
python
def find_relations(chunked): """ The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object. "...
[ "def", "find_relations", "(", "chunked", ")", ":", "tag", "=", "lambda", "token", ":", "token", "[", "2", "]", ".", "split", "(", "\"-\"", ")", "[", "-", "1", "]", "# B-NP => NP", "# Group successive tokens with the same chunk-tag.", "chunks", "=", "[", "]",...
The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, relation]-items. A noun phrase preceding a verb phrase is perceived as sentence subject. A noun phrase following a verb phrase is perceived as sentence object.
[ "The", "input", "is", "a", "list", "of", "[", "token", "tag", "chunk", "]", "-", "items", ".", "The", "output", "is", "a", "list", "of", "[", "token", "tag", "chunk", "relation", "]", "-", "items", ".", "A", "noun", "phrase", "preceding", "a", "ver...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1250-L1296
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
find_keywords
def find_keywords(string, parser, top=10, frequency={}, **kwargs): """ Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequenc...
python
def find_keywords(string, parser, top=10, frequency={}, **kwargs): """ Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequenc...
[ "def", "find_keywords", "(", "string", ",", "parser", ",", "top", "=", "10", ",", "frequency", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "lemmata", "=", "kwargs", ".", "pop", "(", "\"lemmata\"", ",", "kwargs", ".", "pop", "(", "\"stem\"", "...
Returns a sorted list of keywords in the given string. The given parser (e.g., pattern.en.parser) is used to identify noun phrases. The given frequency dictionary can be a reference corpus, with relative document frequency (df, 0.0-1.0) for each lemma, e.g., {"the": 0.8, "cat": 0.1, ......
[ "Returns", "a", "sorted", "list", "of", "keywords", "in", "the", "given", "string", ".", "The", "given", "parser", "(", "e", ".", "g", ".", "pattern", ".", "en", ".", "parser", ")", "is", "used", "to", "identify", "noun", "phrases", ".", "The", "give...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1300-L1366
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
tense_id
def tense_id(*args, **kwargs): """ Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated. """ # Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)): if len(args) == 1 and isinstance(args[0], (list,...
python
def tense_id(*args, **kwargs): """ Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated. """ # Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)): if len(args) == 1 and isinstance(args[0], (list,...
[ "def", "tense_id", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Unpack tense given as a tuple, e.g., tense((PRESENT, 1, SG)):", "if", "len", "(", "args", ")", "==", "1", "and", "isinstance", "(", "args", "[", "0", "]", ",", "(", "list", ",", "tu...
Returns the tense id for a given (tense, person, number, mood, aspect, negated). Aliases and compound forms (e.g., IMPERFECT) are disambiguated.
[ "Returns", "the", "tense", "id", "for", "a", "given", "(", "tense", "person", "number", "mood", "aspect", "negated", ")", ".", "Aliases", "and", "compound", "forms", "(", "e", ".", "g", ".", "IMPERFECT", ")", "are", "disambiguated", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1594-L1641
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
_multilingual
def _multilingual(function, *args, **kwargs): """ Returns the value from the function with the given name in the given language module. By default, language="en". """ return getattr(_module(kwargs.pop("language", "en")), function)(*args, **kwargs)
python
def _multilingual(function, *args, **kwargs): """ Returns the value from the function with the given name in the given language module. By default, language="en". """ return getattr(_module(kwargs.pop("language", "en")), function)(*args, **kwargs)
[ "def", "_multilingual", "(", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "_module", "(", "kwargs", ".", "pop", "(", "\"language\"", ",", "\"en\"", ")", ")", ",", "function", ")", "(", "*", "args", ",", ...
Returns the value from the function with the given name in the given language module. By default, language="en".
[ "Returns", "the", "value", "from", "the", "function", "with", "the", "given", "name", "in", "the", "given", "language", "module", ".", "By", "default", "language", "=", "en", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2188-L2192
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
language
def language(s): """ Returns a (language, confidence)-tuple for the given string. """ s = decode_utf8(s) s = set(w.strip(PUNCTUATION) for w in s.replace("'", "' ").split()) n = float(len(s) or 1) p = {} for xx in LANGUAGES: lexicon = _module(xx).__dict__["lexicon"] p[xx] = su...
python
def language(s): """ Returns a (language, confidence)-tuple for the given string. """ s = decode_utf8(s) s = set(w.strip(PUNCTUATION) for w in s.replace("'", "' ").split()) n = float(len(s) or 1) p = {} for xx in LANGUAGES: lexicon = _module(xx).__dict__["lexicon"] p[xx] = su...
[ "def", "language", "(", "s", ")", ":", "s", "=", "decode_utf8", "(", "s", ")", "s", "=", "set", "(", "w", ".", "strip", "(", "PUNCTUATION", ")", "for", "w", "in", "s", ".", "replace", "(", "\"'\"", ",", "\"' \"", ")", ".", "split", "(", ")", ...
Returns a (language, confidence)-tuple for the given string.
[ "Returns", "a", "(", "language", "confidence", ")", "-", "tuple", "for", "the", "given", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2194-L2204
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
lazylist._lazy
def _lazy(self, method, *args): """ If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it. """ if list.__len__(self) == 0: self.load() setattr(self, method, types.MethodType(getattr(list, method), self)) ...
python
def _lazy(self, method, *args): """ If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it. """ if list.__len__(self) == 0: self.load() setattr(self, method, types.MethodType(getattr(list, method), self)) ...
[ "def", "_lazy", "(", "self", ",", "method", ",", "*", "args", ")", ":", "if", "list", ".", "__len__", "(", "self", ")", "==", "0", ":", "self", ".", "load", "(", ")", "setattr", "(", "self", ",", "method", ",", "types", ".", "MethodType", "(", ...
If the list is empty, calls lazylist.load(). Replaces lazylist.method() with list.method() and calls it.
[ "If", "the", "list", "is", "empty", "calls", "lazylist", ".", "load", "()", ".", "Replaces", "lazylist", ".", "method", "()", "with", "list", ".", "method", "()", "and", "calls", "it", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L179-L186
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.train
def train(self, token, tag, previous=None, next=None): """ Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples. """ self._classifier.train(self._v(token, previous, next), type=tag)
python
def train(self, token, tag, previous=None, next=None): """ Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples. """ self._classifier.train(self._v(token, previous, next), type=tag)
[ "def", "train", "(", "self", ",", "token", ",", "tag", ",", "previous", "=", "None", ",", "next", "=", "None", ")", ":", "self", ".", "_classifier", ".", "train", "(", "self", ".", "_v", "(", "token", ",", "previous", ",", "next", ")", ",", "type...
Trains the model to predict the given tag for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Trains", "the", "model", "to", "predict", "the", "given", "tag", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L323-L327
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.classify
def classify(self, token, previous=None, next=None, **kwargs): """ Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples. """ return self._classifier.classify(self._v(token, previous, next), **kwargs)
python
def classify(self, token, previous=None, next=None, **kwargs): """ Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples. """ return self._classifier.classify(self._v(token, previous, next), **kwargs)
[ "def", "classify", "(", "self", ",", "token", ",", "previous", "=", "None", ",", "next", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_classifier", ".", "classify", "(", "self", ".", "_v", "(", "token", ",", "previous", "...
Returns the predicted tag for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Returns", "the", "predicted", "tag", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L329-L333
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model.apply
def apply(self, token, previous=(None, None), next=(None, None)): """ Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples. """ return [token[0], self._classifier.classify(self._v(token[0], previous, next))]
python
def apply(self, token, previous=(None, None), next=(None, None)): """ Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples. """ return [token[0], self._classifier.classify(self._v(token[0], previous, next))]
[ "def", "apply", "(", "self", ",", "token", ",", "previous", "=", "(", "None", ",", "None", ")", ",", "next", "=", "(", "None", ",", "None", ")", ")", ":", "return", "[", "token", "[", "0", "]", ",", "self", ".", "_classifier", ".", "classify", ...
Returns a (token, tag)-tuple for the given token, in context of the given previous and next (token, tag)-tuples.
[ "Returns", "a", "(", "token", "tag", ")", "-", "tuple", "for", "the", "given", "token", "in", "context", "of", "the", "given", "previous", "and", "next", "(", "token", "tag", ")", "-", "tuples", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L335-L339
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Model._v
def _v(self, token, previous=None, next=None): """ Returns a training vector for the given (word, tag)-tuple and its context. """ def f(v, s1, s2): if s2: v[s1 + " " + s2] = 1 p, n = previous, next p = ("", "") if not p else (p[0] or "", p[1] or "") ...
python
def _v(self, token, previous=None, next=None): """ Returns a training vector for the given (word, tag)-tuple and its context. """ def f(v, s1, s2): if s2: v[s1 + " " + s2] = 1 p, n = previous, next p = ("", "") if not p else (p[0] or "", p[1] or "") ...
[ "def", "_v", "(", "self", ",", "token", ",", "previous", "=", "None", ",", "next", "=", "None", ")", ":", "def", "f", "(", "v", ",", "s1", ",", "s2", ")", ":", "if", "s2", ":", "v", "[", "s1", "+", "\" \"", "+", "s2", "]", "=", "1", "p", ...
Returns a training vector for the given (word, tag)-tuple and its context.
[ "Returns", "a", "training", "vector", "for", "the", "given", "(", "word", "tag", ")", "-", "tuple", "and", "its", "context", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L341-L360
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Morphology.apply
def apply(self, token, previous=(None, None), next=(None, None)): """ Applies lexical rules to the given token, which is a [word, tag] list. """ w = token[0] for r in self: if r[1] in self._cmd: # Rule = ly hassuf 2 RB x f, x, pos, cmd = bool(0), r[0], r[-2], ...
python
def apply(self, token, previous=(None, None), next=(None, None)): """ Applies lexical rules to the given token, which is a [word, tag] list. """ w = token[0] for r in self: if r[1] in self._cmd: # Rule = ly hassuf 2 RB x f, x, pos, cmd = bool(0), r[0], r[-2], ...
[ "def", "apply", "(", "self", ",", "token", ",", "previous", "=", "(", "None", ",", "None", ")", ",", "next", "=", "(", "None", ",", "None", ")", ")", ":", "w", "=", "token", "[", "0", "]", "for", "r", "in", "self", ":", "if", "r", "[", "1",...
Applies lexical rules to the given token, which is a [word, tag] list.
[ "Applies", "lexical", "rules", "to", "the", "given", "token", "which", "is", "a", "[", "word", "tag", "]", "list", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L403-L425
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Morphology.insert
def insert(self, i, tag, affix, cmd="hassuf", tagged=None): """ Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly"). """ if affix.startswith("-") and affix.endswith("-"): affix, cmd = affix[+1:-1], "char" ...
python
def insert(self, i, tag, affix, cmd="hassuf", tagged=None): """ Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly"). """ if affix.startswith("-") and affix.endswith("-"): affix, cmd = affix[+1:-1], "char" ...
[ "def", "insert", "(", "self", ",", "i", ",", "tag", ",", "affix", ",", "cmd", "=", "\"hassuf\"", ",", "tagged", "=", "None", ")", ":", "if", "affix", ".", "startswith", "(", "\"-\"", ")", "and", "affix", ".", "endswith", "(", "\"-\"", ")", ":", "...
Inserts a new rule that assigns the given tag to words with the given affix, e.g., Morphology.append("RB", "-ly").
[ "Inserts", "a", "new", "rule", "that", "assigns", "the", "given", "tag", "to", "words", "with", "the", "given", "affix", "e", ".", "g", ".", "Morphology", ".", "append", "(", "RB", "-", "ly", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L427-L441
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Context.apply
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 ...
python
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", ")", ":", "o", "=", "[", "(", "\"STAART\"", ",", "\"STAART\"", ")", "]", "*", "3", "# Empty delimiters for look ahead/back.", "t", "=", "o", "+", "tokens", "+", "o", "for", "i", ",", "token", "in", "enumerate...
Applies contextual rules to the given list of tokens, where each token is a [word, tag] list.
[ "Applies", "contextual", "rules", "to", "the", "given", "list", "of", "tokens", "where", "each", "token", "is", "a", "[", "word", "tag", "]", "list", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L498-L538
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Context.insert
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...
python
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", ")", ":", "if", "\" < \"", "in", "tag1", "and", "not", "x", "and", "not", "y", ":", "tag1", ",", "...
Inserts a new rule that updates words with tag1 to tag2, given constraints x and y, e.g., Context.append("TO < NN", "VB")
[ "Inserts", "a", "new", "rule", "that", "updates", "words", "with", "tag1", "to", "tag2", "given", "constraints", "x", "and", "y", "e", ".", "g", ".", "Context", ".", "append", "(", "TO", "<", "NN", "VB", ")" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L540-L548
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Entities.apply
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): ...
python
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", ")", ":", "# 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"...
Applies the named entity recognizer to the given list of tokens, where each token is a [word, tag] list.
[ "Applies", "the", "named", "entity", "recognizer", "to", "the", "given", "list", "of", "tokens", "where", "each", "token", "is", "a", "[", "word", "tag", "]", "list", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L588-L616
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Entities.append
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)
python
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\"", ")", ":", "e", "=", "map", "(", "lambda", "s", ":", "s", ".", "lower", "(", ")", ",", "entity", ".", "split", "(", "\" \"", ")", "+", "[", "name", "]", ")", "self", "....
Appends a named entity to the lexicon, e.g., Entities.append("Hooloovoo", "PERS")
[ "Appends", "a", "named", "entity", "to", "the", "lexicon", "e", ".", "g", ".", "Entities", ".", "append", "(", "Hooloovoo", "PERS", ")" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L618-L623
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Parser.find_keywords
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 ...
python
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", ")", ":", "return", "find_keywords", "(", "string", ",", "parser", "=", "self", ",", "top", "=", "kwargs", ".", "pop", "(", "\"top\"", ",", "10", ")", ",", "frequency", "=",...
Returns a sorted list of keywords in the given string.
[ "Returns", "a", "sorted", "list", "of", "keywords", "in", "the", "given", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L710-L717
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Parser.find_tokens
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...
python
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", ")", ":", "# \"The cat purs.\" => [\"The cat purs .\"]", "return", "find_tokens", "(", "string", ",", "punctuation", "=", "kwargs", ".", "get", "(", "\"punctuation\"", ",", "PUNCTUATION", ...
Returns a list of sentences from the given string. Punctuation marks are separated from each word by a space.
[ "Returns", "a", "list", "of", "sentences", "from", "the", "given", "string", ".", "Punctuation", "marks", "are", "separated", "from", "each", "word", "by", "a", "space", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L719-L728
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Parser.find_tags
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...
python
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", ")", ":", "# [\"The\", \"cat\", \"purs\"] => [[\"The\", \"DT\"], [\"cat\", \"NN\"], [\"purs\", \"VB\"]]", "return", "find_tags", "(", "tokens", ",", "lexicon", "=", "kwargs", ".", "get", "(", "\"...
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.
[ "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", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L730-L743
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Parser.find_chunks
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", ...
python
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", ")", ":", "# [[\"The\", \"DT\"], [\"cat\", \"NN\"], [\"purs\", \"VB\"]] =>", "# [[\"The\", \"DT\", \"B-NP\"], [\"cat\", \"NN\", \"I-NP\"], [\"purs\", \"VB\", \"B-VP\"]]", "return", "find_prepositions", "(", ...
Annotates the given list of tokens with chunk tags. Several tags can be added, for example chunk + preposition tags.
[ "Annotates", "the", "given", "list", "of", "tokens", "with", "chunk", "tags", ".", "Several", "tags", "can", "be", "added", "for", "example", "chunk", "+", "preposition", "tags", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L745-L753
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Parser.parse
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 ...
python
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 split from words and sentences are separated by \n. With tags=True, part-of-speech tags are parsed (NN, VB, IN, ...). ...
[ "Takes", "a", "string", "(", "sentences", ")", "and", "returns", "a", "tagged", "Unicode", "string", "(", "TaggedString", ")", ".", "Sentences", "in", "the", "output", "are", "separated", "by", "newlines", ".", "With", "tokenize", "=", "True", "punctuation",...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L770-L834
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
TaggedString.split
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...
python
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", ")", ":", "if", "sep", "!=", "TOKENS", ":", "return", "unicode", ".", "split", "(", "self", ",", "sep", ")", "if", "len", "(", "self", ")", "==", "0", ":", "return", "[", "]", "return", "[...
Returns a list of sentences, where each sentence is a list of tokens, where each token is a list of word + tags.
[ "Returns", "a", "list", "of", "sentences", "where", "each", "sentence", "is", "a", "list", "of", "tokens", "where", "each", "token", "is", "a", "list", "of", "word", "+", "tags", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L861-L871
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Verbs.TENSES
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...
python
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", ")", ":", "a", "=", "set", "(", "TENSES", "[", "id", "]", "for", "id", "in", "self", ".", "_format", ")", "a", "=", "a", ".", "union", "(", "set", "(", "TENSES", "[", "id", "]", "for", "id", "in", "self", ".", ...
Yields a list of tenses for this language, excluding negations. Each tense is a (tense, person, number, mood, aspect)-tuple.
[ "Yields", "a", "list", "of", "tenses", "for", "this", "language", "excluding", "negations", ".", "Each", "tense", "is", "a", "(", "tense", "person", "number", "mood", "aspect", ")", "-", "tuple", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1699-L1707
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Verbs.lemma
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...
python
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", ")", ":", "if", "dict", ".", "__len__", "(", "self", ")", "==", "0", ":", "self", ".", "load", "(", ")", "if", "verb", ".", "lower", "(", ")", "in", "self", ".", "_inverse", ...
Returns the infinitive form of the given verb, or None.
[ "Returns", "the", "infinitive", "form", "of", "the", "given", "verb", "or", "None", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1709-L1719
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Verbs.lexeme
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...
python
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", ")", ":", "a", "=", "[", "]", "b", "=", "self", ".", "lemma", "(", "verb", ",", "parse", "=", "parse", ")", "if", "b", "in", "self", ":", "a", "=", "[", "x", "for", "x", ...
Returns a list of all possible inflections of the given verb.
[ "Returns", "a", "list", "of", "all", "possible", "inflections", "of", "the", "given", "verb", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1721-L1731
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Verbs.conjugate
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...
python
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", ")", ":", "id", "=", "tense_id", "(", "*", "args", ",", "*", "*", "kwargs", ")", "# Get the tense index from the format description (or a default).", "i1", "=", "self", ...
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...
[ "Inflects", "the", "verb", "and", "returns", "the", "given", "tense", "(", "or", "None", ")", ".", "For", "example", ":", "be", "-", "Verbs", ".", "conjugate", "(", "is", "INFINITVE", ")", "=", ">", "be", "-", "Verbs", ".", "conjugate", "(", "be", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1733-L1760
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Verbs.tenses
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 ...
python
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", ")", ":", "verb", "=", "verb", ".", "lower", "(", ")", "a", "=", "set", "(", ")", "b", "=", "self", ".", "lemma", "(", "verb", ",", "parse", "=", "parse", ")", "v", "=", ...
Returns a list of possible tenses for the given inflected verb.
[ "Returns", "a", "list", "of", "possible", "tenses", "for", "the", "given", "inflected", "verb", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1762-L1789
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Sentiment.load
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...
python
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", ")", ":", "# <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", ...
Loads the XML-file (with sentiment annotations) from the given path. By default, Sentiment.path is lazily loaded.
[ "Loads", "the", "XML", "-", "file", "(", "with", "sentiment", "annotations", ")", "from", "the", "given", "path", ".", "By", "default", "Sentiment", ".", "path", "is", "lazily", "loaded", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1878-L1922
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Sentiment.synset
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...
python
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", ")", ":", "id", "=", "str", "(", "id", ")", ".", "zfill", "(", "8", ")", "if", "not", "id", ".", "startswith", "(", "(", "\"n-\"", ",", "\"v-\"", ",", "\"a-\"", ",", "\"r-\"...
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).
[ "Returns", "a", "(", "polarity", "subjectivity", ")", "-", "tuple", "for", "the", "given", "synset", "id", ".", "For", "example", "the", "adjective", "horrible", "has", "id", "193480", "in", "WordNet", ":", "Sentiment", ".", "synset", "(", "193480", "pos",...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L1924-L1944
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Sentiment.assessments
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"). """...
python
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", ")", ":", "a", "=", "[", "]", "m", "=", "None", "# Preceding modifier (i.e., adverb or adjective).", "n", "=", "None", "# Preceding negation (e.g., \"not beautiful\").", ...
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...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2004-L2078
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Sentiment.annotate
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, {})...
python
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", ")", ":", "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 "(!)").
[ "Annotates", "the", "given", "word", "with", "polarity", "subjectivity", "and", "intensity", "scores", "and", "optionally", "a", "semantic", "label", "(", "e", ".", "g", ".", "MOOD", "for", "emoticons", "IRONY", "for", "(", "!", ")", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2080-L2087
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Spelling.train
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...
python
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\"", ")", ":", "model", "=", "{", "}", "for", "w", "in", "re", ".", "findall", "(", "\"[a-z]+\"", ",", "s", ".", "lower", "(", ")", ")", ":", "model", "[", "w", "]", "=", ...
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.
[ "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", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2113-L2124
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Spelling._edit1
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)]...
python
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", ")", ":", "# 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", ":", "]"...
Returns a set of words with edit distance 1 from the given word.
[ "Returns", "a", "set", "of", "words", "with", "edit", "distance", "1", "from", "the", "given", "word", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2126-L2138
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Spelling._edit2
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...
python
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", ")", ":", "# 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", ")", ...
Returns a set of words with edit distance 2 from the given word
[ "Returns", "a", "set", "of", "words", "with", "edit", "distance", "2", "from", "the", "given", "word" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2140-L2145
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
Spelling.suggest
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....
python
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", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "self", ".", "load", "(", ")", "if", "len", "(", "w", ")", "==", "1", ":", "return", "[", "(", "w", ",", "1.0", ")", "]", "# I", "if", "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.
[ "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", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2152-L2172
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
zip
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...
python
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", ")", ":", "args", "=", "[", "list", "(", "iterable", ")", "for", "iterable", "in", "args", "]", "n", "=", "max", "(", "map", "(", "len", ",", "args", ")", ")", "v", "=", "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).
[ "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", ")", "."...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L89-L96
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
chunked
def chunked(sentence): """ Returns a list of Chunk and Chink objects from the given sentence. Chink is a subclass of Chunk used for words that have Word.chunk == None (e.g., punctuation marks, conjunctions). """ # For example, to construct a training vector with the head of previous chunks a...
python
def chunked(sentence): """ Returns a list of Chunk and Chink objects from the given sentence. Chink is a subclass of Chunk used for words that have Word.chunk == None (e.g., punctuation marks, conjunctions). """ # For example, to construct a training vector with the head of previous chunks a...
[ "def", "chunked", "(", "sentence", ")", ":", "# For example, to construct a training vector with the head of previous chunks as a feature.", "# Doing this with Sentence.chunks would discard the punctuation marks and conjunctions", "# (Sentence.chunks only yields Chunk objects), which amy be useful f...
Returns a list of Chunk and Chink objects from the given sentence. Chink is a subclass of Chunk used for words that have Word.chunk == None (e.g., punctuation marks, conjunctions).
[ "Returns", "a", "list", "of", "Chunk", "and", "Chink", "objects", "from", "the", "given", "sentence", ".", "Chink", "is", "a", "subclass", "of", "Chunk", "used", "for", "words", "that", "have", "Word", ".", "chunk", "==", "None", "(", "e", ".", "g", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1100-L1117
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
tree
def tree(string, token=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string. """ return Text(string, token)
python
def tree(string, token=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string. """ return Text(string, token)
[ "def", "tree", "(", "string", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "return", "Text", "(", "string", ",", "token", ")" ]
Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string.
[ "Transforms", "the", "output", "of", "parse", "()", "into", "a", "Text", "object", ".", "The", "token", "parameter", "lists", "the", "order", "of", "tags", "in", "each", "token", "in", "the", "input", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1207-L1211
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
xml_encode
def xml_encode(string): """ Returns the string with XML-safe special characters. """ string = string.replace("&", "&amp;") string = string.replace("<", "&lt;") string = string.replace(">", "&gt;") string = string.replace("\"","&quot;") string = string.replace(SLASH, "/") return string
python
def xml_encode(string): """ Returns the string with XML-safe special characters. """ string = string.replace("&", "&amp;") string = string.replace("<", "&lt;") string = string.replace(">", "&gt;") string = string.replace("\"","&quot;") string = string.replace(SLASH, "/") return string
[ "def", "xml_encode", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "\"&\"", ",", "\"&amp;\"", ")", "string", "=", "string", ".", "replace", "(", "\"<\"", ",", "\"&lt;\"", ")", "string", "=", "string", ".", "replace", "(", "\">\...
Returns the string with XML-safe special characters.
[ "Returns", "the", "string", "with", "XML", "-", "safe", "special", "characters", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1253-L1261
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
xml_decode
def xml_decode(string): """ Returns the string with special characters decoded. """ string = string.replace("&amp;", "&") string = string.replace("&lt;", "<") string = string.replace("&gt;", ">") string = string.replace("&quot;","\"") string = string.replace("/", SLASH) return string
python
def xml_decode(string): """ Returns the string with special characters decoded. """ string = string.replace("&amp;", "&") string = string.replace("&lt;", "<") string = string.replace("&gt;", ">") string = string.replace("&quot;","\"") string = string.replace("/", SLASH) return string
[ "def", "xml_decode", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "\"&amp;\"", ",", "\"&\"", ")", "string", "=", "string", ".", "replace", "(", "\"&lt;\"", ",", "\"<\"", ")", "string", "=", "string", ".", "replace", "(", "\"&g...
Returns the string with special characters decoded.
[ "Returns", "the", "string", "with", "special", "characters", "decoded", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1263-L1271
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
parse_xml
def parse_xml(sentence, tab="\t", id=""): """ Returns the given Sentence object as an XML-string (plain bytestring, UTF-8 encoded). The tab delimiter is used as indendation for nested elements. The id can be used as a unique identifier per sentence for chunk id's and anchors. For example: "I...
python
def parse_xml(sentence, tab="\t", id=""): """ Returns the given Sentence object as an XML-string (plain bytestring, UTF-8 encoded). The tab delimiter is used as indendation for nested elements. The id can be used as a unique identifier per sentence for chunk id's and anchors. For example: "I...
[ "def", "parse_xml", "(", "sentence", ",", "tab", "=", "\"\\t\"", ",", "id", "=", "\"\"", ")", ":", "uid", "=", "lambda", "*", "parts", ":", "\"\"", ".", "join", "(", "[", "str", "(", "id", ")", ",", "_UID_SEPARATOR", "]", "+", "[", "str", "(", ...
Returns the given Sentence object as an XML-string (plain bytestring, UTF-8 encoded). The tab delimiter is used as indendation for nested elements. The id can be used as a unique identifier per sentence for chunk id's and anchors. For example: "I eat pizza with a fork." => <sent...
[ "Returns", "the", "given", "Sentence", "object", "as", "an", "XML", "-", "string", "(", "plain", "bytestring", "UTF", "-", "8", "encoded", ")", ".", "The", "tab", "delimiter", "is", "used", "as", "indendation", "for", "nested", "elements", ".", "The", "i...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1279-L1384
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
parse_string
def parse_string(xml): """ Returns a slash-formatted string from the given XML representation. The return value is a TokenString (for MBSP) or TaggedString (for Pattern). """ string = "" # Traverse all the <sentence> elements in the XML. dom = XML(xml) for sentence in dom(XML_SENTENCE): ...
python
def parse_string(xml): """ Returns a slash-formatted string from the given XML representation. The return value is a TokenString (for MBSP) or TaggedString (for Pattern). """ string = "" # Traverse all the <sentence> elements in the XML. dom = XML(xml) for sentence in dom(XML_SENTENCE): ...
[ "def", "parse_string", "(", "xml", ")", ":", "string", "=", "\"\"", "# Traverse all the <sentence> elements in the XML.", "dom", "=", "XML", "(", "xml", ")", "for", "sentence", "in", "dom", "(", "XML_SENTENCE", ")", ":", "_anchors", ".", "clear", "(", ")", "...
Returns a slash-formatted string from the given XML representation. The return value is a TokenString (for MBSP) or TaggedString (for Pattern).
[ "Returns", "a", "slash", "-", "formatted", "string", "from", "the", "given", "XML", "representation", ".", "The", "return", "value", "is", "a", "TokenString", "(", "for", "MBSP", ")", "or", "TaggedString", "(", "for", "Pattern", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1440-L1487
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
_parse_tokens
def _parse_tokens(chunk, format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Parses tokens from <word> elements in the given XML <chunk> element. Returns a flat list of tokens, in which each token is [WORD, POS, CHUNK, PNP, RELATION, ANCHOR, LEMMA]. If a <chunk type="PNP"> is encountered, trave...
python
def _parse_tokens(chunk, format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Parses tokens from <word> elements in the given XML <chunk> element. Returns a flat list of tokens, in which each token is [WORD, POS, CHUNK, PNP, RELATION, ANCHOR, LEMMA]. If a <chunk type="PNP"> is encountered, trave...
[ "def", "_parse_tokens", "(", "chunk", ",", "format", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "tokens", "=", "[", "]", "# Only process <chunk> and <chink> elements, ", "# text nodes in be...
Parses tokens from <word> elements in the given XML <chunk> element. Returns a flat list of tokens, in which each token is [WORD, POS, CHUNK, PNP, RELATION, ANCHOR, LEMMA]. If a <chunk type="PNP"> is encountered, traverses all of the chunks in the PNP.
[ "Parses", "tokens", "from", "<word", ">", "elements", "in", "the", "given", "XML", "<chunk", ">", "element", ".", "Returns", "a", "flat", "list", "of", "tokens", "in", "which", "each", "token", "is", "[", "WORD", "POS", "CHUNK", "PNP", "RELATION", "ANCHO...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1489-L1534
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
_parse_relation
def _parse_relation(chunk, type="O"): """ Returns a string of the roles and relations parsed from the given <chunk> element. The chunk type (which is part of the relation string) can be given as parameter. """ r1 = chunk.get(XML_RELATION) r2 = chunk.get(XML_ID, chunk.get(XML_OF)) r1 = [x != ...
python
def _parse_relation(chunk, type="O"): """ Returns a string of the roles and relations parsed from the given <chunk> element. The chunk type (which is part of the relation string) can be given as parameter. """ r1 = chunk.get(XML_RELATION) r2 = chunk.get(XML_ID, chunk.get(XML_OF)) r1 = [x != ...
[ "def", "_parse_relation", "(", "chunk", ",", "type", "=", "\"O\"", ")", ":", "r1", "=", "chunk", ".", "get", "(", "XML_RELATION", ")", "r2", "=", "chunk", ".", "get", "(", "XML_ID", ",", "chunk", ".", "get", "(", "XML_OF", ")", ")", "r1", "=", "[...
Returns a string of the roles and relations parsed from the given <chunk> element. The chunk type (which is part of the relation string) can be given as parameter.
[ "Returns", "a", "string", "of", "the", "roles", "and", "relations", "parsed", "from", "the", "given", "<chunk", ">", "element", ".", "The", "chunk", "type", "(", "which", "is", "part", "of", "the", "relation", "string", ")", "can", "be", "given", "as", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1536-L1547
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
_parse_token
def _parse_token(word, chunk="O", pnp="O", relation="O", anchor="O", format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Returns a list of token tags parsed from the given <word> element. Tags that are not attributes in a <word> (e.g., relation) can be given as parameters. """ ...
python
def _parse_token(word, chunk="O", pnp="O", relation="O", anchor="O", format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Returns a list of token tags parsed from the given <word> element. Tags that are not attributes in a <word> (e.g., relation) can be given as parameters. """ ...
[ "def", "_parse_token", "(", "word", ",", "chunk", "=", "\"O\"", ",", "pnp", "=", "\"O\"", ",", "relation", "=", "\"O\"", ",", "anchor", "=", "\"O\"", ",", "format", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ...
Returns a list of token tags parsed from the given <word> element. Tags that are not attributes in a <word> (e.g., relation) can be given as parameters.
[ "Returns", "a", "list", "of", "token", "tags", "parsed", "from", "the", "given", "<word", ">", "element", ".", "Tags", "that", "are", "not", "attributes", "in", "a", "<word", ">", "(", "e", ".", "g", ".", "relation", ")", "can", "be", "given", "as", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1549-L1566
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
nltk_tree
def nltk_tree(sentence): """ Returns an NLTK nltk.tree.Tree object from the given Sentence. The NLTK module should be on the search path somewhere. """ from nltk import tree def do_pnp(pnp): # Returns the PNPChunk (and the contained Chunk objects) in NLTK bracket format. s = ' '....
python
def nltk_tree(sentence): """ Returns an NLTK nltk.tree.Tree object from the given Sentence. The NLTK module should be on the search path somewhere. """ from nltk import tree def do_pnp(pnp): # Returns the PNPChunk (and the contained Chunk objects) in NLTK bracket format. s = ' '....
[ "def", "nltk_tree", "(", "sentence", ")", ":", "from", "nltk", "import", "tree", "def", "do_pnp", "(", "pnp", ")", ":", "# Returns the PNPChunk (and the contained Chunk objects) in NLTK bracket format.", "s", "=", "' '", ".", "join", "(", "[", "do_chunk", "(", "ch...
Returns an NLTK nltk.tree.Tree object from the given Sentence. The NLTK module should be on the search path somewhere.
[ "Returns", "an", "NLTK", "nltk", ".", "tree", ".", "Tree", "object", "from", "the", "given", "Sentence", ".", "The", "NLTK", "module", "should", "be", "on", "the", "search", "path", "somewhere", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1570-L1599
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
graphviz_dot
def graphviz_dot(sentence, font="Arial", colors=BLUE): """ Returns a dot-formatted string that can be visualized as a graph in GraphViz. """ s = 'digraph sentence {\n' s += '\tranksep=0.75;\n' s += '\tnodesep=0.15;\n' s += '\tnode [penwidth=1, fontname="%s", shape=record, margin=0.1, height=0.3...
python
def graphviz_dot(sentence, font="Arial", colors=BLUE): """ Returns a dot-formatted string that can be visualized as a graph in GraphViz. """ s = 'digraph sentence {\n' s += '\tranksep=0.75;\n' s += '\tnodesep=0.15;\n' s += '\tnode [penwidth=1, fontname="%s", shape=record, margin=0.1, height=0.3...
[ "def", "graphviz_dot", "(", "sentence", ",", "font", "=", "\"Arial\"", ",", "colors", "=", "BLUE", ")", ":", "s", "=", "'digraph sentence {\\n'", "s", "+=", "'\\tranksep=0.75;\\n'", "s", "+=", "'\\tnodesep=0.15;\\n'", "s", "+=", "'\\tnode [penwidth=1, fontname=\"%s\...
Returns a dot-formatted string that can be visualized as a graph in GraphViz.
[ "Returns", "a", "dot", "-", "formatted", "string", "that", "can", "be", "visualized", "as", "a", "graph", "in", "GraphViz", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1621-L1672
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
table
def table(sentence, fill=1, placeholder="-"): """ Returns a string where the tags of tokens in the sentence are organized in outlined columns. """ tags = [WORD, POS, IOB, CHUNK, ROLE, REL, PNP, ANCHOR, LEMMA] tags += [tag for tag in sentence.token if tag not in tags] def format(token, tag): ...
python
def table(sentence, fill=1, placeholder="-"): """ Returns a string where the tags of tokens in the sentence are organized in outlined columns. """ tags = [WORD, POS, IOB, CHUNK, ROLE, REL, PNP, ANCHOR, LEMMA] tags += [tag for tag in sentence.token if tag not in tags] def format(token, tag): ...
[ "def", "table", "(", "sentence", ",", "fill", "=", "1", ",", "placeholder", "=", "\"-\"", ")", ":", "tags", "=", "[", "WORD", ",", "POS", ",", "IOB", ",", "CHUNK", ",", "ROLE", ",", "REL", ",", "PNP", ",", "ANCHOR", ",", "LEMMA", "]", "tags", "...
Returns a string where the tags of tokens in the sentence are organized in outlined columns.
[ "Returns", "a", "string", "where", "the", "tags", "of", "tokens", "in", "the", "sentence", "are", "organized", "in", "outlined", "columns", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1676-L1717
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Word.tags
def tags(self): """ Yields a list of all the token tags as they appeared when the word was parsed. For example: ["was", "VBD", "B-VP", "O", "VP-1", "A1", "be"] """ # See also. Sentence.__repr__(). ch, I,O,B = self.chunk, INSIDE+"-", OUTSIDE, BEGIN+"-" tags = [OUTSIDE ...
python
def tags(self): """ Yields a list of all the token tags as they appeared when the word was parsed. For example: ["was", "VBD", "B-VP", "O", "VP-1", "A1", "be"] """ # See also. Sentence.__repr__(). ch, I,O,B = self.chunk, INSIDE+"-", OUTSIDE, BEGIN+"-" tags = [OUTSIDE ...
[ "def", "tags", "(", "self", ")", ":", "# See also. Sentence.__repr__().", "ch", ",", "I", ",", "O", ",", "B", "=", "self", ".", "chunk", ",", "INSIDE", "+", "\"-\"", ",", "OUTSIDE", ",", "BEGIN", "+", "\"-\"", "tags", "=", "[", "OUTSIDE", "for", "i",...
Yields a list of all the token tags as they appeared when the word was parsed. For example: ["was", "VBD", "B-VP", "O", "VP-1", "A1", "be"]
[ "Yields", "a", "list", "of", "all", "the", "token", "tags", "as", "they", "appeared", "when", "the", "word", "was", "parsed", ".", "For", "example", ":", "[", "was", "VBD", "B", "-", "VP", "O", "VP", "-", "1", "A1", "be", "]" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L190-L215
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Word.next
def next(self, type=None): """ Returns the next word in the sentence with the given type. """ i = self.index + 1 s = self.sentence while i < len(s): if type in (s[i].type, None): return s[i] i += 1
python
def next(self, type=None): """ Returns the next word in the sentence with the given type. """ i = self.index + 1 s = self.sentence while i < len(s): if type in (s[i].type, None): return s[i] i += 1
[ "def", "next", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "index", "+", "1", "s", "=", "self", ".", "sentence", "while", "i", "<", "len", "(", "s", ")", ":", "if", "type", "in", "(", "s", "[", "i", "]", ".", "...
Returns the next word in the sentence with the given type.
[ "Returns", "the", "next", "word", "in", "the", "sentence", "with", "the", "given", "type", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L222-L230
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Word.previous
def previous(self, type=None): """ Returns the next previous word in the sentence with the given type. """ i = self.index - 1 s = self.sentence while i > 0: if type in (s[i].type, None): return s[i] i -= 1
python
def previous(self, type=None): """ Returns the next previous word in the sentence with the given type. """ i = self.index - 1 s = self.sentence while i > 0: if type in (s[i].type, None): return s[i] i -= 1
[ "def", "previous", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "index", "-", "1", "s", "=", "self", ".", "sentence", "while", "i", ">", "0", ":", "if", "type", "in", "(", "s", "[", "i", "]", ".", "type", ",", "No...
Returns the next previous word in the sentence with the given type.
[ "Returns", "the", "next", "previous", "word", "in", "the", "sentence", "with", "the", "given", "type", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L232-L240
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.head
def head(self): """ Yields the head of the chunk (usually, the last word in the chunk). """ if self.type == "NP" and any(w.type.startswith("NNP") for w in self): w = find(lambda w: w.type.startswith("NNP"), reversed(self)) elif self.type == "NP": # "the cat" => "cat" ...
python
def head(self): """ Yields the head of the chunk (usually, the last word in the chunk). """ if self.type == "NP" and any(w.type.startswith("NNP") for w in self): w = find(lambda w: w.type.startswith("NNP"), reversed(self)) elif self.type == "NP": # "the cat" => "cat" ...
[ "def", "head", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\"NP\"", "and", "any", "(", "w", ".", "type", ".", "startswith", "(", "\"NNP\"", ")", "for", "w", "in", "self", ")", ":", "w", "=", "find", "(", "lambda", "w", ":", "w", ...
Yields the head of the chunk (usually, the last word in the chunk).
[ "Yields", "the", "head", "of", "the", "chunk", "(", "usually", "the", "last", "word", "in", "the", "chunk", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L365-L382
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.related
def related(self): """ Yields a list of all chunks in the sentence with the same relation id. """ return [ch for ch in self.sentence.chunks if ch != self and intersects(unzip(0, ch.relations), unzip(0, self.relations))]
python
def related(self): """ Yields a list of all chunks in the sentence with the same relation id. """ return [ch for ch in self.sentence.chunks if ch != self and intersects(unzip(0, ch.relations), unzip(0, self.relations))]
[ "def", "related", "(", "self", ")", ":", "return", "[", "ch", "for", "ch", "in", "self", ".", "sentence", ".", "chunks", "if", "ch", "!=", "self", "and", "intersects", "(", "unzip", "(", "0", ",", "ch", ".", "relations", ")", ",", "unzip", "(", "...
Yields a list of all chunks in the sentence with the same relation id.
[ "Yields", "a", "list", "of", "all", "chunks", "in", "the", "sentence", "with", "the", "same", "relation", "id", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L414-L418
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.anchor_id
def anchor_id(self): """ Yields the anchor tag as parsed from the original token. Chunks that are anchors have a tag with an "A" prefix (e.g., "A1"). Chunks that are PNP attachmens (or chunks inside a PNP) have "P" (e.g., "P1"). Chunks inside a PNP can be both anchor and atta...
python
def anchor_id(self): """ Yields the anchor tag as parsed from the original token. Chunks that are anchors have a tag with an "A" prefix (e.g., "A1"). Chunks that are PNP attachmens (or chunks inside a PNP) have "P" (e.g., "P1"). Chunks inside a PNP can be both anchor and atta...
[ "def", "anchor_id", "(", "self", ")", ":", "id", "=", "\"\"", "f", "=", "lambda", "ch", ":", "filter", "(", "lambda", "k", ":", "self", ".", "sentence", ".", "_anchors", "[", "k", "]", "==", "ch", ",", "self", ".", "sentence", ".", "_anchors", ")...
Yields the anchor tag as parsed from the original token. Chunks that are anchors have a tag with an "A" prefix (e.g., "A1"). Chunks that are PNP attachmens (or chunks inside a PNP) have "P" (e.g., "P1"). Chunks inside a PNP can be both anchor and attachment (e.g., "P1-A2"), ...
[ "Yields", "the", "anchor", "tag", "as", "parsed", "from", "the", "original", "token", ".", "Chunks", "that", "are", "anchors", "have", "a", "tag", "with", "an", "A", "prefix", "(", "e", ".", "g", ".", "A1", ")", ".", "Chunks", "that", "are", "PNP", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L427-L442
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.modifiers
def modifiers(self): """ For verb phrases (VP), yields a list of the nearest adjectives and adverbs. """ if self._modifiers is None: # Iterate over all the chunks and attach modifiers to their VP-anchor. is_modifier = lambda ch: ch.type in ("ADJP", "ADVP") and ch.relation...
python
def modifiers(self): """ For verb phrases (VP), yields a list of the nearest adjectives and adverbs. """ if self._modifiers is None: # Iterate over all the chunks and attach modifiers to their VP-anchor. is_modifier = lambda ch: ch.type in ("ADJP", "ADVP") and ch.relation...
[ "def", "modifiers", "(", "self", ")", ":", "if", "self", ".", "_modifiers", "is", "None", ":", "# Iterate over all the chunks and attach modifiers to their VP-anchor.", "is_modifier", "=", "lambda", "ch", ":", "ch", ".", "type", "in", "(", "\"ADJP\"", ",", "\"ADVP...
For verb phrases (VP), yields a list of the nearest adjectives and adverbs.
[ "For", "verb", "phrases", "(", "VP", ")", "yields", "a", "list", "of", "the", "nearest", "adjectives", "and", "adverbs", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L450-L461
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.nearest
def nearest(self, type="VP"): """ Returns the nearest chunk in the sentence with the given type. This can be used (for example) to find adverbs and adjectives related to verbs, as in: "the cat is ravenous" => is what? => "ravenous". """ candidate, d = None, len(self.sente...
python
def nearest(self, type="VP"): """ Returns the nearest chunk in the sentence with the given type. This can be used (for example) to find adverbs and adjectives related to verbs, as in: "the cat is ravenous" => is what? => "ravenous". """ candidate, d = None, len(self.sente...
[ "def", "nearest", "(", "self", ",", "type", "=", "\"VP\"", ")", ":", "candidate", ",", "d", "=", "None", ",", "len", "(", "self", ".", "sentence", ".", "chunks", ")", "if", "isinstance", "(", "self", ",", "PNPChunk", ")", ":", "i", "=", "self", "...
Returns the nearest chunk in the sentence with the given type. This can be used (for example) to find adverbs and adjectives related to verbs, as in: "the cat is ravenous" => is what? => "ravenous".
[ "Returns", "the", "nearest", "chunk", "in", "the", "sentence", "with", "the", "given", "type", ".", "This", "can", "be", "used", "(", "for", "example", ")", "to", "find", "adverbs", "and", "adjectives", "related", "to", "verbs", "as", "in", ":", "the", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L463-L476
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.next
def next(self, type=None): """ Returns the next chunk in the sentence with the given type. """ i = self.stop s = self.sentence while i < len(s): if s[i].chunk is not None and type in (s[i].chunk.type, None): return s[i].chunk i += 1
python
def next(self, type=None): """ Returns the next chunk in the sentence with the given type. """ i = self.stop s = self.sentence while i < len(s): if s[i].chunk is not None and type in (s[i].chunk.type, None): return s[i].chunk i += 1
[ "def", "next", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "stop", "s", "=", "self", ".", "sentence", "while", "i", "<", "len", "(", "s", ")", ":", "if", "s", "[", "i", "]", ".", "chunk", "is", "not", "None", "an...
Returns the next chunk in the sentence with the given type.
[ "Returns", "the", "next", "chunk", "in", "the", "sentence", "with", "the", "given", "type", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L478-L486
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Chunk.previous
def previous(self, type=None): """ Returns the next previous chunk in the sentence with the given type. """ i = self.start - 1 s = self.sentence while i > 0: if s[i].chunk is not None and type in (s[i].chunk.type, None): return s[i].chunk i...
python
def previous(self, type=None): """ Returns the next previous chunk in the sentence with the given type. """ i = self.start - 1 s = self.sentence while i > 0: if s[i].chunk is not None and type in (s[i].chunk.type, None): return s[i].chunk i...
[ "def", "previous", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "start", "-", "1", "s", "=", "self", ".", "sentence", "while", "i", ">", "0", ":", "if", "s", "[", "i", "]", ".", "chunk", "is", "not", "None", "and", ...
Returns the next previous chunk in the sentence with the given type.
[ "Returns", "the", "next", "previous", "chunk", "in", "the", "sentence", "with", "the", "given", "type", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L488-L496
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.append
def append(self, word, lemma=None, type=None, chunk=None, role=None, relation=None, pnp=None, anchor=None, iob=None, custom={}): """ Appends the next word to the sentence / chunk / preposition. For example: Sentence.append("clawed", "claw", "VB", "VP", role=None, relation=1) - word :...
python
def append(self, word, lemma=None, type=None, chunk=None, role=None, relation=None, pnp=None, anchor=None, iob=None, custom={}): """ Appends the next word to the sentence / chunk / preposition. For example: Sentence.append("clawed", "claw", "VB", "VP", role=None, relation=1) - word :...
[ "def", "append", "(", "self", ",", "word", ",", "lemma", "=", "None", ",", "type", "=", "None", ",", "chunk", "=", "None", ",", "role", "=", "None", ",", "relation", "=", "None", ",", "pnp", "=", "None", ",", "anchor", "=", "None", ",", "iob", ...
Appends the next word to the sentence / chunk / preposition. For example: Sentence.append("clawed", "claw", "VB", "VP", role=None, relation=1) - word : the current word, - lemma : the canonical form of the word, - type : part-of-speech tag for the word (NN, JJ,...
[ "Appends", "the", "next", "word", "to", "the", "sentence", "/", "chunk", "/", "preposition", ".", "For", "example", ":", "Sentence", ".", "append", "(", "clawed", "claw", "VB", "VP", "role", "=", "None", "relation", "=", "1", ")", "-", "word", ":", "...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L708-L728
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.parse_token
def parse_token(self, token, tags=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Returns the arguments for Sentence.append() from a tagged token representation. The order in which token tags appear can be specified. The default order is (separated by slashes): - word, ...
python
def parse_token(self, token, tags=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Returns the arguments for Sentence.append() from a tagged token representation. The order in which token tags appear can be specified. The default order is (separated by slashes): - word, ...
[ "def", "parse_token", "(", "self", ",", "token", ",", "tags", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "p", "=", "{", "WORD", ":", "\"\"", ",", "POS", ":", "None", ",", "I...
Returns the arguments for Sentence.append() from a tagged token representation. The order in which token tags appear can be specified. The default order is (separated by slashes): - word, - part-of-speech, - (IOB-)chunk, - (IOB-)preposition, ...
[ "Returns", "the", "arguments", "for", "Sentence", ".", "append", "()", "from", "a", "tagged", "token", "representation", ".", "The", "order", "in", "which", "token", "tags", "appear", "can", "be", "specified", ".", "The", "default", "order", "is", "(", "se...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L730-L796
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._parse_relation
def _parse_relation(self, tag): """ Parses the chunk tag, role and relation id from the token relation tag. - VP => VP, [], [] - VP-1 => VP, [1], [None] - ADJP-PRD => ADJP, [None], [PRD] - NP-SBJ-1 => NP, [1], [SBJ] ...
python
def _parse_relation(self, tag): """ Parses the chunk tag, role and relation id from the token relation tag. - VP => VP, [], [] - VP-1 => VP, [1], [None] - ADJP-PRD => ADJP, [None], [PRD] - NP-SBJ-1 => NP, [1], [SBJ] ...
[ "def", "_parse_relation", "(", "self", ",", "tag", ")", ":", "chunk", ",", "relation", ",", "role", "=", "None", ",", "[", "]", ",", "[", "]", "if", "\";\"", "in", "tag", ":", "# NP-SBJ;NP-OBJ-1 => 1 relates to both SBJ and OBJ.", "id", "=", "tag", ".", ...
Parses the chunk tag, role and relation id from the token relation tag. - VP => VP, [], [] - VP-1 => VP, [1], [None] - ADJP-PRD => ADJP, [None], [PRD] - NP-SBJ-1 => NP, [1], [SBJ] - NP-OBJ-1*NP-OBJ-2 => NP, [1,2], ...
[ "Parses", "the", "chunk", "tag", "role", "and", "relation", "id", "from", "the", "token", "relation", "tag", ".", "-", "VP", "=", ">", "VP", "[]", "[]", "-", "VP", "-", "1", "=", ">", "VP", "[", "1", "]", "[", "None", "]", "-", "ADJP", "-", "...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L798-L834
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_word
def _do_word(self, word, lemma=None, type=None): """ Adds a new Word to the sentence. Other Sentence._do_[tag] functions assume a new word has just been appended. """ # Improve 3rd person singular "'s" lemma to "be", e.g., as in "he's fine". if lemma == "'s" and type in ("VB"...
python
def _do_word(self, word, lemma=None, type=None): """ Adds a new Word to the sentence. Other Sentence._do_[tag] functions assume a new word has just been appended. """ # Improve 3rd person singular "'s" lemma to "be", e.g., as in "he's fine". if lemma == "'s" and type in ("VB"...
[ "def", "_do_word", "(", "self", ",", "word", ",", "lemma", "=", "None", ",", "type", "=", "None", ")", ":", "# Improve 3rd person singular \"'s\" lemma to \"be\", e.g., as in \"he's fine\".", "if", "lemma", "==", "\"'s\"", "and", "type", "in", "(", "\"VB\"", ",", ...
Adds a new Word to the sentence. Other Sentence._do_[tag] functions assume a new word has just been appended.
[ "Adds", "a", "new", "Word", "to", "the", "sentence", ".", "Other", "Sentence", ".", "_do_", "[", "tag", "]", "functions", "assume", "a", "new", "word", "has", "just", "been", "appended", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L836-L843
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_chunk
def _do_chunk(self, type, role=None, relation=None, iob=None): """ Adds a new Chunk to the sentence, or adds the last word to the previous chunk. The word is attached to the previous chunk if both type and relation match, and if the word's chunk tag does not start with "B-" (i.e., iob !=...
python
def _do_chunk(self, type, role=None, relation=None, iob=None): """ Adds a new Chunk to the sentence, or adds the last word to the previous chunk. The word is attached to the previous chunk if both type and relation match, and if the word's chunk tag does not start with "B-" (i.e., iob !=...
[ "def", "_do_chunk", "(", "self", ",", "type", ",", "role", "=", "None", ",", "relation", "=", "None", ",", "iob", "=", "None", ")", ":", "if", "(", "type", "is", "None", "or", "type", "==", "OUTSIDE", ")", "and", "(", "role", "is", "None", "or", ...
Adds a new Chunk to the sentence, or adds the last word to the previous chunk. The word is attached to the previous chunk if both type and relation match, and if the word's chunk tag does not start with "B-" (i.e., iob != BEGIN). Punctuation marks (or other "O" chunk tags) are not ch...
[ "Adds", "a", "new", "Chunk", "to", "the", "sentence", "or", "adds", "the", "last", "word", "to", "the", "previous", "chunk", ".", "The", "word", "is", "attached", "to", "the", "previous", "chunk", "if", "both", "type", "and", "relation", "match", "and", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L845-L863
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_relation
def _do_relation(self): """ Attaches subjects, objects and verbs. If the previous chunk is a subject/object/verb, it is stored in Sentence.relations{}. """ if self.chunks: ch = self.chunks[-1] for relation, role in ch.relations: if role == "SBJ...
python
def _do_relation(self): """ Attaches subjects, objects and verbs. If the previous chunk is a subject/object/verb, it is stored in Sentence.relations{}. """ if self.chunks: ch = self.chunks[-1] for relation, role in ch.relations: if role == "SBJ...
[ "def", "_do_relation", "(", "self", ")", ":", "if", "self", ".", "chunks", ":", "ch", "=", "self", ".", "chunks", "[", "-", "1", "]", "for", "relation", ",", "role", "in", "ch", ".", "relations", ":", "if", "role", "==", "\"SBJ\"", "or", "role", ...
Attaches subjects, objects and verbs. If the previous chunk is a subject/object/verb, it is stored in Sentence.relations{}.
[ "Attaches", "subjects", "objects", "and", "verbs", ".", "If", "the", "previous", "chunk", "is", "a", "subject", "/", "object", "/", "verb", "it", "is", "stored", "in", "Sentence", ".", "relations", "{}", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L865-L875
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_pnp
def _do_pnp(self, pnp, anchor=None): """ Attaches prepositional noun phrases. Identifies PNP's from either the PNP tag or the P-attachment tag. This does not determine the PP-anchor, it only groups words in a PNP chunk. """ if anchor or pnp and pnp.endswith("PNP"): ...
python
def _do_pnp(self, pnp, anchor=None): """ Attaches prepositional noun phrases. Identifies PNP's from either the PNP tag or the P-attachment tag. This does not determine the PP-anchor, it only groups words in a PNP chunk. """ if anchor or pnp and pnp.endswith("PNP"): ...
[ "def", "_do_pnp", "(", "self", ",", "pnp", ",", "anchor", "=", "None", ")", ":", "if", "anchor", "or", "pnp", "and", "pnp", ".", "endswith", "(", "\"PNP\"", ")", ":", "if", "anchor", "is", "not", "None", ":", "m", "=", "find", "(", "lambda", "x",...
Attaches prepositional noun phrases. Identifies PNP's from either the PNP tag or the P-attachment tag. This does not determine the PP-anchor, it only groups words in a PNP chunk.
[ "Attaches", "prepositional", "noun", "phrases", ".", "Identifies", "PNP", "s", "from", "either", "the", "PNP", "tag", "or", "the", "P", "-", "attachment", "tag", ".", "This", "does", "not", "determine", "the", "PP", "-", "anchor", "it", "only", "groups", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L877-L898
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_anchor
def _do_anchor(self, anchor): """ Collects preposition anchors and attachments in a dictionary. Once the dictionary has an entry for both the anchor and the attachment, they are linked. """ if anchor: for x in anchor.split("-"): A, P = None, None ...
python
def _do_anchor(self, anchor): """ Collects preposition anchors and attachments in a dictionary. Once the dictionary has an entry for both the anchor and the attachment, they are linked. """ if anchor: for x in anchor.split("-"): A, P = None, None ...
[ "def", "_do_anchor", "(", "self", ",", "anchor", ")", ":", "if", "anchor", ":", "for", "x", "in", "anchor", ".", "split", "(", "\"-\"", ")", ":", "A", ",", "P", "=", "None", ",", "None", "if", "x", ".", "startswith", "(", "\"A\"", ")", "and", "...
Collects preposition anchors and attachments in a dictionary. Once the dictionary has an entry for both the anchor and the attachment, they are linked.
[ "Collects", "preposition", "anchors", "and", "attachments", "in", "a", "dictionary", ".", "Once", "the", "dictionary", "has", "an", "entry", "for", "both", "the", "anchor", "and", "the", "attachment", "they", "are", "linked", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L900-L916
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence._do_conjunction
def _do_conjunction(self, _and=("and", "e", "en", "et", "und", "y")): """ Attach conjunctions. CC-words like "and" and "or" between two chunks indicate a conjunction. """ w = self.words if len(w) > 2 and w[-2].type == "CC" and w[-2].chunk is None: cc = w[-2].stri...
python
def _do_conjunction(self, _and=("and", "e", "en", "et", "und", "y")): """ Attach conjunctions. CC-words like "and" and "or" between two chunks indicate a conjunction. """ w = self.words if len(w) > 2 and w[-2].type == "CC" and w[-2].chunk is None: cc = w[-2].stri...
[ "def", "_do_conjunction", "(", "self", ",", "_and", "=", "(", "\"and\"", ",", "\"e\"", ",", "\"en\"", ",", "\"et\"", ",", "\"und\"", ",", "\"y\"", ")", ")", ":", "w", "=", "self", ".", "words", "if", "len", "(", "w", ")", ">", "2", "and", "w", ...
Attach conjunctions. CC-words like "and" and "or" between two chunks indicate a conjunction.
[ "Attach", "conjunctions", ".", "CC", "-", "words", "like", "and", "and", "or", "between", "two", "chunks", "indicate", "a", "conjunction", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L925-L937
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.get
def get(self, index, tag=LEMMA): """ Returns a tag for the word at the given index. The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. """ if tag == WORD: return self.words[index] if tag == LEMMA: return self.word...
python
def get(self, index, tag=LEMMA): """ Returns a tag for the word at the given index. The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. """ if tag == WORD: return self.words[index] if tag == LEMMA: return self.word...
[ "def", "get", "(", "self", ",", "index", ",", "tag", "=", "LEMMA", ")", ":", "if", "tag", "==", "WORD", ":", "return", "self", ".", "words", "[", "index", "]", "if", "tag", "==", "LEMMA", ":", "return", "self", ".", "words", "[", "index", "]", ...
Returns a tag for the word at the given index. The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag.
[ "Returns", "a", "tag", "for", "the", "word", "at", "the", "given", "index", ".", "The", "tag", "can", "be", "WORD", "LEMMA", "POS", "CHUNK", "PNP", "RELATION", "ROLE", "ANCHOR", "or", "a", "custom", "word", "tag", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L939-L961
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.loop
def loop(self, *tags): """ Iterates over the tags in the entire Sentence, For example, Sentence.loop(POS, LEMMA) yields tuples of the part-of-speech tags and lemmata. Possible tags: WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. Any order or combi...
python
def loop(self, *tags): """ Iterates over the tags in the entire Sentence, For example, Sentence.loop(POS, LEMMA) yields tuples of the part-of-speech tags and lemmata. Possible tags: WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. Any order or combi...
[ "def", "loop", "(", "self", ",", "*", "tags", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "words", ")", ")", ":", "yield", "tuple", "(", "[", "self", ".", "get", "(", "i", ",", "tag", "=", "tag", ")", "for", "tag", "i...
Iterates over the tags in the entire Sentence, For example, Sentence.loop(POS, LEMMA) yields tuples of the part-of-speech tags and lemmata. Possible tags: WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. Any order or combination of tags can be supplied.
[ "Iterates", "over", "the", "tags", "in", "the", "entire", "Sentence", "For", "example", "Sentence", ".", "loop", "(", "POS", "LEMMA", ")", "yields", "tuples", "of", "the", "part", "-", "of", "-", "speech", "tags", "and", "lemmata", ".", "Possible", "tags...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L963-L970
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.indexof
def indexof(self, value, tag=WORD): """ Returns the indices of tokens in the sentence where the given token tag equals the string. The string can contain a wildcard "*" at the end (this way "NN*" will match "NN" and "NNS"). The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANC...
python
def indexof(self, value, tag=WORD): """ Returns the indices of tokens in the sentence where the given token tag equals the string. The string can contain a wildcard "*" at the end (this way "NN*" will match "NN" and "NNS"). The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANC...
[ "def", "indexof", "(", "self", ",", "value", ",", "tag", "=", "WORD", ")", ":", "match", "=", "lambda", "a", ",", "b", ":", "a", ".", "endswith", "(", "\"*\"", ")", "and", "b", ".", "startswith", "(", "a", "[", ":", "-", "1", "]", ")", "or", ...
Returns the indices of tokens in the sentence where the given token tag equals the string. The string can contain a wildcard "*" at the end (this way "NN*" will match "NN" and "NNS"). The tag can be WORD, LEMMA, POS, CHUNK, PNP, RELATION, ROLE, ANCHOR or a custom word tag. For exampl...
[ "Returns", "the", "indices", "of", "tokens", "in", "the", "sentence", "where", "the", "given", "token", "tag", "equals", "the", "string", ".", "The", "string", "can", "contain", "a", "wildcard", "*", "at", "the", "end", "(", "this", "way", "NN", "*", "...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L972-L984
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.slice
def slice(self, start, stop): """ Returns a portion of the sentence from word start index to word stop index. The returned slice is a subclass of Sentence and a deep copy. """ s = Slice(token=self.token, language=self.language) for i, word in enumerate(self.words[start:stop])...
python
def slice(self, start, stop): """ Returns a portion of the sentence from word start index to word stop index. The returned slice is a subclass of Sentence and a deep copy. """ s = Slice(token=self.token, language=self.language) for i, word in enumerate(self.words[start:stop])...
[ "def", "slice", "(", "self", ",", "start", ",", "stop", ")", ":", "s", "=", "Slice", "(", "token", "=", "self", ".", "token", ",", "language", "=", "self", ".", "language", ")", "for", "i", ",", "word", "in", "enumerate", "(", "self", ".", "words...
Returns a portion of the sentence from word start index to word stop index. The returned slice is a subclass of Sentence and a deep copy.
[ "Returns", "a", "portion", "of", "the", "sentence", "from", "word", "start", "index", "to", "word", "stop", "index", ".", "The", "returned", "slice", "is", "a", "subclass", "of", "Sentence", "and", "a", "deep", "copy", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L986-L1018
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.constituents
def constituents(self, pnp=False): """ Returns an in-order list of mixed Chunk and Word objects. With pnp=True, also contains PNPChunk objects whenever possible. """ a = [] for word in self.words: if pnp and word.pnp is not None: if len(a) == 0 or ...
python
def constituents(self, pnp=False): """ Returns an in-order list of mixed Chunk and Word objects. With pnp=True, also contains PNPChunk objects whenever possible. """ a = [] for word in self.words: if pnp and word.pnp is not None: if len(a) == 0 or ...
[ "def", "constituents", "(", "self", ",", "pnp", "=", "False", ")", ":", "a", "=", "[", "]", "for", "word", "in", "self", ".", "words", ":", "if", "pnp", "and", "word", ".", "pnp", "is", "not", "None", ":", "if", "len", "(", "a", ")", "==", "0...
Returns an in-order list of mixed Chunk and Word objects. With pnp=True, also contains PNPChunk objects whenever possible.
[ "Returns", "an", "in", "-", "order", "list", "of", "mixed", "Chunk", "and", "Word", "objects", ".", "With", "pnp", "=", "True", "also", "contains", "PNPChunk", "objects", "whenever", "possible", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1026-L1040
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Sentence.from_xml
def from_xml(cls, xml): """ Returns a new Text from the given XML string. """ s = parse_string(xml) return Sentence(s.split("\n")[0], token=s.tags, language=s.language)
python
def from_xml(cls, xml): """ Returns a new Text from the given XML string. """ s = parse_string(xml) return Sentence(s.split("\n")[0], token=s.tags, language=s.language)
[ "def", "from_xml", "(", "cls", ",", "xml", ")", ":", "s", "=", "parse_string", "(", "xml", ")", "return", "Sentence", "(", "s", ".", "split", "(", "\"\\n\"", ")", "[", "0", "]", ",", "token", "=", "s", ".", "tags", ",", "language", "=", "s", "....
Returns a new Text from the given XML string.
[ "Returns", "a", "new", "Text", "from", "the", "given", "XML", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1064-L1068
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
Text.xml
def xml(self): """ Yields the sentence as an XML-formatted string (plain bytestring, UTF-8 encoded). All the sentences in the XML are wrapped in a <text> element. """ xml = [] xml.append('<?xml version="1.0" encoding="%s"?>' % XML_ENCODING.get(self.encoding, self.encoding)) ...
python
def xml(self): """ Yields the sentence as an XML-formatted string (plain bytestring, UTF-8 encoded). All the sentences in the XML are wrapped in a <text> element. """ xml = [] xml.append('<?xml version="1.0" encoding="%s"?>' % XML_ENCODING.get(self.encoding, self.encoding)) ...
[ "def", "xml", "(", "self", ")", ":", "xml", "=", "[", "]", "xml", ".", "append", "(", "'<?xml version=\"1.0\" encoding=\"%s\"?>'", "%", "XML_ENCODING", ".", "get", "(", "self", ".", "encoding", ",", "self", ".", "encoding", ")", ")", "xml", ".", "append"...
Yields the sentence as an XML-formatted string (plain bytestring, UTF-8 encoded). All the sentences in the XML are wrapped in a <text> element.
[ "Yields", "the", "sentence", "as", "an", "XML", "-", "formatted", "string", "(", "plain", "bytestring", "UTF", "-", "8", "encoded", ")", ".", "All", "the", "sentences", "in", "the", "XML", "are", "wrapped", "in", "a", "<text", ">", "element", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1186-L1195
markuskiller/textblob-de
prepare_docs.py
get_credits
def get_credits(): """Extract credits from `AUTHORS.rst`""" credits = read(os.path.join(_HERE, "AUTHORS.rst")).split("\n") from_index = credits.index("Active Contributors") credits = "\n".join(credits[from_index + 2:]) return credits
python
def get_credits(): """Extract credits from `AUTHORS.rst`""" credits = read(os.path.join(_HERE, "AUTHORS.rst")).split("\n") from_index = credits.index("Active Contributors") credits = "\n".join(credits[from_index + 2:]) return credits
[ "def", "get_credits", "(", ")", ":", "credits", "=", "read", "(", "os", ".", "path", ".", "join", "(", "_HERE", ",", "\"AUTHORS.rst\"", ")", ")", ".", "split", "(", "\"\\n\"", ")", "from_index", "=", "credits", ".", "index", "(", "\"Active Contributors\"...
Extract credits from `AUTHORS.rst`
[ "Extract", "credits", "from", "AUTHORS", ".", "rst" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L30-L35
markuskiller/textblob-de
prepare_docs.py
rst2markdown_github
def rst2markdown_github(path_to_rst, path_to_md, pandoc="pandoc"): """ Converts ``rst`` to **markdown_github**, using :program:`pandoc` **Input** * ``FILE.rst`` **Output** * ``FILE.md`` """ _proc = subprocess.Popen([pandoc, "-f", "rst", "-t", "m...
python
def rst2markdown_github(path_to_rst, path_to_md, pandoc="pandoc"): """ Converts ``rst`` to **markdown_github**, using :program:`pandoc` **Input** * ``FILE.rst`` **Output** * ``FILE.md`` """ _proc = subprocess.Popen([pandoc, "-f", "rst", "-t", "m...
[ "def", "rst2markdown_github", "(", "path_to_rst", ",", "path_to_md", ",", "pandoc", "=", "\"pandoc\"", ")", ":", "_proc", "=", "subprocess", ".", "Popen", "(", "[", "pandoc", ",", "\"-f\"", ",", "\"rst\"", ",", "\"-t\"", ",", "\"markdown_github\"", ",", "#\"...
Converts ``rst`` to **markdown_github**, using :program:`pandoc` **Input** * ``FILE.rst`` **Output** * ``FILE.md``
[ "Converts", "rst", "to", "**", "markdown_github", "**", "using", ":", "program", ":", "pandoc" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L38-L79
markuskiller/textblob-de
prepare_docs.py
console_help2rst
def console_help2rst(cwd, help_cmd, path_to_rst, rst_title, format_as_code=False): """ Extract HELP information from ``<program> -h | --help`` message **Input** * ``$ <program> -h | --help`` * ``$ cd <cwd> && make help`` **Output** * ``docs/src/console_he...
python
def console_help2rst(cwd, help_cmd, path_to_rst, rst_title, format_as_code=False): """ Extract HELP information from ``<program> -h | --help`` message **Input** * ``$ <program> -h | --help`` * ``$ cd <cwd> && make help`` **Output** * ``docs/src/console_he...
[ "def", "console_help2rst", "(", "cwd", ",", "help_cmd", ",", "path_to_rst", ",", "rst_title", ",", "format_as_code", "=", "False", ")", ":", "generated_time_str", "=", "\"\"\"\n\n ::\n\n generated: {0}\n\n\"\"\"", ".", "format", "(", "time", ".", "strftime", ...
Extract HELP information from ``<program> -h | --help`` message **Input** * ``$ <program> -h | --help`` * ``$ cd <cwd> && make help`` **Output** * ``docs/src/console_help_xy.rst``
[ "Extract", "HELP", "information", "from", "<program", ">", "-", "h", "|", "--", "help", "message" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L82-L150
markuskiller/textblob-de
prepare_docs.py
update_docs
def update_docs(readme=True, makefiles=True): """Update documentation (ready for publishing new release) Usually called by ``make docs`` :param bool make_doc: generate DOC page from Makefile help messages """ if readme: _pandoc = get_external_executable("pandoc") rst2markdown_gith...
python
def update_docs(readme=True, makefiles=True): """Update documentation (ready for publishing new release) Usually called by ``make docs`` :param bool make_doc: generate DOC page from Makefile help messages """ if readme: _pandoc = get_external_executable("pandoc") rst2markdown_gith...
[ "def", "update_docs", "(", "readme", "=", "True", ",", "makefiles", "=", "True", ")", ":", "if", "readme", ":", "_pandoc", "=", "get_external_executable", "(", "\"pandoc\"", ")", "rst2markdown_github", "(", "os", ".", "path", ".", "join", "(", "_HERE", ","...
Update documentation (ready for publishing new release) Usually called by ``make docs`` :param bool make_doc: generate DOC page from Makefile help messages
[ "Update", "documentation", "(", "ready", "for", "publishing", "new", "release", ")" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L153-L197
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.rms
def rms(self, x, params=()): """ Returns root mean square value of f(x, params) """ internal_x, internal_params = self.pre_process(np.asarray(x), np.asarray(params)) if internal_params.ndim > 1: raise NotImplementedError("Paramet...
python
def rms(self, x, params=()): """ Returns root mean square value of f(x, params) """ internal_x, internal_params = self.pre_process(np.asarray(x), np.asarray(params)) if internal_params.ndim > 1: raise NotImplementedError("Paramet...
[ "def", "rms", "(", "self", ",", "x", ",", "params", "=", "(", ")", ")", ":", "internal_x", ",", "internal_params", "=", "self", ".", "pre_process", "(", "np", ".", "asarray", "(", "x", ")", ",", "np", ".", "asarray", "(", "params", ")", ")", "if"...
Returns root mean square value of f(x, params)
[ "Returns", "root", "mean", "square", "value", "of", "f", "(", "x", "params", ")" ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L79-L89
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.solve_series
def solve_series(self, x0, params, varied_data, varied_idx, internal_x0=None, solver=None, propagate=True, **kwargs): """ Solve system for a set of parameters in which one is varied Parameters ---------- x0 : array_like Guess (subject to ``self.post_proc...
python
def solve_series(self, x0, params, varied_data, varied_idx, internal_x0=None, solver=None, propagate=True, **kwargs): """ Solve system for a set of parameters in which one is varied Parameters ---------- x0 : array_like Guess (subject to ``self.post_proc...
[ "def", "solve_series", "(", "self", ",", "x0", ",", "params", ",", "varied_data", ",", "varied_idx", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "propagate", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "x_...
Solve system for a set of parameters in which one is varied Parameters ---------- x0 : array_like Guess (subject to ``self.post_processors``) params : array_like Parameter values vaired_data : array_like Numerical values of the varied paramete...
[ "Solve", "system", "for", "a", "set", "of", "parameters", "in", "which", "one", "is", "varied" ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L91-L166
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.plot_series
def plot_series(self, xres, varied_data, varied_idx, **kwargs): """ Plots the results from :meth:`solve_series`. Parameters ---------- xres : array Of shape ``(varied_data.size, self.nx)``. varied_data : array See :meth:`solve_series`. varied_idx ...
python
def plot_series(self, xres, varied_data, varied_idx, **kwargs): """ Plots the results from :meth:`solve_series`. Parameters ---------- xres : array Of shape ``(varied_data.size, self.nx)``. varied_data : array See :meth:`solve_series`. varied_idx ...
[ "def", "plot_series", "(", "self", ",", "xres", ",", "varied_data", ",", "varied_idx", ",", "*", "*", "kwargs", ")", ":", "for", "attr", "in", "'names latex_names'", ".", "split", "(", ")", ":", "if", "kwargs", ".", "get", "(", "attr", ",", "None", "...
Plots the results from :meth:`solve_series`. Parameters ---------- xres : array Of shape ``(varied_data.size, self.nx)``. varied_data : array See :meth:`solve_series`. varied_idx : int or str See :meth:`solve_series`. \\*\\*kwargs : ...
[ "Plots", "the", "results", "from", ":", "meth", ":", "solve_series", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L168-L193
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.plot_series_residuals
def plot_series_residuals(self, xres, varied_data, varied_idx, params, **kwargs): """ Analogous to :meth:`plot_series` but will plot residuals. """ nf = len(self.f_cb(*self.pre_process(xres[0], params))) xerr = np.empty((xres.shape[0], nf)) new_params = np.array(params) for idx,...
python
def plot_series_residuals(self, xres, varied_data, varied_idx, params, **kwargs): """ Analogous to :meth:`plot_series` but will plot residuals. """ nf = len(self.f_cb(*self.pre_process(xres[0], params))) xerr = np.empty((xres.shape[0], nf)) new_params = np.array(params) for idx,...
[ "def", "plot_series_residuals", "(", "self", ",", "xres", ",", "varied_data", ",", "varied_idx", ",", "params", ",", "*", "*", "kwargs", ")", ":", "nf", "=", "len", "(", "self", ".", "f_cb", "(", "*", "self", ".", "pre_process", "(", "xres", "[", "0"...
Analogous to :meth:`plot_series` but will plot residuals.
[ "Analogous", "to", ":", "meth", ":", "plot_series", "but", "will", "plot", "residuals", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L195-L204
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.plot_series_residuals_internal
def plot_series_residuals_internal(self, varied_data, varied_idx, **kwargs): """ Analogous to :meth:`plot_series` but for internal residuals from last run. """ nf = len(self.f_cb(*self.pre_process( self.internal_xout[0], self.internal_params_out[0]))) xerr = np.empty((self.internal_x...
python
def plot_series_residuals_internal(self, varied_data, varied_idx, **kwargs): """ Analogous to :meth:`plot_series` but for internal residuals from last run. """ nf = len(self.f_cb(*self.pre_process( self.internal_xout[0], self.internal_params_out[0]))) xerr = np.empty((self.internal_x...
[ "def", "plot_series_residuals_internal", "(", "self", ",", "varied_data", ",", "varied_idx", ",", "*", "*", "kwargs", ")", ":", "nf", "=", "len", "(", "self", ".", "f_cb", "(", "*", "self", ".", "pre_process", "(", "self", ".", "internal_xout", "[", "0",...
Analogous to :meth:`plot_series` but for internal residuals from last run.
[ "Analogous", "to", ":", "meth", ":", "plot_series", "but", "for", "internal", "residuals", "from", "last", "run", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L206-L213
bjodah/pyneqsys
pyneqsys/core.py
_NeqSysBase.solve_and_plot_series
def solve_and_plot_series(self, x0, params, varied_data, varied_idx, solver=None, plot_kwargs=None, plot_residuals_kwargs=None, **kwargs): """ Solve and plot for a series of a varied parameter. Convenience method, see :meth:`solve_series`, :meth:`plot_series` & :me...
python
def solve_and_plot_series(self, x0, params, varied_data, varied_idx, solver=None, plot_kwargs=None, plot_residuals_kwargs=None, **kwargs): """ Solve and plot for a series of a varied parameter. Convenience method, see :meth:`solve_series`, :meth:`plot_series` & :me...
[ "def", "solve_and_plot_series", "(", "self", ",", "x0", ",", "params", ",", "varied_data", ",", "varied_idx", ",", "solver", "=", "None", ",", "plot_kwargs", "=", "None", ",", "plot_residuals_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sol", ...
Solve and plot for a series of a varied parameter. Convenience method, see :meth:`solve_series`, :meth:`plot_series` & :meth:`plot_series_residuals_internal` for more information.
[ "Solve", "and", "plot", "for", "a", "series", "of", "a", "varied", "parameter", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L215-L233
bjodah/pyneqsys
pyneqsys/core.py
NeqSys.pre_process
def pre_process(self, x0, params=()): """ Used internally for transformation of variables. """ # Should be used by all methods matching "solve_*" if self.x_by_name and isinstance(x0, dict): x0 = [x0[k] for k in self.names] if self.par_by_name and isinstance(params, dict): ...
python
def pre_process(self, x0, params=()): """ Used internally for transformation of variables. """ # Should be used by all methods matching "solve_*" if self.x_by_name and isinstance(x0, dict): x0 = [x0[k] for k in self.names] if self.par_by_name and isinstance(params, dict): ...
[ "def", "pre_process", "(", "self", ",", "x0", ",", "params", "=", "(", ")", ")", ":", "# Should be used by all methods matching \"solve_*\"", "if", "self", ".", "x_by_name", "and", "isinstance", "(", "x0", ",", "dict", ")", ":", "x0", "=", "[", "x0", "[", ...
Used internally for transformation of variables.
[ "Used", "internally", "for", "transformation", "of", "variables", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L318-L327
bjodah/pyneqsys
pyneqsys/core.py
NeqSys.post_process
def post_process(self, xout, params_out): """ Used internally for transformation of variables. """ # Should be used by all methods matching "solve_*" for post_processor in self.post_processors: xout, params_out = post_processor(xout, params_out) return xout, params_out
python
def post_process(self, xout, params_out): """ Used internally for transformation of variables. """ # Should be used by all methods matching "solve_*" for post_processor in self.post_processors: xout, params_out = post_processor(xout, params_out) return xout, params_out
[ "def", "post_process", "(", "self", ",", "xout", ",", "params_out", ")", ":", "# Should be used by all methods matching \"solve_*\"", "for", "post_processor", "in", "self", ".", "post_processors", ":", "xout", ",", "params_out", "=", "post_processor", "(", "xout", "...
Used internally for transformation of variables.
[ "Used", "internally", "for", "transformation", "of", "variables", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L329-L334
bjodah/pyneqsys
pyneqsys/core.py
NeqSys.solve
def solve(self, x0, params=(), internal_x0=None, solver=None, attached_solver=None, **kwargs): """ Solve with user specified ``solver`` choice. Parameters ---------- x0: 1D array of floats Guess (subject to ``self.post_processors``) params: 1D array_like of floats ...
python
def solve(self, x0, params=(), internal_x0=None, solver=None, attached_solver=None, **kwargs): """ Solve with user specified ``solver`` choice. Parameters ---------- x0: 1D array of floats Guess (subject to ``self.post_processors``) params: 1D array_like of floats ...
[ "def", "solve", "(", "self", ",", "x0", ",", "params", "=", "(", ")", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "attached_solver", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "solver", ","...
Solve with user specified ``solver`` choice. Parameters ---------- x0: 1D array of floats Guess (subject to ``self.post_processors``) params: 1D array_like of floats Parameters (subject to ``self.post_processors``) internal_x0: 1D array of floats ...
[ "Solve", "with", "user", "specified", "solver", "choice", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L336-L390
bjodah/pyneqsys
pyneqsys/core.py
NeqSys._solve_scipy
def _solve_scipy(self, intern_x0, tol=1e-8, method=None, **kwargs): """ Uses ``scipy.optimize.root`` See: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html Parameters ---------- intern_x0: array_like initial guess tol: float ...
python
def _solve_scipy(self, intern_x0, tol=1e-8, method=None, **kwargs): """ Uses ``scipy.optimize.root`` See: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html Parameters ---------- intern_x0: array_like initial guess tol: float ...
[ "def", "_solve_scipy", "(", "self", ",", "intern_x0", ",", "tol", "=", "1e-8", ",", "method", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "scipy", ".", "optimize", "import", "root", "if", "method", "is", "None", ":", "if", "self", ".", ...
Uses ``scipy.optimize.root`` See: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.root.html Parameters ---------- intern_x0: array_like initial guess tol: float Tolerance method: str What method to use. Defaults to ...
[ "Uses", "scipy", ".", "optimize", ".", "root" ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L392-L426
bjodah/pyneqsys
pyneqsys/core.py
ConditionalNeqSys.solve
def solve(self, x0, params=(), internal_x0=None, solver=None, conditional_maxiter=20, initial_conditions=None, **kwargs): """ Solve the problem (systems of equations) Parameters ---------- x0 : array Guess. params : array See :meth:`NeqSys.s...
python
def solve(self, x0, params=(), internal_x0=None, solver=None, conditional_maxiter=20, initial_conditions=None, **kwargs): """ Solve the problem (systems of equations) Parameters ---------- x0 : array Guess. params : array See :meth:`NeqSys.s...
[ "def", "solve", "(", "self", ",", "x0", ",", "params", "=", "(", ")", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "conditional_maxiter", "=", "20", ",", "initial_conditions", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if",...
Solve the problem (systems of equations) Parameters ---------- x0 : array Guess. params : array See :meth:`NeqSys.solve`. internal_x0 : array See :meth:`NeqSys.solve`. solver : str or callable or iterable of such. See :meth...
[ "Solve", "the", "problem", "(", "systems", "of", "equations", ")" ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L626-L679
bjodah/pyneqsys
examples/bi_dimensional.py
solve
def solve(guess_a, guess_b, power, solver='scipy'): """ Constructs a pyneqsys.symbolic.SymbolicSys instance and returns from its ``solve`` method. """ # The problem is 2 dimensional so we need 2 symbols x = sp.symbols('x:2', real=True) # There is a user specified parameter ``p`` in this problem: p =...
python
def solve(guess_a, guess_b, power, solver='scipy'): """ Constructs a pyneqsys.symbolic.SymbolicSys instance and returns from its ``solve`` method. """ # The problem is 2 dimensional so we need 2 symbols x = sp.symbols('x:2', real=True) # There is a user specified parameter ``p`` in this problem: p =...
[ "def", "solve", "(", "guess_a", ",", "guess_b", ",", "power", ",", "solver", "=", "'scipy'", ")", ":", "# The problem is 2 dimensional so we need 2 symbols", "x", "=", "sp", ".", "symbols", "(", "'x:2'", ",", "real", "=", "True", ")", "# There is a user specifie...
Constructs a pyneqsys.symbolic.SymbolicSys instance and returns from its ``solve`` method.
[ "Constructs", "a", "pyneqsys", ".", "symbolic", ".", "SymbolicSys", "instance", "and", "returns", "from", "its", "solve", "method", "." ]
train
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/examples/bi_dimensional.py#L13-L26