partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
chunked
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).
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1100-L1117
[ "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...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
tree
Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string.
textblob_de/ext/_pattern/text/tree.py
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]): """ 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)
[ "Transforms", "the", "output", "of", "parse", "()", "into", "a", "Text", "object", ".", "The", "token", "parameter", "lists", "the", "order", "of", "tags", "in", "each", "token", "in", "the", "input", "string", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1207-L1211
[ "def", "tree", "(", "string", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "return", "Text", "(", "string", ",", "token", ")" ]
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
xml_encode
Returns the string with XML-safe special characters.
textblob_de/ext/_pattern/text/tree.py
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): """ 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
[ "Returns", "the", "string", "with", "XML", "-", "safe", "special", "characters", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1253-L1261
[ "def", "xml_encode", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "\"&\"", ",", "\"&amp;\"", ")", "string", "=", "string", ".", "replace", "(", "\"<\"", ",", "\"&lt;\"", ")", "string", "=", "string", ".", "replace", "(", "\">\...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
xml_decode
Returns the string with special characters decoded.
textblob_de/ext/_pattern/text/tree.py
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): """ 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
[ "Returns", "the", "string", "with", "special", "characters", "decoded", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1263-L1271
[ "def", "xml_decode", "(", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "\"&amp;\"", ",", "\"&\"", ")", "string", "=", "string", ".", "replace", "(", "\"&lt;\"", ",", "\"<\"", ")", "string", "=", "string", ".", "replace", "(", "\"&g...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
parse_xml
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...
textblob_de/ext/_pattern/text/tree.py
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=""): """ 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...
[ "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...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1279-L1384
[ "def", "parse_xml", "(", "sentence", ",", "tab", "=", "\"\\t\"", ",", "id", "=", "\"\"", ")", ":", "uid", "=", "lambda", "*", "parts", ":", "\"\"", ".", "join", "(", "[", "str", "(", "id", ")", ",", "_UID_SEPARATOR", "]", "+", "[", "str", "(", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
parse_string
Returns a slash-formatted string from the given XML representation. The return value is a TokenString (for MBSP) or TaggedString (for Pattern).
textblob_de/ext/_pattern/text/tree.py
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): """ 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): ...
[ "Returns", "a", "slash", "-", "formatted", "string", "from", "the", "given", "XML", "representation", ".", "The", "return", "value", "is", "a", "TokenString", "(", "for", "MBSP", ")", "or", "TaggedString", "(", "for", "Pattern", ")", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1440-L1487
[ "def", "parse_string", "(", "xml", ")", ":", "string", "=", "\"\"", "# Traverse all the <sentence> elements in the XML.", "dom", "=", "XML", "(", "xml", ")", "for", "sentence", "in", "dom", "(", "XML_SENTENCE", ")", ":", "_anchors", ".", "clear", "(", ")", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
_parse_tokens
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.
textblob_de/ext/_pattern/text/tree.py
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]): """ 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...
[ "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...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1489-L1534
[ "def", "_parse_tokens", "(", "chunk", ",", "format", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "tokens", "=", "[", "]", "# Only process <chunk> and <chink> elements, ", "# text nodes in be...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
_parse_relation
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.
textblob_de/ext/_pattern/text/tree.py
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"): """ 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 != ...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1536-L1547
[ "def", "_parse_relation", "(", "chunk", ",", "type", "=", "\"O\"", ")", ":", "r1", "=", "chunk", ".", "get", "(", "XML_RELATION", ")", "r2", "=", "chunk", ".", "get", "(", "XML_ID", ",", "chunk", ".", "get", "(", "XML_OF", ")", ")", "r1", "=", "[...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
_parse_token
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.
textblob_de/ext/_pattern/text/tree.py
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, 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. """ ...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1549-L1566
[ "def", "_parse_token", "(", "word", ",", "chunk", "=", "\"O\"", ",", "pnp", "=", "\"O\"", ",", "relation", "=", "\"O\"", ",", "anchor", "=", "\"O\"", ",", "format", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
nltk_tree
Returns an NLTK nltk.tree.Tree object from the given Sentence. The NLTK module should be on the search path somewhere.
textblob_de/ext/_pattern/text/tree.py
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): """ 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 = ' '....
[ "Returns", "an", "NLTK", "nltk", ".", "tree", ".", "Tree", "object", "from", "the", "given", "Sentence", ".", "The", "NLTK", "module", "should", "be", "on", "the", "search", "path", "somewhere", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1570-L1599
[ "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...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
graphviz_dot
Returns a dot-formatted string that can be visualized as a graph in GraphViz.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "Returns", "a", "dot", "-", "formatted", "string", "that", "can", "be", "visualized", "as", "a", "graph", "in", "GraphViz", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1621-L1672
[ "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\...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
table
Returns a string where the tags of tokens in the sentence are organized in outlined columns.
textblob_de/ext/_pattern/text/tree.py
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="-"): """ 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): ...
[ "Returns", "a", "string", "where", "the", "tags", "of", "tokens", "in", "the", "sentence", "are", "organized", "in", "outlined", "columns", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1676-L1717
[ "def", "table", "(", "sentence", ",", "fill", "=", "1", ",", "placeholder", "=", "\"-\"", ")", ":", "tags", "=", "[", "WORD", ",", "POS", ",", "IOB", ",", "CHUNK", ",", "ROLE", ",", "REL", ",", "PNP", ",", "ANCHOR", ",", "LEMMA", "]", "tags", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Word.tags
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"]
textblob_de/ext/_pattern/text/tree.py
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): """ 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 ...
[ "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", "]" ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L190-L215
[ "def", "tags", "(", "self", ")", ":", "# See also. Sentence.__repr__().", "ch", ",", "I", ",", "O", ",", "B", "=", "self", ".", "chunk", ",", "INSIDE", "+", "\"-\"", ",", "OUTSIDE", ",", "BEGIN", "+", "\"-\"", "tags", "=", "[", "OUTSIDE", "for", "i",...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Word.next
Returns the next word in the sentence with the given type.
textblob_de/ext/_pattern/text/tree.py
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): """ 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
[ "Returns", "the", "next", "word", "in", "the", "sentence", "with", "the", "given", "type", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L222-L230
[ "def", "next", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "index", "+", "1", "s", "=", "self", ".", "sentence", "while", "i", "<", "len", "(", "s", ")", ":", "if", "type", "in", "(", "s", "[", "i", "]", ".", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Word.previous
Returns the next previous word in the sentence with the given type.
textblob_de/ext/_pattern/text/tree.py
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): """ 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
[ "Returns", "the", "next", "previous", "word", "in", "the", "sentence", "with", "the", "given", "type", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L232-L240
[ "def", "previous", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "index", "-", "1", "s", "=", "self", ".", "sentence", "while", "i", ">", "0", ":", "if", "type", "in", "(", "s", "[", "i", "]", ".", "type", ",", "No...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.head
Yields the head of the chunk (usually, the last word in the chunk).
textblob_de/ext/_pattern/text/tree.py
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): """ 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" ...
[ "Yields", "the", "head", "of", "the", "chunk", "(", "usually", "the", "last", "word", "in", "the", "chunk", ")", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L365-L382
[ "def", "head", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\"NP\"", "and", "any", "(", "w", ".", "type", ".", "startswith", "(", "\"NNP\"", ")", "for", "w", "in", "self", ")", ":", "w", "=", "find", "(", "lambda", "w", ":", "w", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.related
Yields a list of all chunks in the sentence with the same relation id.
textblob_de/ext/_pattern/text/tree.py
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): """ 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))]
[ "Yields", "a", "list", "of", "all", "chunks", "in", "the", "sentence", "with", "the", "same", "relation", "id", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L414-L418
[ "def", "related", "(", "self", ")", ":", "return", "[", "ch", "for", "ch", "in", "self", ".", "sentence", ".", "chunks", "if", "ch", "!=", "self", "and", "intersects", "(", "unzip", "(", "0", ",", "ch", ".", "relations", ")", ",", "unzip", "(", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.anchor_id
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"), ...
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L427-L442
[ "def", "anchor_id", "(", "self", ")", ":", "id", "=", "\"\"", "f", "=", "lambda", "ch", ":", "filter", "(", "lambda", "k", ":", "self", ".", "sentence", ".", "_anchors", "[", "k", "]", "==", "ch", ",", "self", ".", "sentence", ".", "_anchors", ")...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.modifiers
For verb phrases (VP), yields a list of the nearest adjectives and adverbs.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "For", "verb", "phrases", "(", "VP", ")", "yields", "a", "list", "of", "the", "nearest", "adjectives", "and", "adverbs", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L450-L461
[ "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...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.nearest
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".
textblob_de/ext/_pattern/text/tree.py
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"): """ 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...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L463-L476
[ "def", "nearest", "(", "self", ",", "type", "=", "\"VP\"", ")", ":", "candidate", ",", "d", "=", "None", ",", "len", "(", "self", ".", "sentence", ".", "chunks", ")", "if", "isinstance", "(", "self", ",", "PNPChunk", ")", ":", "i", "=", "self", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.next
Returns the next chunk in the sentence with the given type.
textblob_de/ext/_pattern/text/tree.py
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): """ 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
[ "Returns", "the", "next", "chunk", "in", "the", "sentence", "with", "the", "given", "type", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L478-L486
[ "def", "next", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "stop", "s", "=", "self", ".", "sentence", "while", "i", "<", "len", "(", "s", ")", ":", "if", "s", "[", "i", "]", ".", "chunk", "is", "not", "None", "an...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Chunk.previous
Returns the next previous chunk in the sentence with the given type.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "Returns", "the", "next", "previous", "chunk", "in", "the", "sentence", "with", "the", "given", "type", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L488-L496
[ "def", "previous", "(", "self", ",", "type", "=", "None", ")", ":", "i", "=", "self", ".", "start", "-", "1", "s", "=", "self", ".", "sentence", "while", "i", ">", "0", ":", "if", "s", "[", "i", "]", ".", "chunk", "is", "not", "None", "and", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.append
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,...
textblob_de/ext/_pattern/text/tree.py
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=None, custom={}): """ Appends the next word to the sentence / chunk / preposition. For example: Sentence.append("clawed", "claw", "VB", "VP", role=None, relation=1) - word :...
[ "Appends", "the", "next", "word", "to", "the", "sentence", "/", "chunk", "/", "preposition", ".", "For", "example", ":", "Sentence", ".", "append", "(", "clawed", "claw", "VB", "VP", "role", "=", "None", "relation", "=", "1", ")", "-", "word", ":", "...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L708-L728
[ "def", "append", "(", "self", ",", "word", ",", "lemma", "=", "None", ",", "type", "=", "None", ",", "chunk", "=", "None", ",", "role", "=", "None", ",", "relation", "=", "None", ",", "pnp", "=", "None", ",", "anchor", "=", "None", ",", "iob", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.parse_token
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, ...
textblob_de/ext/_pattern/text/tree.py
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]): """ 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, ...
[ "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...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L730-L796
[ "def", "parse_token", "(", "self", ",", "token", ",", "tags", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "p", "=", "{", "WORD", ":", "\"\"", ",", "POS", ":", "None", ",", "I...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._parse_relation
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], ...
textblob_de/ext/_pattern/text/tree.py
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): """ 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] ...
[ "Parses", "the", "chunk", "tag", "role", "and", "relation", "id", "from", "the", "token", "relation", "tag", ".", "-", "VP", "=", ">", "VP", "[]", "[]", "-", "VP", "-", "1", "=", ">", "VP", "[", "1", "]", "[", "None", "]", "-", "ADJP", "-", "...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L798-L834
[ "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", ".", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_word
Adds a new Word to the sentence. Other Sentence._do_[tag] functions assume a new word has just been appended.
textblob_de/ext/_pattern/text/tree.py
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): """ 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"...
[ "Adds", "a", "new", "Word", "to", "the", "sentence", ".", "Other", "Sentence", ".", "_do_", "[", "tag", "]", "functions", "assume", "a", "new", "word", "has", "just", "been", "appended", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L836-L843
[ "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\"", ",", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_chunk
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...
textblob_de/ext/_pattern/text/tree.py
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): """ 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 !=...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L845-L863
[ "def", "_do_chunk", "(", "self", ",", "type", ",", "role", "=", "None", ",", "relation", "=", "None", ",", "iob", "=", "None", ")", ":", "if", "(", "type", "is", "None", "or", "type", "==", "OUTSIDE", ")", "and", "(", "role", "is", "None", "or", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_relation
Attaches subjects, objects and verbs. If the previous chunk is a subject/object/verb, it is stored in Sentence.relations{}.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "Attaches", "subjects", "objects", "and", "verbs", ".", "If", "the", "previous", "chunk", "is", "a", "subject", "/", "object", "/", "verb", "it", "is", "stored", "in", "Sentence", ".", "relations", "{}", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L865-L875
[ "def", "_do_relation", "(", "self", ")", ":", "if", "self", ".", "chunks", ":", "ch", "=", "self", ".", "chunks", "[", "-", "1", "]", "for", "relation", ",", "role", "in", "ch", ".", "relations", ":", "if", "role", "==", "\"SBJ\"", "or", "role", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_pnp
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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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"): ...
[ "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", ...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L877-L898
[ "def", "_do_pnp", "(", "self", ",", "pnp", ",", "anchor", "=", "None", ")", ":", "if", "anchor", "or", "pnp", "and", "pnp", ".", "endswith", "(", "\"PNP\"", ")", ":", "if", "anchor", "is", "not", "None", ":", "m", "=", "find", "(", "lambda", "x",...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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 ...
[ "Collects", "preposition", "anchors", "and", "attachments", "in", "a", "dictionary", ".", "Once", "the", "dictionary", "has", "an", "entry", "for", "both", "the", "anchor", "and", "the", "attachment", "they", "are", "linked", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L900-L916
[ "def", "_do_anchor", "(", "self", ",", "anchor", ")", ":", "if", "anchor", ":", "for", "x", "in", "anchor", ".", "split", "(", "\"-\"", ")", ":", "A", ",", "P", "=", "None", ",", "None", "if", "x", ".", "startswith", "(", "\"A\"", ")", "and", "...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence._do_conjunction
Attach conjunctions. CC-words like "and" and "or" between two chunks indicate a conjunction.
textblob_de/ext/_pattern/text/tree.py
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")): """ 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...
[ "Attach", "conjunctions", ".", "CC", "-", "words", "like", "and", "and", "or", "between", "two", "chunks", "indicate", "a", "conjunction", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L925-L937
[ "def", "_do_conjunction", "(", "self", ",", "_and", "=", "(", "\"and\"", ",", "\"e\"", ",", "\"en\"", ",", "\"et\"", ",", "\"und\"", ",", "\"y\"", ")", ")", ":", "w", "=", "self", ".", "words", "if", "len", "(", "w", ")", ">", "2", "and", "w", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.get
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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "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", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L939-L961
[ "def", "get", "(", "self", ",", "index", ",", "tag", "=", "LEMMA", ")", ":", "if", "tag", "==", "WORD", ":", "return", "self", ".", "words", "[", "index", "]", "if", "tag", "==", "LEMMA", ":", "return", "self", ".", "words", "[", "index", "]", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.loop
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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "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...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L963-L970
[ "def", "loop", "(", "self", ",", "*", "tags", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "words", ")", ")", ":", "yield", "tuple", "(", "[", "self", ".", "get", "(", "i", ",", "tag", "=", "tag", ")", "for", "tag", "i...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.indexof
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...
textblob_de/ext/_pattern/text/tree.py
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): """ 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...
[ "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", "*", "...
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L972-L984
[ "def", "indexof", "(", "self", ",", "value", ",", "tag", "=", "WORD", ")", ":", "match", "=", "lambda", "a", ",", "b", ":", "a", ".", "endswith", "(", "\"*\"", ")", "and", "b", ".", "startswith", "(", "a", "[", ":", "-", "1", "]", ")", "or", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.slice
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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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])...
[ "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", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L986-L1018
[ "def", "slice", "(", "self", ",", "start", ",", "stop", ")", ":", "s", "=", "Slice", "(", "token", "=", "self", ".", "token", ",", "language", "=", "self", ".", "language", ")", "for", "i", ",", "word", "in", "enumerate", "(", "self", ".", "words...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.constituents
Returns an in-order list of mixed Chunk and Word objects. With pnp=True, also contains PNPChunk objects whenever possible.
textblob_de/ext/_pattern/text/tree.py
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): """ 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 ...
[ "Returns", "an", "in", "-", "order", "list", "of", "mixed", "Chunk", "and", "Word", "objects", ".", "With", "pnp", "=", "True", "also", "contains", "PNPChunk", "objects", "whenever", "possible", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1026-L1040
[ "def", "constituents", "(", "self", ",", "pnp", "=", "False", ")", ":", "a", "=", "[", "]", "for", "word", "in", "self", ".", "words", ":", "if", "pnp", "and", "word", ".", "pnp", "is", "not", "None", ":", "if", "len", "(", "a", ")", "==", "0...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Sentence.from_xml
Returns a new Text from the given XML string.
textblob_de/ext/_pattern/text/tree.py
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): """ 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)
[ "Returns", "a", "new", "Text", "from", "the", "given", "XML", "string", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1064-L1068
[ "def", "from_xml", "(", "cls", ",", "xml", ")", ":", "s", "=", "parse_string", "(", "xml", ")", "return", "Sentence", "(", "s", ".", "split", "(", "\"\\n\"", ")", "[", "0", "]", ",", "token", "=", "s", ".", "tags", ",", "language", "=", "s", "....
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
Text.xml
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.
textblob_de/ext/_pattern/text/tree.py
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): """ 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)) ...
[ "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", "." ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1186-L1195
[ "def", "xml", "(", "self", ")", ":", "xml", "=", "[", "]", "xml", ".", "append", "(", "'<?xml version=\"1.0\" encoding=\"%s\"?>'", "%", "XML_ENCODING", ".", "get", "(", "self", ".", "encoding", ",", "self", ".", "encoding", ")", ")", "xml", ".", "append"...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
get_credits
Extract credits from `AUTHORS.rst`
prepare_docs.py
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(): """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
[ "Extract", "credits", "from", "AUTHORS", ".", "rst" ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L30-L35
[ "def", "get_credits", "(", ")", ":", "credits", "=", "read", "(", "os", ".", "path", ".", "join", "(", "_HERE", ",", "\"AUTHORS.rst\"", ")", ")", ".", "split", "(", "\"\\n\"", ")", "from_index", "=", "credits", ".", "index", "(", "\"Active Contributors\"...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
rst2markdown_github
Converts ``rst`` to **markdown_github**, using :program:`pandoc` **Input** * ``FILE.rst`` **Output** * ``FILE.md``
prepare_docs.py
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"): """ Converts ``rst`` to **markdown_github**, using :program:`pandoc` **Input** * ``FILE.rst`` **Output** * ``FILE.md`` """ _proc = subprocess.Popen([pandoc, "-f", "rst", "-t", "m...
[ "Converts", "rst", "to", "**", "markdown_github", "**", "using", ":", "program", ":", "pandoc" ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L38-L79
[ "def", "rst2markdown_github", "(", "path_to_rst", ",", "path_to_md", ",", "pandoc", "=", "\"pandoc\"", ")", ":", "_proc", "=", "subprocess", ".", "Popen", "(", "[", "pandoc", ",", "\"-f\"", ",", "\"rst\"", ",", "\"-t\"", ",", "\"markdown_github\"", ",", "#\"...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
console_help2rst
Extract HELP information from ``<program> -h | --help`` message **Input** * ``$ <program> -h | --help`` * ``$ cd <cwd> && make help`` **Output** * ``docs/src/console_help_xy.rst``
prepare_docs.py
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): """ Extract HELP information from ``<program> -h | --help`` message **Input** * ``$ <program> -h | --help`` * ``$ cd <cwd> && make help`` **Output** * ``docs/src/console_he...
[ "Extract", "HELP", "information", "from", "<program", ">", "-", "h", "|", "--", "help", "message" ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L82-L150
[ "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", ...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
update_docs
Update documentation (ready for publishing new release) Usually called by ``make docs`` :param bool make_doc: generate DOC page from Makefile help messages
prepare_docs.py
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): """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...
[ "Update", "documentation", "(", "ready", "for", "publishing", "new", "release", ")" ]
markuskiller/textblob-de
python
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/prepare_docs.py#L153-L197
[ "def", "update_docs", "(", "readme", "=", "True", ",", "makefiles", "=", "True", ")", ":", "if", "readme", ":", "_pandoc", "=", "get_external_executable", "(", "\"pandoc\"", ")", "rst2markdown_github", "(", "os", ".", "path", ".", "join", "(", "_HERE", ","...
1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1
train
_NeqSysBase.rms
Returns root mean square value of f(x, params)
pyneqsys/core.py
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=()): """ 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...
[ "Returns", "root", "mean", "square", "value", "of", "f", "(", "x", "params", ")" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L79-L89
[ "def", "rms", "(", "self", ",", "x", ",", "params", "=", "(", ")", ")", ":", "internal_x", ",", "internal_params", "=", "self", ".", "pre_process", "(", "np", ".", "asarray", "(", "x", ")", ",", "np", ".", "asarray", "(", "params", ")", ")", "if"...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
_NeqSysBase.solve_series
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...
pyneqsys/core.py
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): """ Solve system for a set of parameters in which one is varied Parameters ---------- x0 : array_like Guess (subject to ``self.post_proc...
[ "Solve", "system", "for", "a", "set", "of", "parameters", "in", "which", "one", "is", "varied" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L91-L166
[ "def", "solve_series", "(", "self", ",", "x0", ",", "params", ",", "varied_data", ",", "varied_idx", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "propagate", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "x_...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
_NeqSysBase.plot_series
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 : ...
pyneqsys/core.py
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): """ 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 ...
[ "Plots", "the", "results", "from", ":", "meth", ":", "solve_series", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L168-L193
[ "def", "plot_series", "(", "self", ",", "xres", ",", "varied_data", ",", "varied_idx", ",", "*", "*", "kwargs", ")", ":", "for", "attr", "in", "'names latex_names'", ".", "split", "(", ")", ":", "if", "kwargs", ".", "get", "(", "attr", ",", "None", "...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
_NeqSysBase.plot_series_residuals
Analogous to :meth:`plot_series` but will plot residuals.
pyneqsys/core.py
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): """ 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,...
[ "Analogous", "to", ":", "meth", ":", "plot_series", "but", "will", "plot", "residuals", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L195-L204
[ "def", "plot_series_residuals", "(", "self", ",", "xres", ",", "varied_data", ",", "varied_idx", ",", "params", ",", "*", "*", "kwargs", ")", ":", "nf", "=", "len", "(", "self", ".", "f_cb", "(", "*", "self", ".", "pre_process", "(", "xres", "[", "0"...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
_NeqSysBase.plot_series_residuals_internal
Analogous to :meth:`plot_series` but for internal residuals from last run.
pyneqsys/core.py
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): """ 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...
[ "Analogous", "to", ":", "meth", ":", "plot_series", "but", "for", "internal", "residuals", "from", "last", "run", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L206-L213
[ "def", "plot_series_residuals_internal", "(", "self", ",", "varied_data", ",", "varied_idx", ",", "*", "*", "kwargs", ")", ":", "nf", "=", "len", "(", "self", ".", "f_cb", "(", "*", "self", ".", "pre_process", "(", "self", ".", "internal_xout", "[", "0",...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
_NeqSysBase.solve_and_plot_series
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.
pyneqsys/core.py
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): """ Solve and plot for a series of a varied parameter. Convenience method, see :meth:`solve_series`, :meth:`plot_series` & :me...
[ "Solve", "and", "plot", "for", "a", "series", "of", "a", "varied", "parameter", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L215-L233
[ "def", "solve_and_plot_series", "(", "self", ",", "x0", ",", "params", ",", "varied_data", ",", "varied_idx", ",", "solver", "=", "None", ",", "plot_kwargs", "=", "None", ",", "plot_residuals_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sol", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
NeqSys.pre_process
Used internally for transformation of variables.
pyneqsys/core.py
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=()): """ 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): ...
[ "Used", "internally", "for", "transformation", "of", "variables", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L318-L327
[ "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", "[", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
NeqSys.post_process
Used internally for transformation of variables.
pyneqsys/core.py
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): """ 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
[ "Used", "internally", "for", "transformation", "of", "variables", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L329-L334
[ "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", "...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
NeqSys.solve
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 ...
pyneqsys/core.py
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): """ Solve with user specified ``solver`` choice. Parameters ---------- x0: 1D array of floats Guess (subject to ``self.post_processors``) params: 1D array_like of floats ...
[ "Solve", "with", "user", "specified", "solver", "choice", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L336-L390
[ "def", "solve", "(", "self", ",", "x0", ",", "params", "=", "(", ")", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "attached_solver", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "solver", ","...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
NeqSys._solve_scipy
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 ...
pyneqsys/core.py
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): """ 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 ...
[ "Uses", "scipy", ".", "optimize", ".", "root" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L392-L426
[ "def", "_solve_scipy", "(", "self", ",", "intern_x0", ",", "tol", "=", "1e-8", ",", "method", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "scipy", ".", "optimize", "import", "root", "if", "method", "is", "None", ":", "if", "self", ".", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
ConditionalNeqSys.solve
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...
pyneqsys/core.py
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): """ Solve the problem (systems of equations) Parameters ---------- x0 : array Guess. params : array See :meth:`NeqSys.s...
[ "Solve", "the", "problem", "(", "systems", "of", "equations", ")" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/core.py#L626-L679
[ "def", "solve", "(", "self", ",", "x0", ",", "params", "=", "(", ")", ",", "internal_x0", "=", "None", ",", "solver", "=", "None", ",", "conditional_maxiter", "=", "20", ",", "initial_conditions", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if",...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
solve
Constructs a pyneqsys.symbolic.SymbolicSys instance and returns from its ``solve`` method.
examples/bi_dimensional.py
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'): """ 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 =...
[ "Constructs", "a", "pyneqsys", ".", "symbolic", ".", "SymbolicSys", "instance", "and", "returns", "from", "its", "solve", "method", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/examples/bi_dimensional.py#L13-L26
[ "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...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
main
Example demonstrating how to solve a system of non-linear equations defined as SymPy expressions. The example shows how a non-linear problem can be given a command-line interface which may be preferred by end-users who are not familiar with Python.
examples/bi_dimensional.py
def main(guess_a=1., guess_b=0., power=3, savetxt='None', verbose=False): """ Example demonstrating how to solve a system of non-linear equations defined as SymPy expressions. The example shows how a non-linear problem can be given a command-line interface which may be preferred by end-users who are no...
def main(guess_a=1., guess_b=0., power=3, savetxt='None', verbose=False): """ Example demonstrating how to solve a system of non-linear equations defined as SymPy expressions. The example shows how a non-linear problem can be given a command-line interface which may be preferred by end-users who are no...
[ "Example", "demonstrating", "how", "to", "solve", "a", "system", "of", "non", "-", "linear", "equations", "defined", "as", "SymPy", "expressions", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/examples/bi_dimensional.py#L29-L44
[ "def", "main", "(", "guess_a", "=", "1.", ",", "guess_b", "=", "0.", ",", "power", "=", "3", ",", "savetxt", "=", "'None'", ",", "verbose", "=", "False", ")", ":", "x", ",", "sol", "=", "solve", "(", "guess_a", ",", "guess_b", ",", "power", ")", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
plot_series
Plot the values of the solution vector vs the varied parameter. Parameters ---------- xres : array Solution vector of shape ``(varied_data.size, x0.size)``. varied_data : array Numerical values of the varied parameter. indices : iterable of integers, optional Indices of vari...
pyneqsys/plotting.py
def plot_series(xres, varied_data, indices=None, info=None, fail_vline=None, plot_kwargs_cb=None, ls=('-', '--', ':', '-.'), c=('k', 'r', 'g', 'b', 'c', 'm', 'y'), labels=None, ax=None, names=None, latex_names=None): """ Plot the values of the solution...
def plot_series(xres, varied_data, indices=None, info=None, fail_vline=None, plot_kwargs_cb=None, ls=('-', '--', ':', '-.'), c=('k', 'r', 'g', 'b', 'c', 'm', 'y'), labels=None, ax=None, names=None, latex_names=None): """ Plot the values of the solution...
[ "Plot", "the", "values", "of", "the", "solution", "vector", "vs", "the", "varied", "parameter", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/plotting.py#L4-L68
[ "def", "plot_series", "(", "xres", ",", "varied_data", ",", "indices", "=", "None", ",", "info", "=", "None", ",", "fail_vline", "=", "None", ",", "plot_kwargs_cb", "=", "None", ",", "ls", "=", "(", "'-'", ",", "'--'", ",", "':'", ",", "'-.'", ")", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
mpl_outside_legend
Places a legend box outside a matplotlib Axes instance.
pyneqsys/plotting.py
def mpl_outside_legend(ax, **kwargs): """ Places a legend box outside a matplotlib Axes instance. """ box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.75, box.height]) # Put a legend to the right of the current axis ax.legend(loc='upper left', bbox_to_anchor=(1, 1), **kwargs)
def mpl_outside_legend(ax, **kwargs): """ Places a legend box outside a matplotlib Axes instance. """ box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.75, box.height]) # Put a legend to the right of the current axis ax.legend(loc='upper left', bbox_to_anchor=(1, 1), **kwargs)
[ "Places", "a", "legend", "box", "outside", "a", "matplotlib", "Axes", "instance", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/plotting.py#L71-L76
[ "def", "mpl_outside_legend", "(", "ax", ",", "*", "*", "kwargs", ")", ":", "box", "=", "ax", ".", "get_position", "(", ")", "ax", ".", "set_position", "(", "[", "box", ".", "x0", ",", "box", ".", "y0", ",", "box", ".", "width", "*", "0.75", ",", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
linear_rref
Transform a linear system to reduced row-echelon form Transforms both the matrix and right-hand side of a linear system of equations to reduced row echelon form Parameters ---------- A : Matrix-like Iterable of rows. b : iterable Returns ------- A', b' - transformed versio...
pyneqsys/symbolic.py
def linear_rref(A, b, Matrix=None, S=None): """ Transform a linear system to reduced row-echelon form Transforms both the matrix and right-hand side of a linear system of equations to reduced row echelon form Parameters ---------- A : Matrix-like Iterable of rows. b : iterable ...
def linear_rref(A, b, Matrix=None, S=None): """ Transform a linear system to reduced row-echelon form Transforms both the matrix and right-hand side of a linear system of equations to reduced row echelon form Parameters ---------- A : Matrix-like Iterable of rows. b : iterable ...
[ "Transform", "a", "linear", "system", "to", "reduced", "row", "-", "echelon", "form" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/symbolic.py#L284-L309
[ "def", "linear_rref", "(", "A", ",", "b", ",", "Matrix", "=", "None", ",", "S", "=", "None", ")", ":", "if", "Matrix", "is", "None", ":", "from", "sympy", "import", "Matrix", "if", "S", "is", "None", ":", "from", "sympy", "import", "S", "mat_rows",...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
linear_exprs
Returns Ax - b Parameters ---------- A : matrix_like of numbers Of shape (len(b), len(x)). x : iterable of symbols b : array_like of numbers (default: None) When ``None``, assume zeros of length ``len(x)``. Matrix : class When ``rref == True``: A matrix class which suppo...
pyneqsys/symbolic.py
def linear_exprs(A, x, b=None, rref=False, Matrix=None): """ Returns Ax - b Parameters ---------- A : matrix_like of numbers Of shape (len(b), len(x)). x : iterable of symbols b : array_like of numbers (default: None) When ``None``, assume zeros of length ``len(x)``. Matrix ...
def linear_exprs(A, x, b=None, rref=False, Matrix=None): """ Returns Ax - b Parameters ---------- A : matrix_like of numbers Of shape (len(b), len(x)). x : iterable of symbols b : array_like of numbers (default: None) When ``None``, assume zeros of length ``len(x)``. Matrix ...
[ "Returns", "Ax", "-", "b" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/symbolic.py#L312-L342
[ "def", "linear_exprs", "(", "A", ",", "x", ",", "b", "=", "None", ",", "rref", "=", "False", ",", "Matrix", "=", "None", ")", ":", "if", "b", "is", "None", ":", "b", "=", "[", "0", "]", "*", "len", "(", "x", ")", "if", "rref", ":", "rA", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
SymbolicSys.from_callback
Generate a SymbolicSys instance from a callback. Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. nx : int Number of unknowns, when not given it is deduced from ``kwargs['names']``. nparams : int ...
pyneqsys/symbolic.py
def from_callback(cls, cb, nx=None, nparams=None, **kwargs): """ Generate a SymbolicSys instance from a callback. Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. nx : int Number of unknowns, when not g...
def from_callback(cls, cb, nx=None, nparams=None, **kwargs): """ Generate a SymbolicSys instance from a callback. Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. nx : int Number of unknowns, when not g...
[ "Generate", "a", "SymbolicSys", "instance", "from", "a", "callback", "." ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/symbolic.py#L88-L141
[ "def", "from_callback", "(", "cls", ",", "cb", ",", "nx", "=", "None", ",", "nparams", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'x_by_name'", ",", "False", ")", ":", "if", "'names'", "not", "in", "kwargs", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
SymbolicSys.get_jac
Return the jacobian of the expressions
pyneqsys/symbolic.py
def get_jac(self): """ Return the jacobian of the expressions """ if self._jac is True: if self.band is None: f = self.be.Matrix(self.nf, 1, self.exprs) _x = self.be.Matrix(self.nx, 1, self.x) return f.jacobian(_x) else: ...
def get_jac(self): """ Return the jacobian of the expressions """ if self._jac is True: if self.band is None: f = self.be.Matrix(self.nf, 1, self.exprs) _x = self.be.Matrix(self.nx, 1, self.x) return f.jacobian(_x) else: ...
[ "Return", "the", "jacobian", "of", "the", "expressions" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/symbolic.py#L143-L157
[ "def", "get_jac", "(", "self", ")", ":", "if", "self", ".", "_jac", "is", "True", ":", "if", "self", ".", "band", "is", "None", ":", "f", "=", "self", ".", "be", ".", "Matrix", "(", "self", ".", "nf", ",", "1", ",", "self", ".", "exprs", ")",...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
TransformedSys.from_callback
Generate a TransformedSys instance from a callback Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. The callback ``cb`` should return *untransformed* expressions. transf_cbs : pair or iterable of pairs of calla...
pyneqsys/symbolic.py
def from_callback(cls, cb, transf_cbs, nx, nparams=0, pre_adj=None, **kwargs): """ Generate a TransformedSys instance from a callback Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. The c...
def from_callback(cls, cb, transf_cbs, nx, nparams=0, pre_adj=None, **kwargs): """ Generate a TransformedSys instance from a callback Parameters ---------- cb : callable Should have the signature ``cb(x, p, backend) -> list of exprs``. The c...
[ "Generate", "a", "TransformedSys", "instance", "from", "a", "callback" ]
bjodah/pyneqsys
python
https://github.com/bjodah/pyneqsys/blob/1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77/pyneqsys/symbolic.py#L232-L281
[ "def", "from_callback", "(", "cls", ",", "cb", ",", "transf_cbs", ",", "nx", ",", "nparams", "=", "0", ",", "pre_adj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "be", "=", "Backend", "(", "kwargs", ".", "pop", "(", "'backend'", ",", "None", ...
1c8f2fe1ab2b6cc6cb55b7a1328aca2e3a3c5c77
train
Header.write
Write binary header data to a file handle. This method writes exactly 512 bytes to the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and then 512 bytes will be written to d...
c3d.py
def write(self, handle): '''Write binary header data to a file handle. This method writes exactly 512 bytes to the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and then 512 by...
def write(self, handle): '''Write binary header data to a file handle. This method writes exactly 512 bytes to the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and then 512 by...
[ "Write", "binary", "header", "data", "to", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L89-L118
[ "def", "write", "(", "self", ",", "handle", ")", ":", "handle", ".", "seek", "(", "0", ")", "handle", ".", "write", "(", "struct", ".", "pack", "(", "self", ".", "BINARY_FORMAT", ",", "self", ".", "parameter_block", ",", "0x50", ",", "self", ".", "...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Header.read
Read and parse binary header data from a file handle. This method reads exactly 512 bytes from the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and then 512 bytes will be ...
c3d.py
def read(self, handle): '''Read and parse binary header data from a file handle. This method reads exactly 512 bytes from the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and ...
def read(self, handle): '''Read and parse binary header data from a file handle. This method reads exactly 512 bytes from the beginning of the given file handle. Parameters ---------- handle : file handle The given handle will be reset to 0 using `seek` and ...
[ "Read", "and", "parse", "binary", "header", "data", "from", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L136-L171
[ "def", "read", "(", "self", ",", "handle", ")", ":", "handle", ".", "seek", "(", "0", ")", "(", "self", ".", "parameter_block", ",", "magic", ",", "self", ".", "point_count", ",", "self", ".", "analog_count", ",", "self", ".", "first_frame", ",", "se...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param.binary_size
Return the number of bytes needed to store this parameter.
c3d.py
def binary_size(self): '''Return the number of bytes needed to store this parameter.''' return ( 1 + # group_id 2 + # next offset marker 1 + len(self.name.encode('utf-8')) + # size of name and name bytes 1 + # data size 1 + len(self.dimensions)...
def binary_size(self): '''Return the number of bytes needed to store this parameter.''' return ( 1 + # group_id 2 + # next offset marker 1 + len(self.name.encode('utf-8')) + # size of name and name bytes 1 + # data size 1 + len(self.dimensions)...
[ "Return", "the", "number", "of", "bytes", "needed", "to", "store", "this", "parameter", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L227-L237
[ "def", "binary_size", "(", "self", ")", ":", "return", "(", "1", "+", "# group_id", "2", "+", "# next offset marker", "1", "+", "len", "(", "self", ".", "name", ".", "encode", "(", "'utf-8'", ")", ")", "+", "# size of name and name bytes", "1", "+", "# d...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param.write
Write binary data for this parameter to a file handle. Parameters ---------- group_id : int The numerical ID of the group that holds this parameter. handle : file handle An open, writable, binary file handle.
c3d.py
def write(self, group_id, handle): '''Write binary data for this parameter to a file handle. Parameters ---------- group_id : int The numerical ID of the group that holds this parameter. handle : file handle An open, writable, binary file handle. ...
def write(self, group_id, handle): '''Write binary data for this parameter to a file handle. Parameters ---------- group_id : int The numerical ID of the group that holds this parameter. handle : file handle An open, writable, binary file handle. ...
[ "Write", "binary", "data", "for", "this", "parameter", "to", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L239-L260
[ "def", "write", "(", "self", ",", "group_id", ",", "handle", ")", ":", "name", "=", "self", ".", "name", ".", "encode", "(", "'utf-8'", ")", "handle", ".", "write", "(", "struct", ".", "pack", "(", "'bb'", ",", "len", "(", "name", ")", ",", "grou...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param.read
Read binary data for this parameter from a file handle. This reads exactly enough data from the current position in the file to initialize the parameter.
c3d.py
def read(self, handle): '''Read binary data for this parameter from a file handle. This reads exactly enough data from the current position in the file to initialize the parameter. ''' self.bytes_per_element, = struct.unpack('b', handle.read(1)) dims, = struct.unpack('B'...
def read(self, handle): '''Read binary data for this parameter from a file handle. This reads exactly enough data from the current position in the file to initialize the parameter. ''' self.bytes_per_element, = struct.unpack('b', handle.read(1)) dims, = struct.unpack('B'...
[ "Read", "binary", "data", "for", "this", "parameter", "from", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L262-L275
[ "def", "read", "(", "self", ",", "handle", ")", ":", "self", ".", "bytes_per_element", ",", "=", "struct", ".", "unpack", "(", "'b'", ",", "handle", ".", "read", "(", "1", ")", ")", "dims", ",", "=", "struct", ".", "unpack", "(", "'B'", ",", "han...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param._as_array
Unpack the raw bytes of this param using the given data format.
c3d.py
def _as_array(self, fmt): '''Unpack the raw bytes of this param using the given data format.''' assert self.dimensions, \ '{}: cannot get value as {} array!'.format(self.name, fmt) elems = array.array(fmt) elems.fromstring(self.bytes) return np.array(elems).reshape(se...
def _as_array(self, fmt): '''Unpack the raw bytes of this param using the given data format.''' assert self.dimensions, \ '{}: cannot get value as {} array!'.format(self.name, fmt) elems = array.array(fmt) elems.fromstring(self.bytes) return np.array(elems).reshape(se...
[ "Unpack", "the", "raw", "bytes", "of", "this", "param", "using", "the", "given", "data", "format", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L326-L332
[ "def", "_as_array", "(", "self", ",", "fmt", ")", ":", "assert", "self", ".", "dimensions", ",", "'{}: cannot get value as {} array!'", ".", "format", "(", "self", ".", "name", ",", "fmt", ")", "elems", "=", "array", ".", "array", "(", "fmt", ")", "elems...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param.bytes_array
Get the param as an array of raw byte strings.
c3d.py
def bytes_array(self): '''Get the param as an array of raw byte strings.''' assert len(self.dimensions) == 2, \ '{}: cannot get value as bytes array!'.format(self.name) l, n = self.dimensions return [self.bytes[i*l:(i+1)*l] for i in range(n)]
def bytes_array(self): '''Get the param as an array of raw byte strings.''' assert len(self.dimensions) == 2, \ '{}: cannot get value as bytes array!'.format(self.name) l, n = self.dimensions return [self.bytes[i*l:(i+1)*l] for i in range(n)]
[ "Get", "the", "param", "as", "an", "array", "of", "raw", "byte", "strings", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L370-L375
[ "def", "bytes_array", "(", "self", ")", ":", "assert", "len", "(", "self", ".", "dimensions", ")", "==", "2", ",", "'{}: cannot get value as bytes array!'", ".", "format", "(", "self", ".", "name", ")", "l", ",", "n", "=", "self", ".", "dimensions", "ret...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Param.string_array
Get the param as a array of unicode strings.
c3d.py
def string_array(self): '''Get the param as a array of unicode strings.''' assert len(self.dimensions) == 2, \ '{}: cannot get value as string array!'.format(self.name) l, n = self.dimensions return [self.bytes[i*l:(i+1)*l].decode('utf-8') for i in range(n)]
def string_array(self): '''Get the param as a array of unicode strings.''' assert len(self.dimensions) == 2, \ '{}: cannot get value as string array!'.format(self.name) l, n = self.dimensions return [self.bytes[i*l:(i+1)*l].decode('utf-8') for i in range(n)]
[ "Get", "the", "param", "as", "a", "array", "of", "unicode", "strings", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L378-L383
[ "def", "string_array", "(", "self", ")", ":", "assert", "len", "(", "self", ".", "dimensions", ")", "==", "2", ",", "'{}: cannot get value as string array!'", ".", "format", "(", "self", ".", "name", ")", "l", ",", "n", "=", "self", ".", "dimensions", "r...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Group.add_param
Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param` constructor.
c3d.py
def add_param(self, name, **kwargs): '''Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param`...
def add_param(self, name, **kwargs): '''Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param`...
[ "Add", "a", "parameter", "to", "this", "group", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L425-L436
[ "def", "add_param", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "self", ".", "params", "[", "name", ".", "upper", "(", ")", "]", "=", "Param", "(", "name", ".", "upper", "(", ")", ",", "*", "*", "kwargs", ")" ]
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Group.binary_size
Return the number of bytes to store this group and its parameters.
c3d.py
def binary_size(self): '''Return the number of bytes to store this group and its parameters.''' return ( 1 + # group_id 1 + len(self.name.encode('utf-8')) + # size of name and name bytes 2 + # next offset marker 1 + len(self.desc.encode('utf-8')) + # size ...
def binary_size(self): '''Return the number of bytes to store this group and its parameters.''' return ( 1 + # group_id 1 + len(self.name.encode('utf-8')) + # size of name and name bytes 2 + # next offset marker 1 + len(self.desc.encode('utf-8')) + # size ...
[ "Return", "the", "number", "of", "bytes", "to", "store", "this", "group", "and", "its", "parameters", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L438-L445
[ "def", "binary_size", "(", "self", ")", ":", "return", "(", "1", "+", "# group_id", "1", "+", "len", "(", "self", ".", "name", ".", "encode", "(", "'utf-8'", ")", ")", "+", "# size of name and name bytes", "2", "+", "# next offset marker", "1", "+", "len...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Group.write
Write this parameter group, with parameters, to a file handle. Parameters ---------- group_id : int The numerical ID of the group. handle : file handle An open, writable, binary file handle.
c3d.py
def write(self, group_id, handle): '''Write this parameter group, with parameters, to a file handle. Parameters ---------- group_id : int The numerical ID of the group. handle : file handle An open, writable, binary file handle. ''' name =...
def write(self, group_id, handle): '''Write this parameter group, with parameters, to a file handle. Parameters ---------- group_id : int The numerical ID of the group. handle : file handle An open, writable, binary file handle. ''' name =...
[ "Write", "this", "parameter", "group", "with", "parameters", "to", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L447-L465
[ "def", "write", "(", "self", ",", "group_id", ",", "handle", ")", ":", "name", "=", "self", ".", "name", ".", "encode", "(", "'utf-8'", ")", "desc", "=", "self", ".", "desc", ".", "encode", "(", "'utf-8'", ")", "handle", ".", "write", "(", "struct"...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Manager.check_metadata
Ensure that the metadata in our file is self-consistent.
c3d.py
def check_metadata(self): '''Ensure that the metadata in our file is self-consistent.''' assert self.header.point_count == self.point_used, ( 'inconsistent point count! {} header != {} POINT:USED'.format( self.header.point_count, self.point_used, )...
def check_metadata(self): '''Ensure that the metadata in our file is self-consistent.''' assert self.header.point_count == self.point_used, ( 'inconsistent point count! {} header != {} POINT:USED'.format( self.header.point_count, self.point_used, )...
[ "Ensure", "that", "the", "metadata", "in", "our", "file", "is", "self", "-", "consistent", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L522-L566
[ "def", "check_metadata", "(", "self", ")", ":", "assert", "self", ".", "header", ".", "point_count", "==", "self", ".", "point_used", ",", "(", "'inconsistent point count! {} header != {} POINT:USED'", ".", "format", "(", "self", ".", "header", ".", "point_count",...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Manager.add_group
Add a new parameter group. Parameters ---------- group_id : int The numeric ID for a group to check or create. name : str, optional If a group is created, assign this name to the group. desc : str, optional If a group is created, assign this d...
c3d.py
def add_group(self, group_id, name, desc): '''Add a new parameter group. Parameters ---------- group_id : int The numeric ID for a group to check or create. name : str, optional If a group is created, assign this name to the group. desc : str, opt...
def add_group(self, group_id, name, desc): '''Add a new parameter group. Parameters ---------- group_id : int The numeric ID for a group to check or create. name : str, optional If a group is created, assign this name to the group. desc : str, opt...
[ "Add", "a", "new", "parameter", "group", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L568-L596
[ "def", "add_group", "(", "self", ",", "group_id", ",", "name", ",", "desc", ")", ":", "if", "group_id", "in", "self", ".", "groups", ":", "raise", "KeyError", "(", "group_id", ")", "name", "=", "name", ".", "upper", "(", ")", "if", "name", "in", "s...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Manager.get
Get a group or parameter. Parameters ---------- group : str If this string contains a period (.), then the part before the period will be used to retrieve a group, and the part after the period will be used to retrieve a parameter from that group. If this ...
c3d.py
def get(self, group, default=None): '''Get a group or parameter. Parameters ---------- group : str If this string contains a period (.), then the part before the period will be used to retrieve a group, and the part after the period will be used to re...
def get(self, group, default=None): '''Get a group or parameter. Parameters ---------- group : str If this string contains a period (.), then the part before the period will be used to retrieve a group, and the part after the period will be used to re...
[ "Get", "a", "group", "or", "parameter", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L598-L631
[ "def", "get", "(", "self", ",", "group", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "group", ",", "int", ")", ":", "return", "self", ".", "groups", ".", "get", "(", "group", ",", "default", ")", "group", "=", "group", ".", "u...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Manager.parameter_blocks
Compute the size (in 512B blocks) of the parameter section.
c3d.py
def parameter_blocks(self): '''Compute the size (in 512B blocks) of the parameter section.''' bytes = 4. + sum(g.binary_size() for g in self.groups.values()) return int(np.ceil(bytes / 512))
def parameter_blocks(self): '''Compute the size (in 512B blocks) of the parameter section.''' bytes = 4. + sum(g.binary_size() for g in self.groups.values()) return int(np.ceil(bytes / 512))
[ "Compute", "the", "size", "(", "in", "512B", "blocks", ")", "of", "the", "parameter", "section", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L669-L672
[ "def", "parameter_blocks", "(", "self", ")", ":", "bytes", "=", "4.", "+", "sum", "(", "g", ".", "binary_size", "(", ")", "for", "g", "in", "self", ".", "groups", ".", "values", "(", ")", ")", "return", "int", "(", "np", ".", "ceil", "(", "bytes"...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Reader.read_frames
Iterate over the data frames from our C3D file handle. Parameters ---------- copy : bool If False, the reader returns a reference to the same data buffers for every frame. The default is True, which causes the reader to return a unique data buffer for each fr...
c3d.py
def read_frames(self, copy=True): '''Iterate over the data frames from our C3D file handle. Parameters ---------- copy : bool If False, the reader returns a reference to the same data buffers for every frame. The default is True, which causes the reader to ...
def read_frames(self, copy=True): '''Iterate over the data frames from our C3D file handle. Parameters ---------- copy : bool If False, the reader returns a reference to the same data buffers for every frame. The default is True, which causes the reader to ...
[ "Iterate", "over", "the", "data", "frames", "from", "our", "C3D", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L804-L899
[ "def", "read_frames", "(", "self", ",", "copy", "=", "True", ")", ":", "scale", "=", "abs", "(", "self", ".", "point_scale", ")", "is_float", "=", "self", ".", "point_scale", "<", "0", "point_bytes", "=", "[", "2", ",", "4", "]", "[", "is_float", "...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Writer._pad_block
Pad the file with 0s to the end of the next block boundary.
c3d.py
def _pad_block(self, handle): '''Pad the file with 0s to the end of the next block boundary.''' extra = handle.tell() % 512 if extra: handle.write(b'\x00' * (512 - extra))
def _pad_block(self, handle): '''Pad the file with 0s to the end of the next block boundary.''' extra = handle.tell() % 512 if extra: handle.write(b'\x00' * (512 - extra))
[ "Pad", "the", "file", "with", "0s", "to", "the", "end", "of", "the", "next", "block", "boundary", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L956-L960
[ "def", "_pad_block", "(", "self", ",", "handle", ")", ":", "extra", "=", "handle", ".", "tell", "(", ")", "%", "512", "if", "extra", ":", "handle", ".", "write", "(", "b'\\x00'", "*", "(", "512", "-", "extra", ")", ")" ]
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Writer._write_metadata
Write metadata to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle.
c3d.py
def _write_metadata(self, handle): '''Write metadata to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' self.check_metadata() # he...
def _write_metadata(self, handle): '''Write metadata to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' self.check_metadata() # he...
[ "Write", "metadata", "to", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L962-L989
[ "def", "_write_metadata", "(", "self", ",", "handle", ")", ":", "self", ".", "check_metadata", "(", ")", "# header", "self", ".", "header", ".", "write", "(", "handle", ")", "self", ".", "_pad_block", "(", "handle", ")", "assert", "handle", ".", "tell", ...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Writer._write_frames
Write our frame data to the given file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle.
c3d.py
def _write_frames(self, handle): '''Write our frame data to the given file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' assert handle.tell() ==...
def _write_frames(self, handle): '''Write our frame data to the given file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' assert handle.tell() ==...
[ "Write", "our", "frame", "data", "to", "the", "given", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L991-L1021
[ "def", "_write_frames", "(", "self", ",", "handle", ")", ":", "assert", "handle", ".", "tell", "(", ")", "==", "512", "*", "(", "self", ".", "header", ".", "data_block", "-", "1", ")", "scale", "=", "abs", "(", "self", ".", "point_scale", ")", "is_...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
Writer.write
Write metadata and point + analog frames to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle.
c3d.py
def write(self, handle): '''Write metadata and point + analog frames to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' if not self._frames...
def write(self, handle): '''Write metadata and point + analog frames to a file handle. Parameters ---------- handle : file Write metadata and C3D motion frames to the given file handle. The writer does not close the handle. ''' if not self._frames...
[ "Write", "metadata", "and", "point", "+", "analog", "frames", "to", "a", "file", "handle", "." ]
EmbodiedCognition/py-c3d
python
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L1023-L1094
[ "def", "write", "(", "self", ",", "handle", ")", ":", "if", "not", "self", ".", "_frames", ":", "return", "def", "add", "(", "name", ",", "desc", ",", "bpe", ",", "format", ",", "bytes", ",", "*", "dimensions", ")", ":", "group", ".", "add_param", ...
391493d9cb4c6b4aaeee4de2930685e3a67f5845
train
SQLite3Helper.aggregate_per_prefix
Given a time range aggregates bytes per prefix. Args: start_time: A string representing the starting time of the time range end_time: A string representing the ending time of the time range limit: An optional integer. If it's >0 it will limit the amount of pr...
sir/helpers/SQLite3Helper.py
def aggregate_per_prefix(self, start_time, end_time, limit=0, net_masks='', exclude_net_masks=False, filter_proto=None): """ Given a time range aggregates bytes per prefix. Args: start_time: A string representing the starting time of the time range end_time: A string...
def aggregate_per_prefix(self, start_time, end_time, limit=0, net_masks='', exclude_net_masks=False, filter_proto=None): """ Given a time range aggregates bytes per prefix. Args: start_time: A string representing the starting time of the time range end_time: A string...
[ "Given", "a", "time", "range", "aggregates", "bytes", "per", "prefix", "." ]
dbarrosop/sir
python
https://github.com/dbarrosop/sir/blob/c1f4c086404b8474f0a560fcc6f49aa4c86f6916/sir/helpers/SQLite3Helper.py#L43-L91
[ "def", "aggregate_per_prefix", "(", "self", ",", "start_time", ",", "end_time", ",", "limit", "=", "0", ",", "net_masks", "=", "''", ",", "exclude_net_masks", "=", "False", ",", "filter_proto", "=", "None", ")", ":", "if", "net_masks", "==", "''", ":", "...
c1f4c086404b8474f0a560fcc6f49aa4c86f6916
train
SQLite3Helper.aggregate_per_as
Given a time range aggregates bytes per ASNs. Args: start_time: A string representing the starting time of the time range end_time: A string representing the ending time of the time range Returns: A list of prefixes sorted by sum_bytes. For examp...
sir/helpers/SQLite3Helper.py
def aggregate_per_as(self, start_time, end_time): """ Given a time range aggregates bytes per ASNs. Args: start_time: A string representing the starting time of the time range end_time: A string representing the ending time of the time range Returns: ...
def aggregate_per_as(self, start_time, end_time): """ Given a time range aggregates bytes per ASNs. Args: start_time: A string representing the starting time of the time range end_time: A string representing the ending time of the time range Returns: ...
[ "Given", "a", "time", "range", "aggregates", "bytes", "per", "ASNs", "." ]
dbarrosop/sir
python
https://github.com/dbarrosop/sir/blob/c1f4c086404b8474f0a560fcc6f49aa4c86f6916/sir/helpers/SQLite3Helper.py#L93-L118
[ "def", "aggregate_per_as", "(", "self", ",", "start_time", ",", "end_time", ")", ":", "query", "=", "''' SELECT as_dst as key, SUM(bytes) as sum_bytes\n from acct\n WHERE\n datetime(stamp_updated) BETWEEN datetime(?) AND datetime(?, \"...
c1f4c086404b8474f0a560fcc6f49aa4c86f6916
train
_workaround_no_vector_images
Replace vector images with fake ones.
kurt/plugin.py
def _workaround_no_vector_images(project): """Replace vector images with fake ones.""" RED = (255, 0, 0) PLACEHOLDER = kurt.Image.new((32, 32), RED) for scriptable in [project.stage] + project.sprites: for costume in scriptable.costumes: if costume.image.format == "SVG": ...
def _workaround_no_vector_images(project): """Replace vector images with fake ones.""" RED = (255, 0, 0) PLACEHOLDER = kurt.Image.new((32, 32), RED) for scriptable in [project.stage] + project.sprites: for costume in scriptable.costumes: if costume.image.format == "SVG": ...
[ "Replace", "vector", "images", "with", "fake", "ones", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L313-L321
[ "def", "_workaround_no_vector_images", "(", "project", ")", ":", "RED", "=", "(", "255", ",", "0", ",", "0", ")", "PLACEHOLDER", "=", "kurt", ".", "Image", ".", "new", "(", "(", "32", ",", "32", ")", ",", "RED", ")", "for", "scriptable", "in", "[",...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
_workaround_no_stage_specific_variables
Make Stage-specific variables global (move them to Project).
kurt/plugin.py
def _workaround_no_stage_specific_variables(project): """Make Stage-specific variables global (move them to Project).""" for (name, var) in project.stage.variables.items(): yield "variable %s" % name for (name, _list) in project.stage.lists.items(): yield "list %s" % name project.variabl...
def _workaround_no_stage_specific_variables(project): """Make Stage-specific variables global (move them to Project).""" for (name, var) in project.stage.variables.items(): yield "variable %s" % name for (name, _list) in project.stage.lists.items(): yield "list %s" % name project.variabl...
[ "Make", "Stage", "-", "specific", "variables", "global", "(", "move", "them", "to", "Project", ")", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L328-L337
[ "def", "_workaround_no_stage_specific_variables", "(", "project", ")", ":", "for", "(", "name", ",", "var", ")", "in", "project", ".", "stage", ".", "variables", ".", "items", "(", ")", ":", "yield", "\"variable %s\"", "%", "name", "for", "(", "name", ",",...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
Kurt.register
Register a new :class:`KurtPlugin`. Once registered, the plugin can be used by :class:`Project`, when: * :attr:`Project.load` sees a file with the right extension * :attr:`Project.convert` is called with the format as a parameter
kurt/plugin.py
def register(cls, plugin): """Register a new :class:`KurtPlugin`. Once registered, the plugin can be used by :class:`Project`, when: * :attr:`Project.load` sees a file with the right extension * :attr:`Project.convert` is called with the format as a parameter """ cls....
def register(cls, plugin): """Register a new :class:`KurtPlugin`. Once registered, the plugin can be used by :class:`Project`, when: * :attr:`Project.load` sees a file with the right extension * :attr:`Project.convert` is called with the format as a parameter """ cls....
[ "Register", "a", "new", ":", "class", ":", "KurtPlugin", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L150-L185
[ "def", "register", "(", "cls", ",", "plugin", ")", ":", "cls", ".", "plugins", "[", "plugin", ".", "name", "]", "=", "plugin", "# make features", "plugin", ".", "features", "=", "map", "(", "Feature", ".", "get", ",", "plugin", ".", "features", ")", ...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
Kurt.get_plugin
Returns the first format plugin whose attributes match kwargs. For example:: get_plugin(extension="scratch14") Will return the :class:`KurtPlugin` whose :attr:`extension <KurtPlugin.extension>` attribute is ``"scratch14"``. The :attr:`name <KurtPlugin.name>` is used as th...
kurt/plugin.py
def get_plugin(cls, name=None, **kwargs): """Returns the first format plugin whose attributes match kwargs. For example:: get_plugin(extension="scratch14") Will return the :class:`KurtPlugin` whose :attr:`extension <KurtPlugin.extension>` attribute is ``"scratch14"``. ...
def get_plugin(cls, name=None, **kwargs): """Returns the first format plugin whose attributes match kwargs. For example:: get_plugin(extension="scratch14") Will return the :class:`KurtPlugin` whose :attr:`extension <KurtPlugin.extension>` attribute is ``"scratch14"``. ...
[ "Returns", "the", "first", "format", "plugin", "whose", "attributes", "match", "kwargs", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L188-L223
[ "def", "get_plugin", "(", "cls", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "name", ",", "KurtPlugin", ")", ":", "return", "name", "if", "'extension'", "in", "kwargs", ":", "kwargs", "[", "'extension'", "]", ...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
Kurt.block_by_command
Return the block with the given :attr:`command`. Returns None if the block is not found.
kurt/plugin.py
def block_by_command(cls, command): """Return the block with the given :attr:`command`. Returns None if the block is not found. """ for block in cls.blocks: if block.has_command(command): return block
def block_by_command(cls, command): """Return the block with the given :attr:`command`. Returns None if the block is not found. """ for block in cls.blocks: if block.has_command(command): return block
[ "Return", "the", "block", "with", "the", "given", ":", "attr", ":", "command", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L226-L234
[ "def", "block_by_command", "(", "cls", ",", "command", ")", ":", "for", "block", "in", "cls", ".", "blocks", ":", "if", "block", ".", "has_command", "(", "command", ")", ":", "return", "block" ]
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
Kurt.blocks_by_text
Return a list of blocks matching the given :attr:`text`. Capitalisation and spaces are ignored.
kurt/plugin.py
def blocks_by_text(cls, text): """Return a list of blocks matching the given :attr:`text`. Capitalisation and spaces are ignored. """ text = kurt.BlockType._strip_text(text) matches = [] for block in cls.blocks: for pbt in block.conversions: ...
def blocks_by_text(cls, text): """Return a list of blocks matching the given :attr:`text`. Capitalisation and spaces are ignored. """ text = kurt.BlockType._strip_text(text) matches = [] for block in cls.blocks: for pbt in block.conversions: ...
[ "Return", "a", "list", "of", "blocks", "matching", "the", "given", ":", "attr", ":", "text", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/plugin.py#L237-L250
[ "def", "blocks_by_text", "(", "cls", ",", "text", ")", ":", "text", "=", "kurt", ".", "BlockType", ".", "_strip_text", "(", "text", ")", "matches", "=", "[", "]", "for", "block", "in", "cls", ".", "blocks", ":", "for", "pbt", "in", "block", ".", "c...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
clean_up
Clean up the given list of scripts in-place so none of the scripts overlap.
kurt/scratch14/heights.py
def clean_up(scripts): """Clean up the given list of scripts in-place so none of the scripts overlap. """ scripts_with_pos = [s for s in scripts if s.pos] scripts_with_pos.sort(key=lambda s: (s.pos[1], s.pos[0])) scripts = scripts_with_pos + [s for s in scripts if not s.pos] y = 20 for...
def clean_up(scripts): """Clean up the given list of scripts in-place so none of the scripts overlap. """ scripts_with_pos = [s for s in scripts if s.pos] scripts_with_pos.sort(key=lambda s: (s.pos[1], s.pos[0])) scripts = scripts_with_pos + [s for s in scripts if not s.pos] y = 20 for...
[ "Clean", "up", "the", "given", "list", "of", "scripts", "in", "-", "place", "so", "none", "of", "the", "scripts", "overlap", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/heights.py#L106-L122
[ "def", "clean_up", "(", "scripts", ")", ":", "scripts_with_pos", "=", "[", "s", "for", "s", "in", "scripts", "if", "s", ".", "pos", "]", "scripts_with_pos", ".", "sort", "(", "key", "=", "lambda", "s", ":", "(", "s", ".", "pos", "[", "1", "]", ",...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
obj_classes_from_module
Return a list of classes in a module that have a 'classID' attribute.
kurt/scratch14/objtable.py
def obj_classes_from_module(module): """Return a list of classes in a module that have a 'classID' attribute.""" for name in dir(module): if not name.startswith('_'): cls = getattr(module, name) if getattr(cls, 'classID', None): yield (name, cls)
def obj_classes_from_module(module): """Return a list of classes in a module that have a 'classID' attribute.""" for name in dir(module): if not name.startswith('_'): cls = getattr(module, name) if getattr(cls, 'classID', None): yield (name, cls)
[ "Return", "a", "list", "of", "classes", "in", "a", "module", "that", "have", "a", "classID", "attribute", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L82-L88
[ "def", "obj_classes_from_module", "(", "module", ")", ":", "for", "name", "in", "dir", "(", "module", ")", ":", "if", "not", "name", ".", "startswith", "(", "'_'", ")", ":", "cls", "=", "getattr", "(", "module", ",", "name", ")", "if", "getattr", "("...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
decode_network
Return root object from ref-containing obj table entries
kurt/scratch14/objtable.py
def decode_network(objects): """Return root object from ref-containing obj table entries""" def resolve_ref(obj, objects=objects): if isinstance(obj, Ref): # first entry is 1 return objects[obj.index - 1] else: return obj # Reading the ObjTable backwards ...
def decode_network(objects): """Return root object from ref-containing obj table entries""" def resolve_ref(obj, objects=objects): if isinstance(obj, Ref): # first entry is 1 return objects[obj.index - 1] else: return obj # Reading the ObjTable backwards ...
[ "Return", "root", "object", "from", "ref", "-", "containing", "obj", "table", "entries" ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L251-L298
[ "def", "decode_network", "(", "objects", ")", ":", "def", "resolve_ref", "(", "obj", ",", "objects", "=", "objects", ")", ":", "if", "isinstance", "(", "obj", ",", "Ref", ")", ":", "# first entry is 1", "return", "objects", "[", "obj", ".", "index", "-",...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
encode_network
Yield ref-containing obj table entries from object network
kurt/scratch14/objtable.py
def encode_network(root): """Yield ref-containing obj table entries from object network""" orig_objects = [] objects = [] def get_ref(value, objects=objects): """Returns the index of the given object in the object table, adding it if needed. """ value = PythonicAdapter(...
def encode_network(root): """Yield ref-containing obj table entries from object network""" orig_objects = [] objects = [] def get_ref(value, objects=objects): """Returns the index of the given object in the object table, adding it if needed. """ value = PythonicAdapter(...
[ "Yield", "ref", "-", "containing", "obj", "table", "entries", "from", "object", "network" ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L300-L381
[ "def", "encode_network", "(", "root", ")", ":", "orig_objects", "=", "[", "]", "objects", "=", "[", "]", "def", "get_ref", "(", "value", ",", "objects", "=", "objects", ")", ":", "\"\"\"Returns the index of the given object in the object table,\n adding it if n...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
encode_network
Yield ref-containing obj table entries from object network
kurt/scratch14/objtable.py
def encode_network(root): """Yield ref-containing obj table entries from object network""" def fix_values(obj): if isinstance(obj, Container): obj.update((k, get_ref(v)) for (k, v) in obj.items() if k != 'class_name') fixed_obj = obj ...
def encode_network(root): """Yield ref-containing obj table entries from object network""" def fix_values(obj): if isinstance(obj, Container): obj.update((k, get_ref(v)) for (k, v) in obj.items() if k != 'class_name') fixed_obj = obj ...
[ "Yield", "ref", "-", "containing", "obj", "table", "entries", "from", "object", "network" ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L383-L443
[ "def", "encode_network", "(", "root", ")", ":", "def", "fix_values", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "Container", ")", ":", "obj", ".", "update", "(", "(", "k", ",", "get_ref", "(", "v", ")", ")", "for", "(", "k", ",", ...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
decode_obj_table
Return root of obj table. Converts user-class objects
kurt/scratch14/objtable.py
def decode_obj_table(table_entries, plugin): """Return root of obj table. Converts user-class objects""" entries = [] for entry in table_entries: if isinstance(entry, Container): assert not hasattr(entry, '__recursion_lock__') user_obj_def = plugin.user_objects[entry.classID]...
def decode_obj_table(table_entries, plugin): """Return root of obj table. Converts user-class objects""" entries = [] for entry in table_entries: if isinstance(entry, Container): assert not hasattr(entry, '__recursion_lock__') user_obj_def = plugin.user_objects[entry.classID]...
[ "Return", "root", "of", "obj", "table", ".", "Converts", "user", "-", "class", "objects" ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L445-L458
[ "def", "decode_obj_table", "(", "table_entries", ",", "plugin", ")", ":", "entries", "=", "[", "]", "for", "entry", "in", "table_entries", ":", "if", "isinstance", "(", "entry", ",", "Container", ")", ":", "assert", "not", "hasattr", "(", "entry", ",", "...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
encode_obj_table
Return list of obj table entries. Converts user-class objects
kurt/scratch14/objtable.py
def encode_obj_table(root, plugin): """Return list of obj table entries. Converts user-class objects""" entries = encode_network(root) table_entries = [] for entry in entries: if isinstance(entry, Container): assert not hasattr(entry, '__recursion_lock__') user_obj_def =...
def encode_obj_table(root, plugin): """Return list of obj table entries. Converts user-class objects""" entries = encode_network(root) table_entries = [] for entry in entries: if isinstance(entry, Container): assert not hasattr(entry, '__recursion_lock__') user_obj_def =...
[ "Return", "list", "of", "obj", "table", "entries", ".", "Converts", "user", "-", "class", "objects" ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L460-L477
[ "def", "encode_obj_table", "(", "root", ",", "plugin", ")", ":", "entries", "=", "encode_network", "(", "root", ")", "table_entries", "=", "[", "]", "for", "entry", "in", "entries", ":", "if", "isinstance", "(", "entry", ",", "Container", ")", ":", "asse...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
ObjectAdapter._encode
Encodes a class to a lower-level object using the class' own to_construct function. If no such function is defined, returns the object unchanged.
kurt/scratch14/objtable.py
def _encode(self, obj, context): """Encodes a class to a lower-level object using the class' own to_construct function. If no such function is defined, returns the object unchanged. """ func = getattr(obj, 'to_construct', None) if callable(func): return func(c...
def _encode(self, obj, context): """Encodes a class to a lower-level object using the class' own to_construct function. If no such function is defined, returns the object unchanged. """ func = getattr(obj, 'to_construct', None) if callable(func): return func(c...
[ "Encodes", "a", "class", "to", "a", "lower", "-", "level", "object", "using", "the", "class", "own", "to_construct", "function", ".", "If", "no", "such", "function", "is", "defined", "returns", "the", "object", "unchanged", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L60-L69
[ "def", "_encode", "(", "self", ",", "obj", ",", "context", ")", ":", "func", "=", "getattr", "(", "obj", ",", "'to_construct'", ",", "None", ")", "if", "callable", "(", "func", ")", ":", "return", "func", "(", "context", ")", "else", ":", "return", ...
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
ObjectAdapter._decode
Initialises a new Python class from a construct using the mapping passed to the adapter.
kurt/scratch14/objtable.py
def _decode(self, obj, context): """Initialises a new Python class from a construct using the mapping passed to the adapter. """ cls = self._get_class(obj.classID) return cls.from_construct(obj, context)
def _decode(self, obj, context): """Initialises a new Python class from a construct using the mapping passed to the adapter. """ cls = self._get_class(obj.classID) return cls.from_construct(obj, context)
[ "Initialises", "a", "new", "Python", "class", "from", "a", "construct", "using", "the", "mapping", "passed", "to", "the", "adapter", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L71-L76
[ "def", "_decode", "(", "self", ",", "obj", ",", "context", ")", ":", "cls", "=", "self", ".", "_get_class", "(", "obj", ".", "classID", ")", "return", "cls", ".", "from_construct", "(", "obj", ",", "context", ")" ]
fcccd80cae11dc233f6dd02b40ec9a388c62f259
train
ZipWriter.write_file
Write file contents string into archive.
kurt/scratch20/__init__.py
def write_file(self, name, contents): """Write file contents string into archive.""" # TODO: find a way to make ZipFile accept a file object. zi = zipfile.ZipInfo(name) zi.date_time = time.localtime(time.time())[:6] zi.compress_type = zipfile.ZIP_DEFLATED zi.external_attr...
def write_file(self, name, contents): """Write file contents string into archive.""" # TODO: find a way to make ZipFile accept a file object. zi = zipfile.ZipInfo(name) zi.date_time = time.localtime(time.time())[:6] zi.compress_type = zipfile.ZIP_DEFLATED zi.external_attr...
[ "Write", "file", "contents", "string", "into", "archive", "." ]
tjvr/kurt
python
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch20/__init__.py#L348-L355
[ "def", "write_file", "(", "self", ",", "name", ",", "contents", ")", ":", "# TODO: find a way to make ZipFile accept a file object.", "zi", "=", "zipfile", ".", "ZipInfo", "(", "name", ")", "zi", ".", "date_time", "=", "time", ".", "localtime", "(", "time", "....
fcccd80cae11dc233f6dd02b40ec9a388c62f259