Datasets:
id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens sequencelengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens sequencelengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | docstring_summary stringclasses 1
value | parameters stringclasses 1
value | return_statement stringclasses 1
value | argument_list stringclasses 1
value | identifier stringclasses 1
value | nwo stringclasses 1
value | score float32 -1 -1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.settext | def settext(self, text, cls='current'):
"""Set the text for this element.
Arguments:
text (str): The text
cls (str): The class of the text, defaults to ``current`` (leave this unless you know what you are doing). There may be only one text content element of each class associate... | python | def settext(self, text, cls='current'):
"""Set the text for this element.
Arguments:
text (str): The text
cls (str): The class of the text, defaults to ``current`` (leave this unless you know what you are doing). There may be only one text content element of each class associate... | [
"def",
"settext",
"(",
"self",
",",
"text",
",",
"cls",
"=",
"'current'",
")",
":",
"self",
".",
"replace",
"(",
"TextContent",
",",
"value",
"=",
"text",
",",
"cls",
"=",
"cls",
")"
] | Set the text for this element.
Arguments:
text (str): The text
cls (str): The class of the text, defaults to ``current`` (leave this unless you know what you are doing). There may be only one text content element of each class associated with the element. | [
"Set",
"the",
"text",
"for",
"this",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1357-L1364 | -1 | ||||||
1 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.setdocument | def setdocument(self, doc):
"""Associate a document with this element.
Arguments:
doc (:class:`Document`): A document
Each element must be associated with a FoLiA document.
"""
assert isinstance(doc, Document)
if not self.doc:
self.doc = doc
... | python | def setdocument(self, doc):
"""Associate a document with this element.
Arguments:
doc (:class:`Document`): A document
Each element must be associated with a FoLiA document.
"""
assert isinstance(doc, Document)
if not self.doc:
self.doc = doc
... | [
"def",
"setdocument",
"(",
"self",
",",
"doc",
")",
":",
"assert",
"isinstance",
"(",
"doc",
",",
"Document",
")",
"if",
"not",
"self",
".",
"doc",
":",
"self",
".",
"doc",
"=",
"doc",
"if",
"self",
".",
"id",
":",
"if",
"self",
".",
"id",
"in",
... | Associate a document with this element.
Arguments:
doc (:class:`Document`): A document
Each element must be associated with a FoLiA document. | [
"Associate",
"a",
"document",
"with",
"this",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1366-L1385 | -1 | ||||||
2 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.addable | def addable(Class, parent, set=None, raiseexceptions=True):
"""Tests whether a new element of this class can be added to the parent.
This method is mostly for internal use.
This will use the ``OCCURRENCES`` property, but may be overidden by subclasses for more customised behaviour.
Par... | python | def addable(Class, parent, set=None, raiseexceptions=True):
"""Tests whether a new element of this class can be added to the parent.
This method is mostly for internal use.
This will use the ``OCCURRENCES`` property, but may be overidden by subclasses for more customised behaviour.
Par... | [
"def",
"addable",
"(",
"Class",
",",
"parent",
",",
"set",
"=",
"None",
",",
"raiseexceptions",
"=",
"True",
")",
":",
"if",
"not",
"parent",
".",
"__class__",
".",
"accepts",
"(",
"Class",
",",
"raiseexceptions",
",",
"parent",
")",
":",
"return",
"Fa... | Tests whether a new element of this class can be added to the parent.
This method is mostly for internal use.
This will use the ``OCCURRENCES`` property, but may be overidden by subclasses for more customised behaviour.
Parameters:
parent (:class:`AbstractElement`): The element tha... | [
"Tests",
"whether",
"a",
"new",
"element",
"of",
"this",
"class",
"can",
"be",
"added",
"to",
"the",
"parent",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1406-L1455 | -1 | ||||||
3 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.postappend | def postappend(self):
"""This method will be called after an element is added to another and does some checks.
It can do extra checks and if necessary raise exceptions to prevent addition. By default makes sure the right document is associated.
This method is mostly for internal use.
"... | python | def postappend(self):
"""This method will be called after an element is added to another and does some checks.
It can do extra checks and if necessary raise exceptions to prevent addition. By default makes sure the right document is associated.
This method is mostly for internal use.
"... | [
"def",
"postappend",
"(",
"self",
")",
":",
"#If the element was not associated with a document yet, do so now (and for all unassociated children:",
"if",
"not",
"self",
".",
"doc",
"and",
"self",
".",
"parent",
".",
"doc",
":",
"self",
".",
"setdocument",
"(",
"self",
... | This method will be called after an element is added to another and does some checks.
It can do extra checks and if necessary raise exceptions to prevent addition. By default makes sure the right document is associated.
This method is mostly for internal use. | [
"This",
"method",
"will",
"be",
"called",
"after",
"an",
"element",
"is",
"added",
"to",
"another",
"and",
"does",
"some",
"checks",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1458-L1471 | -1 | ||||||
4 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.updatetext | def updatetext(self):
"""Recompute textual value based on the text content of the children. Only supported on elements that are a ``TEXTCONTAINER``"""
if self.TEXTCONTAINER:
s = ""
for child in self:
if isinstance(child, AbstractElement):
child... | python | def updatetext(self):
"""Recompute textual value based on the text content of the children. Only supported on elements that are a ``TEXTCONTAINER``"""
if self.TEXTCONTAINER:
s = ""
for child in self:
if isinstance(child, AbstractElement):
child... | [
"def",
"updatetext",
"(",
"self",
")",
":",
"if",
"self",
".",
"TEXTCONTAINER",
":",
"s",
"=",
"\"\"",
"for",
"child",
"in",
"self",
":",
"if",
"isinstance",
"(",
"child",
",",
"AbstractElement",
")",
":",
"child",
".",
"updatetext",
"(",
")",
"s",
"... | Recompute textual value based on the text content of the children. Only supported on elements that are a ``TEXTCONTAINER`` | [
"Recompute",
"textual",
"value",
"based",
"on",
"the",
"text",
"content",
"of",
"the",
"children",
".",
"Only",
"supported",
"on",
"elements",
"that",
"are",
"a",
"TEXTCONTAINER"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1772-L1782 | -1 | ||||||
5 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.ancestors | def ancestors(self, Class=None):
"""Generator yielding all ancestors of this element, effectively back-tracing its path to the root element. A tuple of multiple classes may be specified.
Arguments:
*Class: The class or classes (:class:`AbstractElement` or subclasses). Not instances!
... | python | def ancestors(self, Class=None):
"""Generator yielding all ancestors of this element, effectively back-tracing its path to the root element. A tuple of multiple classes may be specified.
Arguments:
*Class: The class or classes (:class:`AbstractElement` or subclasses). Not instances!
... | [
"def",
"ancestors",
"(",
"self",
",",
"Class",
"=",
"None",
")",
":",
"e",
"=",
"self",
"while",
"e",
":",
"if",
"e",
".",
"parent",
":",
"e",
"=",
"e",
".",
"parent",
"if",
"not",
"Class",
"or",
"isinstance",
"(",
"e",
",",
"Class",
")",
":",
... | Generator yielding all ancestors of this element, effectively back-tracing its path to the root element. A tuple of multiple classes may be specified.
Arguments:
*Class: The class or classes (:class:`AbstractElement` or subclasses). Not instances!
Yields:
elements (instances de... | [
"Generator",
"yielding",
"all",
"ancestors",
"of",
"this",
"element",
"effectively",
"back",
"-",
"tracing",
"its",
"path",
"to",
"the",
"root",
"element",
".",
"A",
"tuple",
"of",
"multiple",
"classes",
"may",
"be",
"specified",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1840-L1860 | -1 | ||||||
6 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.ancestor | def ancestor(self, *Classes):
"""Find the most immediate ancestor of the specified type, multiple classes may be specified.
Arguments:
*Classes: The possible classes (:class:`AbstractElement` or subclasses) to select from. Not instances!
Example::
paragraph = word.ance... | python | def ancestor(self, *Classes):
"""Find the most immediate ancestor of the specified type, multiple classes may be specified.
Arguments:
*Classes: The possible classes (:class:`AbstractElement` or subclasses) to select from. Not instances!
Example::
paragraph = word.ance... | [
"def",
"ancestor",
"(",
"self",
",",
"*",
"Classes",
")",
":",
"for",
"e",
"in",
"self",
".",
"ancestors",
"(",
"tuple",
"(",
"Classes",
")",
")",
":",
"return",
"e",
"raise",
"NoSuchAnnotation"
] | Find the most immediate ancestor of the specified type, multiple classes may be specified.
Arguments:
*Classes: The possible classes (:class:`AbstractElement` or subclasses) to select from. Not instances!
Example::
paragraph = word.ancestor(folia.Paragraph) | [
"Find",
"the",
"most",
"immediate",
"ancestor",
"of",
"the",
"specified",
"type",
"multiple",
"classes",
"may",
"be",
"specified",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1862-L1874 | -1 | ||||||
7 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.json | def json(self, attribs=None, recurse=True, ignorelist=False):
"""Serialises the FoLiA element and all its contents to a Python dictionary suitable for serialisation to JSON.
Example::
import json
json.dumps(word.json())
Returns:
dict
"""
jso... | python | def json(self, attribs=None, recurse=True, ignorelist=False):
"""Serialises the FoLiA element and all its contents to a Python dictionary suitable for serialisation to JSON.
Example::
import json
json.dumps(word.json())
Returns:
dict
"""
jso... | [
"def",
"json",
"(",
"self",
",",
"attribs",
"=",
"None",
",",
"recurse",
"=",
"True",
",",
"ignorelist",
"=",
"False",
")",
":",
"jsonnode",
"=",
"{",
"}",
"jsonnode",
"[",
"'type'",
"]",
"=",
"self",
".",
"XMLTAG",
"if",
"self",
".",
"id",
":",
... | Serialises the FoLiA element and all its contents to a Python dictionary suitable for serialisation to JSON.
Example::
import json
json.dumps(word.json())
Returns:
dict | [
"Serialises",
"the",
"FoLiA",
"element",
"and",
"all",
"its",
"contents",
"to",
"a",
"Python",
"dictionary",
"suitable",
"for",
"serialisation",
"to",
"JSON",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2050-L2110 | -1 | ||||||
8 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.xmlstring | def xmlstring(self, pretty_print=False):
"""Serialises this FoLiA element and all its contents to XML.
Returns:
str: a string with XML representation for this element and all its children"""
s = ElementTree.tostring(self.xml(), xml_declaration=False, pretty_print=pretty_print, encod... | python | def xmlstring(self, pretty_print=False):
"""Serialises this FoLiA element and all its contents to XML.
Returns:
str: a string with XML representation for this element and all its children"""
s = ElementTree.tostring(self.xml(), xml_declaration=False, pretty_print=pretty_print, encod... | [
"def",
"xmlstring",
"(",
"self",
",",
"pretty_print",
"=",
"False",
")",
":",
"s",
"=",
"ElementTree",
".",
"tostring",
"(",
"self",
".",
"xml",
"(",
")",
",",
"xml_declaration",
"=",
"False",
",",
"pretty_print",
"=",
"pretty_print",
",",
"encoding",
"=... | Serialises this FoLiA element and all its contents to XML.
Returns:
str: a string with XML representation for this element and all its children | [
"Serialises",
"this",
"FoLiA",
"element",
"and",
"all",
"its",
"contents",
"to",
"XML",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2114-L2129 | -1 | ||||||
9 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.select | def select(self, Class, set=None, recursive=True, ignore=True, node=None): #pylint: disable=bad-classmethod-argument,redefined-builtin
"""Select child elements of the specified class.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; an... | python | def select(self, Class, set=None, recursive=True, ignore=True, node=None): #pylint: disable=bad-classmethod-argument,redefined-builtin
"""Select child elements of the specified class.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; an... | [
"def",
"select",
"(",
"self",
",",
"Class",
",",
"set",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"ignore",
"=",
"True",
",",
"node",
"=",
"None",
")",
":",
"#pylint: disable=bad-classmethod-argument,redefined-builtin",
"#if ignorelist is True:",
"# igno... | Select child elements of the specified class.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement`
Set (str): The set to match against, only elements pertaining to ... | [
"Select",
"child",
"elements",
"of",
"the",
"specified",
"class",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2132-L2201 | -1 | ||||||
10 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.getmetadata | def getmetadata(self, key=None):
"""Get the metadata that applies to this element, automatically inherited from parent elements"""
if self.metadata:
d = self.doc.submetadata[self.metadata]
elif self.parent:
d = self.parent.getmetadata()
elif self.doc:
... | python | def getmetadata(self, key=None):
"""Get the metadata that applies to this element, automatically inherited from parent elements"""
if self.metadata:
d = self.doc.submetadata[self.metadata]
elif self.parent:
d = self.parent.getmetadata()
elif self.doc:
... | [
"def",
"getmetadata",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"self",
".",
"metadata",
":",
"d",
"=",
"self",
".",
"doc",
".",
"submetadata",
"[",
"self",
".",
"metadata",
"]",
"elif",
"self",
".",
"parent",
":",
"d",
"=",
"self",
"... | Get the metadata that applies to this element, automatically inherited from parent elements | [
"Get",
"the",
"metadata",
"that",
"applies",
"to",
"this",
"element",
"automatically",
"inherited",
"from",
"parent",
"elements"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2221-L2234 | -1 | ||||||
11 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.getindex | def getindex(self, child, recursive=True, ignore=True):
"""Get the index at which an element occurs, recursive by default!
Returns:
int
"""
#breadth first search
for i, c in enumerate(self.data):
if c is child:
return i
if recursi... | python | def getindex(self, child, recursive=True, ignore=True):
"""Get the index at which an element occurs, recursive by default!
Returns:
int
"""
#breadth first search
for i, c in enumerate(self.data):
if c is child:
return i
if recursi... | [
"def",
"getindex",
"(",
"self",
",",
"child",
",",
"recursive",
"=",
"True",
",",
"ignore",
"=",
"True",
")",
":",
"#breadth first search",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"self",
".",
"data",
")",
":",
"if",
"c",
"is",
"child",
":",
... | Get the index at which an element occurs, recursive by default!
Returns:
int | [
"Get",
"the",
"index",
"at",
"which",
"an",
"element",
"occurs",
"recursive",
"by",
"default!"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2238-L2278 | -1 | ||||||
12 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.precedes | def precedes(self, other):
"""Returns a boolean indicating whether this element precedes the other element"""
try:
ancestor = next(commonancestors(AbstractElement, self, other))
except StopIteration:
raise Exception("Elements share no common ancestor")
#now we jus... | python | def precedes(self, other):
"""Returns a boolean indicating whether this element precedes the other element"""
try:
ancestor = next(commonancestors(AbstractElement, self, other))
except StopIteration:
raise Exception("Elements share no common ancestor")
#now we jus... | [
"def",
"precedes",
"(",
"self",
",",
"other",
")",
":",
"try",
":",
"ancestor",
"=",
"next",
"(",
"commonancestors",
"(",
"AbstractElement",
",",
"self",
",",
"other",
")",
")",
"except",
"StopIteration",
":",
"raise",
"Exception",
"(",
"\"Elements share no ... | Returns a boolean indicating whether this element precedes the other element | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"this",
"element",
"precedes",
"the",
"other",
"element"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2280-L2296 | -1 | ||||||
13 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.depthfirstsearch | def depthfirstsearch(self, function):
"""Generic depth first search algorithm using a callback function, continues as long as the callback function returns None"""
result = function(self)
if result is not None:
return result
for e in self:
result = e.depthfirstsea... | python | def depthfirstsearch(self, function):
"""Generic depth first search algorithm using a callback function, continues as long as the callback function returns None"""
result = function(self)
if result is not None:
return result
for e in self:
result = e.depthfirstsea... | [
"def",
"depthfirstsearch",
"(",
"self",
",",
"function",
")",
":",
"result",
"=",
"function",
"(",
"self",
")",
"if",
"result",
"is",
"not",
"None",
":",
"return",
"result",
"for",
"e",
"in",
"self",
":",
"result",
"=",
"e",
".",
"depthfirstsearch",
"(... | Generic depth first search algorithm using a callback function, continues as long as the callback function returns None | [
"Generic",
"depth",
"first",
"search",
"algorithm",
"using",
"a",
"callback",
"function",
"continues",
"as",
"long",
"as",
"the",
"callback",
"function",
"returns",
"None"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2299-L2308 | -1 | ||||||
14 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.next | def next(self, Class=True, scope=True, reverse=False):
"""Returns the next element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The... | python | def next(self, Class=True, scope=True, reverse=False):
"""Returns the next element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The... | [
"def",
"next",
"(",
"self",
",",
"Class",
"=",
"True",
",",
"scope",
"=",
"True",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"Class",
"is",
"True",
":",
"Class",
"=",
"self",
".",
"__class__",
"if",
"scope",
"is",
"True",
":",
"scope",
"=",
"S... | Returns the next element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The class to select; any python class subclassed off `'AbstractElemen... | [
"Returns",
"the",
"next",
"element",
"if",
"it",
"is",
"of",
"the",
"specified",
"type",
"and",
"if",
"it",
"does",
"not",
"cross",
"the",
"boundary",
"of",
"the",
"defined",
"scope",
".",
"Returns",
"None",
"if",
"no",
"next",
"element",
"is",
"found",
... | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2310-L2367 | -1 | ||||||
15 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.previous | def previous(self, Class=True, scope=True):
"""Returns the previous element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The class ... | python | def previous(self, Class=True, scope=True):
"""Returns the previous element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The class ... | [
"def",
"previous",
"(",
"self",
",",
"Class",
"=",
"True",
",",
"scope",
"=",
"True",
")",
":",
"return",
"self",
".",
"next",
"(",
"Class",
",",
"scope",
",",
"True",
")"
] | Returns the previous element, if it is of the specified type and if it does not cross the boundary of the defined scope. Returns None if no next element is found. Non-authoritative elements are never returned.
Arguments:
* ``Class``: The class to select; any python class subclassed off `'AbstractEl... | [
"Returns",
"the",
"previous",
"element",
"if",
"it",
"is",
"of",
"the",
"specified",
"type",
"and",
"if",
"it",
"does",
"not",
"cross",
"the",
"boundary",
"of",
"the",
"defined",
"scope",
".",
"Returns",
"None",
"if",
"no",
"next",
"element",
"is",
"foun... | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2371-L2379 | -1 | ||||||
16 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.remove | def remove(self, child):
"""Removes the child element"""
if not isinstance(child, AbstractElement):
raise ValueError("Expected AbstractElement, got " + str(type(child)))
if child.parent == self:
child.parent = None
self.data.remove(child)
#delete from inde... | python | def remove(self, child):
"""Removes the child element"""
if not isinstance(child, AbstractElement):
raise ValueError("Expected AbstractElement, got " + str(type(child)))
if child.parent == self:
child.parent = None
self.data.remove(child)
#delete from inde... | [
"def",
"remove",
"(",
"self",
",",
"child",
")",
":",
"if",
"not",
"isinstance",
"(",
"child",
",",
"AbstractElement",
")",
":",
"raise",
"ValueError",
"(",
"\"Expected AbstractElement, got \"",
"+",
"str",
"(",
"type",
"(",
"child",
")",
")",
")",
"if",
... | Removes the child element | [
"Removes",
"the",
"child",
"element"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2729-L2738 | -1 | ||||||
17 | proycon/pynlpl | pynlpl/formats/folia.py | AllowTokenAnnotation.hasannotation | def hasannotation(self,Class,set=None):
"""Returns an integer indicating whether such as annotation exists, and if so, how many.
See :meth:`AllowTokenAnnotation.annotations`` for a description of the parameters."""
return sum( 1 for _ in self.select(Class,set,True,default_ignore_annotations)) | python | def hasannotation(self,Class,set=None):
"""Returns an integer indicating whether such as annotation exists, and if so, how many.
See :meth:`AllowTokenAnnotation.annotations`` for a description of the parameters."""
return sum( 1 for _ in self.select(Class,set,True,default_ignore_annotations)) | [
"def",
"hasannotation",
"(",
"self",
",",
"Class",
",",
"set",
"=",
"None",
")",
":",
"return",
"sum",
"(",
"1",
"for",
"_",
"in",
"self",
".",
"select",
"(",
"Class",
",",
"set",
",",
"True",
",",
"default_ignore_annotations",
")",
")"
] | Returns an integer indicating whether such as annotation exists, and if so, how many.
See :meth:`AllowTokenAnnotation.annotations`` for a description of the parameters. | [
"Returns",
"an",
"integer",
"indicating",
"whether",
"such",
"as",
"annotation",
"exists",
"and",
"if",
"so",
"how",
"many",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3046-L3050 | -1 | ||||||
18 | proycon/pynlpl | pynlpl/formats/folia.py | AllowTokenAnnotation.annotation | def annotation(self, type, set=None):
"""Obtain a single annotation element.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement`
Set (str): The set to matc... | python | def annotation(self, type, set=None):
"""Obtain a single annotation element.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement`
Set (str): The set to matc... | [
"def",
"annotation",
"(",
"self",
",",
"type",
",",
"set",
"=",
"None",
")",
":",
"\"\"\"Will return a **single** annotation (even if there are multiple). Raises a ``NoSuchAnnotation`` exception if none was found\"\"\"",
"for",
"e",
"in",
"self",
".",
"select",
"(",
"type",
... | Obtain a single annotation element.
A further restriction can be made based on set.
Arguments:
Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement`
Set (str): The set to match against, only elements pertaining to this set w... | [
"Obtain",
"a",
"single",
"annotation",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3052-L3078 | -1 | ||||||
19 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.hasannotationlayer | def hasannotationlayer(self, annotationtype=None,set=None):
"""Does the specified annotation layer exist?"""
l = self.layers(annotationtype, set)
return (len(l) > 0) | python | def hasannotationlayer(self, annotationtype=None,set=None):
"""Does the specified annotation layer exist?"""
l = self.layers(annotationtype, set)
return (len(l) > 0) | [
"def",
"hasannotationlayer",
"(",
"self",
",",
"annotationtype",
"=",
"None",
",",
"set",
"=",
"None",
")",
":",
"l",
"=",
"self",
".",
"layers",
"(",
"annotationtype",
",",
"set",
")",
"return",
"(",
"len",
"(",
"l",
")",
">",
"0",
")"
] | Does the specified annotation layer exist? | [
"Does",
"the",
"specified",
"annotation",
"layer",
"exist?"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3268-L3271 | -1 | ||||||
20 | proycon/pynlpl | pynlpl/formats/folia.py | TextContent.getreference | def getreference(self, validate=True):
"""Returns and validates the Text Content's reference. Raises UnresolvableTextContent when invalid"""
if self.offset is None: return None #nothing to test
if self.ref:
ref = self.doc[self.ref]
else:
ref = self.finddefaultref... | python | def getreference(self, validate=True):
"""Returns and validates the Text Content's reference. Raises UnresolvableTextContent when invalid"""
if self.offset is None: return None #nothing to test
if self.ref:
ref = self.doc[self.ref]
else:
ref = self.finddefaultref... | [
"def",
"getreference",
"(",
"self",
",",
"validate",
"=",
"True",
")",
":",
"if",
"self",
".",
"offset",
"is",
"None",
":",
"return",
"None",
"#nothing to test",
"if",
"self",
".",
"ref",
":",
"ref",
"=",
"self",
".",
"doc",
"[",
"self",
".",
"ref",
... | Returns and validates the Text Content's reference. Raises UnresolvableTextContent when invalid | [
"Returns",
"and",
"validates",
"the",
"Text",
"Content",
"s",
"reference",
".",
"Raises",
"UnresolvableTextContent",
"when",
"invalid"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3502-L3519 | -1 | ||||||
21 | proycon/pynlpl | pynlpl/formats/folia.py | PhonContent.getreference | def getreference(self, validate=True):
"""Return and validate the Phonetic Content's reference. Raises UnresolvableTextContent when invalid"""
if self.offset is None: return None #nothing to test
if self.ref:
ref = self.doc[self.ref]
else:
ref = self.finddefaultr... | python | def getreference(self, validate=True):
"""Return and validate the Phonetic Content's reference. Raises UnresolvableTextContent when invalid"""
if self.offset is None: return None #nothing to test
if self.ref:
ref = self.doc[self.ref]
else:
ref = self.finddefaultr... | [
"def",
"getreference",
"(",
"self",
",",
"validate",
"=",
"True",
")",
":",
"if",
"self",
".",
"offset",
"is",
"None",
":",
"return",
"None",
"#nothing to test",
"if",
"self",
".",
"ref",
":",
"ref",
"=",
"self",
".",
"doc",
"[",
"self",
".",
"ref",
... | Return and validate the Phonetic Content's reference. Raises UnresolvableTextContent when invalid | [
"Return",
"and",
"validate",
"the",
"Phonetic",
"Content",
"s",
"reference",
".",
"Raises",
"UnresolvableTextContent",
"when",
"invalid"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3715-L3732 | -1 | ||||||
22 | proycon/pynlpl | pynlpl/formats/folia.py | Word.findspans | def findspans(self, type,set=None):
"""Yields span annotation elements of the specified type that include this word.
Arguments:
type: The annotation type, can be passed as using any of the :class:`AnnotationType` member, or by passing the relevant :class:`AbstractSpanAnnotation` or :class:`... | python | def findspans(self, type,set=None):
"""Yields span annotation elements of the specified type that include this word.
Arguments:
type: The annotation type, can be passed as using any of the :class:`AnnotationType` member, or by passing the relevant :class:`AbstractSpanAnnotation` or :class:`... | [
"def",
"findspans",
"(",
"self",
",",
"type",
",",
"set",
"=",
"None",
")",
":",
"if",
"issubclass",
"(",
"type",
",",
"AbstractAnnotationLayer",
")",
":",
"layerclass",
"=",
"type",
"else",
":",
"layerclass",
"=",
"ANNOTATIONTYPE2LAYERCLASS",
"[",
"type",
... | Yields span annotation elements of the specified type that include this word.
Arguments:
type: The annotation type, can be passed as using any of the :class:`AnnotationType` member, or by passing the relevant :class:`AbstractSpanAnnotation` or :class:`AbstractAnnotationLayer` class.
set... | [
"Yields",
"span",
"annotation",
"elements",
"of",
"the",
"specified",
"type",
"that",
"include",
"this",
"word",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4178-L4213 | -1 | ||||||
23 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractSpanAnnotation.setspan | def setspan(self, *args):
"""Sets the span of the span element anew, erases all data inside.
Arguments:
*args: Instances of :class:`Word`, :class:`Morpheme` or :class:`Phoneme`
"""
self.data = []
for child in args:
self.append(child) | python | def setspan(self, *args):
"""Sets the span of the span element anew, erases all data inside.
Arguments:
*args: Instances of :class:`Word`, :class:`Morpheme` or :class:`Phoneme`
"""
self.data = []
for child in args:
self.append(child) | [
"def",
"setspan",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"data",
"=",
"[",
"]",
"for",
"child",
"in",
"args",
":",
"self",
".",
"append",
"(",
"child",
")"
] | Sets the span of the span element anew, erases all data inside.
Arguments:
*args: Instances of :class:`Word`, :class:`Morpheme` or :class:`Phoneme` | [
"Sets",
"the",
"span",
"of",
"the",
"span",
"element",
"anew",
"erases",
"all",
"data",
"inside",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4373-L4381 | -1 | ||||||
24 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractSpanAnnotation._helper_wrefs | def _helper_wrefs(self, targets, recurse=True):
"""Internal helper function"""
for c in self:
if isinstance(c,Word) or isinstance(c,Morpheme) or isinstance(c, Phoneme):
targets.append(c)
elif isinstance(c,WordReference):
try:
ta... | python | def _helper_wrefs(self, targets, recurse=True):
"""Internal helper function"""
for c in self:
if isinstance(c,Word) or isinstance(c,Morpheme) or isinstance(c, Phoneme):
targets.append(c)
elif isinstance(c,WordReference):
try:
ta... | [
"def",
"_helper_wrefs",
"(",
"self",
",",
"targets",
",",
"recurse",
"=",
"True",
")",
":",
"for",
"c",
"in",
"self",
":",
"if",
"isinstance",
"(",
"c",
",",
"Word",
")",
"or",
"isinstance",
"(",
"c",
",",
"Morpheme",
")",
"or",
"isinstance",
"(",
... | Internal helper function | [
"Internal",
"helper",
"function"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4418-L4437 | -1 | ||||||
25 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractSpanAnnotation.wrefs | def wrefs(self, index = None, recurse=True):
"""Returns a list of word references, these can be Words but also Morphemes or Phonemes.
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all
... | python | def wrefs(self, index = None, recurse=True):
"""Returns a list of word references, these can be Words but also Morphemes or Phonemes.
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all
... | [
"def",
"wrefs",
"(",
"self",
",",
"index",
"=",
"None",
",",
"recurse",
"=",
"True",
")",
":",
"targets",
"=",
"[",
"]",
"self",
".",
"_helper_wrefs",
"(",
"targets",
",",
"recurse",
")",
"if",
"index",
"is",
"None",
":",
"return",
"targets",
"else",... | Returns a list of word references, these can be Words but also Morphemes or Phonemes.
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all | [
"Returns",
"a",
"list",
"of",
"word",
"references",
"these",
"can",
"be",
"Words",
"but",
"also",
"Morphemes",
"or",
"Phonemes",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4439-L4450 | -1 | ||||||
26 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractSpanAnnotation.copychildren | def copychildren(self, newdoc=None, idsuffix=""):
"""Generator creating a deep copy of the children of this element. If idsuffix is a string, if set to True, a random idsuffix will be generated including a random 32-bit hash"""
if idsuffix is True: idsuffix = ".copy." + "%08x" % random.getrandbits(32) #... | python | def copychildren(self, newdoc=None, idsuffix=""):
"""Generator creating a deep copy of the children of this element. If idsuffix is a string, if set to True, a random idsuffix will be generated including a random 32-bit hash"""
if idsuffix is True: idsuffix = ".copy." + "%08x" % random.getrandbits(32) #... | [
"def",
"copychildren",
"(",
"self",
",",
"newdoc",
"=",
"None",
",",
"idsuffix",
"=",
"\"\"",
")",
":",
"if",
"idsuffix",
"is",
"True",
":",
"idsuffix",
"=",
"\".copy.\"",
"+",
"\"%08x\"",
"%",
"random",
".",
"getrandbits",
"(",
"32",
")",
"#random 32-bi... | Generator creating a deep copy of the children of this element. If idsuffix is a string, if set to True, a random idsuffix will be generated including a random 32-bit hash | [
"Generator",
"creating",
"a",
"deep",
"copy",
"of",
"the",
"children",
"of",
"this",
"element",
".",
"If",
"idsuffix",
"is",
"a",
"string",
"if",
"set",
"to",
"True",
"a",
"random",
"idsuffix",
"will",
"be",
"generated",
"including",
"a",
"random",
"32",
... | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4465-L4472 | -1 | ||||||
27 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractAnnotationLayer.alternatives | def alternatives(self, Class=None, set=None):
"""Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.
Arguments:
* ``Class`` - The Class you want to retrieve (e.g. PosAnnotation). Or set to None to select all alternatives regard... | python | def alternatives(self, Class=None, set=None):
"""Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.
Arguments:
* ``Class`` - The Class you want to retrieve (e.g. PosAnnotation). Or set to None to select all alternatives regard... | [
"def",
"alternatives",
"(",
"self",
",",
"Class",
"=",
"None",
",",
"set",
"=",
"None",
")",
":",
"for",
"e",
"in",
"self",
".",
"select",
"(",
"AlternativeLayers",
",",
"None",
",",
"True",
",",
"[",
"'Original'",
",",
"'Suggestion'",
"]",
")",
":",... | Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.
Arguments:
* ``Class`` - The Class you want to retrieve (e.g. PosAnnotation). Or set to None to select all alternatives regardless of what type they are.
* ``set`` - The... | [
"Generator",
"over",
"alternatives",
"either",
"all",
"or",
"only",
"of",
"a",
"specific",
"annotation",
"type",
"and",
"possibly",
"restrained",
"also",
"by",
"set",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4574-L4599 | -1 | ||||||
28 | proycon/pynlpl | pynlpl/formats/folia.py | AbstractAnnotationLayer.findspan | def findspan(self, *words):
"""Returns the span element which spans over the specified words or morphemes.
See also:
:meth:`Word.findspans`
"""
for span in self.select(AbstractSpanAnnotation,None,True):
if tuple(span.wrefs()) == words:
return spa... | python | def findspan(self, *words):
"""Returns the span element which spans over the specified words or morphemes.
See also:
:meth:`Word.findspans`
"""
for span in self.select(AbstractSpanAnnotation,None,True):
if tuple(span.wrefs()) == words:
return spa... | [
"def",
"findspan",
"(",
"self",
",",
"*",
"words",
")",
":",
"for",
"span",
"in",
"self",
".",
"select",
"(",
"AbstractSpanAnnotation",
",",
"None",
",",
"True",
")",
":",
"if",
"tuple",
"(",
"span",
".",
"wrefs",
"(",
")",
")",
"==",
"words",
":",... | Returns the span element which spans over the specified words or morphemes.
See also:
:meth:`Word.findspans` | [
"Returns",
"the",
"span",
"element",
"which",
"spans",
"over",
"the",
"specified",
"words",
"or",
"morphemes",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4601-L4611 | -1 | ||||||
29 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.hasnew | def hasnew(self,allowempty=False):
"""Does the correction define new corrected annotations?"""
for e in self.select(New,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | python | def hasnew(self,allowempty=False):
"""Does the correction define new corrected annotations?"""
for e in self.select(New,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | [
"def",
"hasnew",
"(",
"self",
",",
"allowempty",
"=",
"False",
")",
":",
"for",
"e",
"in",
"self",
".",
"select",
"(",
"New",
",",
"None",
",",
"False",
",",
"False",
")",
":",
"if",
"not",
"allowempty",
"and",
"len",
"(",
"e",
")",
"==",
"0",
... | Does the correction define new corrected annotations? | [
"Does",
"the",
"correction",
"define",
"new",
"corrected",
"annotations?"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4982-L4987 | -1 | ||||||
30 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.hasoriginal | def hasoriginal(self,allowempty=False):
"""Does the correction record the old annotations prior to correction?"""
for e in self.select(Original,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | python | def hasoriginal(self,allowempty=False):
"""Does the correction record the old annotations prior to correction?"""
for e in self.select(Original,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | [
"def",
"hasoriginal",
"(",
"self",
",",
"allowempty",
"=",
"False",
")",
":",
"for",
"e",
"in",
"self",
".",
"select",
"(",
"Original",
",",
"None",
",",
"False",
",",
"False",
")",
":",
"if",
"not",
"allowempty",
"and",
"len",
"(",
"e",
")",
"==",... | Does the correction record the old annotations prior to correction? | [
"Does",
"the",
"correction",
"record",
"the",
"old",
"annotations",
"prior",
"to",
"correction?"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4989-L4994 | -1 | ||||||
31 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.hassuggestions | def hassuggestions(self,allowempty=False):
"""Does the correction propose suggestions for correction?"""
for e in self.select(Suggestion,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | python | def hassuggestions(self,allowempty=False):
"""Does the correction propose suggestions for correction?"""
for e in self.select(Suggestion,None,False, False):
if not allowempty and len(e) == 0: continue
return True
return False | [
"def",
"hassuggestions",
"(",
"self",
",",
"allowempty",
"=",
"False",
")",
":",
"for",
"e",
"in",
"self",
".",
"select",
"(",
"Suggestion",
",",
"None",
",",
"False",
",",
"False",
")",
":",
"if",
"not",
"allowempty",
"and",
"len",
"(",
"e",
")",
... | Does the correction propose suggestions for correction? | [
"Does",
"the",
"correction",
"propose",
"suggestions",
"for",
"correction?"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5003-L5008 | -1 | ||||||
32 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.new | def new(self,index = None):
"""Get the new corrected annotation.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnnotation`
... | python | def new(self,index = None):
"""Get the new corrected annotation.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnnotation`
... | [
"def",
"new",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"try",
":",
"return",
"next",
"(",
"self",
".",
"select",
"(",
"New",
",",
"None",
",",
"False",
")",
")",
"except",
"StopIteration",
":",
"raise",
... | Get the new corrected annotation.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnnotation` | [
"Get",
"the",
"new",
"corrected",
"annotation",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5106-L5126 | -1 | ||||||
33 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.original | def original(self,index=None):
"""Get the old annotation prior to correction.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnno... | python | def original(self,index=None):
"""Get the old annotation prior to correction.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnno... | [
"def",
"original",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"try",
":",
"return",
"next",
"(",
"self",
".",
"select",
"(",
"Original",
",",
"None",
",",
"False",
",",
"False",
")",
")",
"except",
"StopIter... | Get the old annotation prior to correction.
This returns only one annotation if multiple exist, use `index` to select another in the sequence.
Returns:
an annotation element (:class:`AbstractElement`)
Raises:
:class:`NoSuchAnnotation` | [
"Get",
"the",
"old",
"annotation",
"prior",
"to",
"correction",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5128-L5147 | -1 | ||||||
34 | proycon/pynlpl | pynlpl/formats/folia.py | Correction.suggestions | def suggestions(self,index=None):
"""Get suggestions for correction.
Yields:
:class:`Suggestion` element that encapsulate the suggested annotations (if index is ``None``, default)
Returns:
a :class:`Suggestion` element that encapsulate the suggested annotations (if inde... | python | def suggestions(self,index=None):
"""Get suggestions for correction.
Yields:
:class:`Suggestion` element that encapsulate the suggested annotations (if index is ``None``, default)
Returns:
a :class:`Suggestion` element that encapsulate the suggested annotations (if inde... | [
"def",
"suggestions",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"return",
"self",
".",
"select",
"(",
"Suggestion",
",",
"None",
",",
"False",
",",
"False",
")",
"else",
":",
"for",
"i",
",",
"e",
"in",
"... | Get suggestions for correction.
Yields:
:class:`Suggestion` element that encapsulate the suggested annotations (if index is ``None``, default)
Returns:
a :class:`Suggestion` element that encapsulate the suggested annotations (if index is set)
Raises:
:class... | [
"Get",
"suggestions",
"for",
"correction",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5170-L5188 | -1 | ||||||
35 | proycon/pynlpl | pynlpl/formats/folia.py | Morpheme.findspans | def findspans(self, type,set=None):
"""Find span annotation of the specified type that include this word"""
if issubclass(type, AbstractAnnotationLayer):
layerclass = type
else:
layerclass = ANNOTATIONTYPE2LAYERCLASS[type.ANNOTATIONTYPE]
e = self
while Tru... | python | def findspans(self, type,set=None):
"""Find span annotation of the specified type that include this word"""
if issubclass(type, AbstractAnnotationLayer):
layerclass = type
else:
layerclass = ANNOTATIONTYPE2LAYERCLASS[type.ANNOTATIONTYPE]
e = self
while Tru... | [
"def",
"findspans",
"(",
"self",
",",
"type",
",",
"set",
"=",
"None",
")",
":",
"if",
"issubclass",
"(",
"type",
",",
"AbstractAnnotationLayer",
")",
":",
"layerclass",
"=",
"type",
"else",
":",
"layerclass",
"=",
"ANNOTATIONTYPE2LAYERCLASS",
"[",
"type",
... | Find span annotation of the specified type that include this word | [
"Find",
"span",
"annotation",
"of",
"the",
"specified",
"type",
"that",
"include",
"this",
"word"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L5528-L5542 | -1 | ||||||
36 | proycon/pynlpl | pynlpl/formats/folia.py | Pattern.resolve | def resolve(self,size, distribution):
"""Resolve a variable sized pattern to all patterns of a certain fixed size"""
if not self.variablesize():
raise Exception("Can only resize patterns with * wildcards")
nrofwildcards = 0
for x in self.sequence:
if x == '*':
... | python | def resolve(self,size, distribution):
"""Resolve a variable sized pattern to all patterns of a certain fixed size"""
if not self.variablesize():
raise Exception("Can only resize patterns with * wildcards")
nrofwildcards = 0
for x in self.sequence:
if x == '*':
... | [
"def",
"resolve",
"(",
"self",
",",
"size",
",",
"distribution",
")",
":",
"if",
"not",
"self",
".",
"variablesize",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"Can only resize patterns with * wildcards\"",
")",
"nrofwildcards",
"=",
"0",
"for",
"x",
"in",
... | Resolve a variable sized pattern to all patterns of a certain fixed size | [
"Resolve",
"a",
"variable",
"sized",
"pattern",
"to",
"all",
"patterns",
"of",
"a",
"certain",
"fixed",
"size"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6221-L6242 | -1 | ||||||
37 | proycon/pynlpl | pynlpl/formats/folia.py | Document.load | def load(self, filename):
"""Load a FoLiA XML file.
Argument:
filename (str): The file to load
"""
#if LXE and self.mode != Mode.XPATH:
# #workaround for xml:id problem (disabled)
# #f = open(filename)
# #s = f.read().replace(' xml:id=', ' id... | python | def load(self, filename):
"""Load a FoLiA XML file.
Argument:
filename (str): The file to load
"""
#if LXE and self.mode != Mode.XPATH:
# #workaround for xml:id problem (disabled)
# #f = open(filename)
# #s = f.read().replace(' xml:id=', ' id... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"#if LXE and self.mode != Mode.XPATH:",
"# #workaround for xml:id problem (disabled)",
"# #f = open(filename)",
"# #s = f.read().replace(' xml:id=', ' id=')",
"# #f.close()",
"# self.tree = ElementTree.parse(filename)",
... | Load a FoLiA XML file.
Argument:
filename (str): The file to load | [
"Load",
"a",
"FoLiA",
"XML",
"file",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6495-L6512 | -1 | ||||||
38 | proycon/pynlpl | pynlpl/formats/folia.py | Document.items | def items(self):
"""Returns a depth-first flat list of all items in the document"""
l = []
for e in self.data:
l += e.items()
return l | python | def items(self):
"""Returns a depth-first flat list of all items in the document"""
l = []
for e in self.data:
l += e.items()
return l | [
"def",
"items",
"(",
"self",
")",
":",
"l",
"=",
"[",
"]",
"for",
"e",
"in",
"self",
".",
"data",
":",
"l",
"+=",
"e",
".",
"items",
"(",
")",
"return",
"l"
] | Returns a depth-first flat list of all items in the document | [
"Returns",
"a",
"depth",
"-",
"first",
"flat",
"list",
"of",
"all",
"items",
"in",
"the",
"document"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6514-L6519 | -1 | ||||||
39 | proycon/pynlpl | pynlpl/formats/folia.py | Document.save | def save(self, filename=None):
"""Save the document to file.
Arguments:
* filename (str): The filename to save to. If not set (``None``, default), saves to the same file as loaded from.
"""
if not filename:
filename = self.filename
if not filename:
... | python | def save(self, filename=None):
"""Save the document to file.
Arguments:
* filename (str): The filename to save to. If not set (``None``, default), saves to the same file as loaded from.
"""
if not filename:
filename = self.filename
if not filename:
... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"self",
".",
"filename",
"if",
"not",
"filename",
":",
"raise",
"Exception",
"(",
"\"No filename specified\"",
")",
"if",
"filename",
"[",
... | Save the document to file.
Arguments:
* filename (str): The filename to save to. If not set (``None``, default), saves to the same file as loaded from. | [
"Save",
"the",
"document",
"to",
"file",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6547-L6568 | -1 | ||||||
40 | proycon/pynlpl | pynlpl/formats/folia.py | Document.xmldeclarations | def xmldeclarations(self):
"""Internal method to generate XML nodes for all declarations"""
l = []
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={None: "http://ilk.uvt.nl/folia", 'xml' : "http://www.w3.org/XML/1998/namespace"})
for annotationtype, set in self.annotations:
... | python | def xmldeclarations(self):
"""Internal method to generate XML nodes for all declarations"""
l = []
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={None: "http://ilk.uvt.nl/folia", 'xml' : "http://www.w3.org/XML/1998/namespace"})
for annotationtype, set in self.annotations:
... | [
"def",
"xmldeclarations",
"(",
"self",
")",
":",
"l",
"=",
"[",
"]",
"E",
"=",
"ElementMaker",
"(",
"namespace",
"=",
"\"http://ilk.uvt.nl/folia\"",
",",
"nsmap",
"=",
"{",
"None",
":",
"\"http://ilk.uvt.nl/folia\"",
",",
"'xml'",
":",
"\"http://www.w3.org/XML/1... | Internal method to generate XML nodes for all declarations | [
"Internal",
"method",
"to",
"generate",
"XML",
"nodes",
"for",
"all",
"declarations"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6653-L6690 | -1 | ||||||
41 | proycon/pynlpl | pynlpl/formats/folia.py | Document.jsondeclarations | def jsondeclarations(self):
"""Return all declarations in a form ready to be serialised to JSON.
Returns:
list of dict
"""
l = []
for annotationtype, set in self.annotations:
label = None
#Find the 'label' for the declarations dynamically (aka... | python | def jsondeclarations(self):
"""Return all declarations in a form ready to be serialised to JSON.
Returns:
list of dict
"""
l = []
for annotationtype, set in self.annotations:
label = None
#Find the 'label' for the declarations dynamically (aka... | [
"def",
"jsondeclarations",
"(",
"self",
")",
":",
"l",
"=",
"[",
"]",
"for",
"annotationtype",
",",
"set",
"in",
"self",
".",
"annotations",
":",
"label",
"=",
"None",
"#Find the 'label' for the declarations dynamically (aka: AnnotationType --> String)",
"for",
"key",... | Return all declarations in a form ready to be serialised to JSON.
Returns:
list of dict | [
"Return",
"all",
"declarations",
"in",
"a",
"form",
"ready",
"to",
"be",
"serialised",
"to",
"JSON",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6692-L6731 | -1 | ||||||
42 | proycon/pynlpl | pynlpl/formats/folia.py | Document.xml | def xml(self):
"""Serialise the document to XML.
Returns:
lxml.etree.Element
See also:
:meth:`Document.xmlstring`
"""
self.pendingvalidation()
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={'xml' : "http://www.w3.org/XML/1998/names... | python | def xml(self):
"""Serialise the document to XML.
Returns:
lxml.etree.Element
See also:
:meth:`Document.xmlstring`
"""
self.pendingvalidation()
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={'xml' : "http://www.w3.org/XML/1998/names... | [
"def",
"xml",
"(",
"self",
")",
":",
"self",
".",
"pendingvalidation",
"(",
")",
"E",
"=",
"ElementMaker",
"(",
"namespace",
"=",
"\"http://ilk.uvt.nl/folia\"",
",",
"nsmap",
"=",
"{",
"'xml'",
":",
"\"http://www.w3.org/XML/1998/namespace\"",
",",
"'xlink'",
":"... | Serialise the document to XML.
Returns:
lxml.etree.Element
See also:
:meth:`Document.xmlstring` | [
"Serialise",
"the",
"document",
"to",
"XML",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6733-L6773 | -1 | ||||||
43 | proycon/pynlpl | pynlpl/formats/folia.py | Document.json | def json(self):
"""Serialise the document to a ``dict`` ready for serialisation to JSON.
Example::
import json
jsondoc = json.dumps(doc.json())
"""
self.pendingvalidation()
jsondoc = {'id': self.id, 'children': [], 'declarations': self.jsondeclarations(... | python | def json(self):
"""Serialise the document to a ``dict`` ready for serialisation to JSON.
Example::
import json
jsondoc = json.dumps(doc.json())
"""
self.pendingvalidation()
jsondoc = {'id': self.id, 'children': [], 'declarations': self.jsondeclarations(... | [
"def",
"json",
"(",
"self",
")",
":",
"self",
".",
"pendingvalidation",
"(",
")",
"jsondoc",
"=",
"{",
"'id'",
":",
"self",
".",
"id",
",",
"'children'",
":",
"[",
"]",
",",
"'declarations'",
":",
"self",
".",
"jsondeclarations",
"(",
")",
"}",
"if",... | Serialise the document to a ``dict`` ready for serialisation to JSON.
Example::
import json
jsondoc = json.dumps(doc.json()) | [
"Serialise",
"the",
"document",
"to",
"a",
"dict",
"ready",
"for",
"serialisation",
"to",
"JSON",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6775-L6794 | -1 | ||||||
44 | proycon/pynlpl | pynlpl/formats/folia.py | Document.xmlmetadata | def xmlmetadata(self):
"""Internal method to serialize metadata to XML"""
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={None: "http://ilk.uvt.nl/folia", 'xml' : "http://www.w3.org/XML/1998/namespace"})
elements = []
if self.metadatatype == "native":
if isinstanc... | python | def xmlmetadata(self):
"""Internal method to serialize metadata to XML"""
E = ElementMaker(namespace="http://ilk.uvt.nl/folia",nsmap={None: "http://ilk.uvt.nl/folia", 'xml' : "http://www.w3.org/XML/1998/namespace"})
elements = []
if self.metadatatype == "native":
if isinstanc... | [
"def",
"xmlmetadata",
"(",
"self",
")",
":",
"E",
"=",
"ElementMaker",
"(",
"namespace",
"=",
"\"http://ilk.uvt.nl/folia\"",
",",
"nsmap",
"=",
"{",
"None",
":",
"\"http://ilk.uvt.nl/folia\"",
",",
"'xml'",
":",
"\"http://www.w3.org/XML/1998/namespace\"",
"}",
")",
... | Internal method to serialize metadata to XML | [
"Internal",
"method",
"to",
"serialize",
"metadata",
"to",
"XML"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6796-L6828 | -1 | ||||||
45 | proycon/pynlpl | pynlpl/formats/folia.py | Document.declare | def declare(self, annotationtype, set, **kwargs):
"""Declare a new annotation type to be used in the document.
Keyword arguments can be used to set defaults for any annotation of this type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the c... | python | def declare(self, annotationtype, set, **kwargs):
"""Declare a new annotation type to be used in the document.
Keyword arguments can be used to set defaults for any annotation of this type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the c... | [
"def",
"declare",
"(",
"self",
",",
"annotationtype",
",",
"set",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"sys",
".",
"version",
">",
"'3'",
"and",
"not",
"isinstance",
"(",
"set",
",",
"str",
")",
")",
"or",
"(",
"sys",
".",
"version",
"<"... | Declare a new annotation type to be used in the document.
Keyword arguments can be used to set defaults for any annotation of this type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation`... | [
"Declare",
"a",
"new",
"annotation",
"type",
"to",
"be",
"used",
"in",
"the",
"document",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L6972-L7018 | -1 | ||||||
46 | proycon/pynlpl | pynlpl/formats/folia.py | Document.defaultset | def defaultset(self, annotationtype):
"""Obtain the default set for the specified annotation type.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or a member of :class:`Annotatio... | python | def defaultset(self, annotationtype):
"""Obtain the default set for the specified annotation type.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or a member of :class:`Annotatio... | [
"def",
"defaultset",
"(",
"self",
",",
"annotationtype",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"annotationtype",
")",
"or",
"isinstance",
"(",
"annotationtype",
",",
"AbstractElement",
")",
":",
"annotationtype",
"=",
"annotationtype",
".",
"ANNOTATION... | Obtain the default set for the specified annotation type.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or a member of :class:`AnnotationType`, such as ``AnnotationType.POS``.
... | [
"Obtain",
"the",
"default",
"set",
"for",
"the",
"specified",
"annotation",
"type",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7039-L7058 | -1 | ||||||
47 | proycon/pynlpl | pynlpl/formats/folia.py | Document.defaultannotator | def defaultannotator(self, annotationtype, set=None):
"""Obtain the default annotator for the specified annotation type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or... | python | def defaultannotator(self, annotationtype, set=None):
"""Obtain the default annotator for the specified annotation type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or... | [
"def",
"defaultannotator",
"(",
"self",
",",
"annotationtype",
",",
"set",
"=",
"None",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"annotationtype",
")",
"or",
"isinstance",
"(",
"annotationtype",
",",
"AbstractElement",
")",
":",
"annotationtype",
"=",
... | Obtain the default annotator for the specified annotation type and set.
Arguments:
annotationtype: The type of annotation, this is conveyed by passing the corresponding annototion class (such as :class:`PosAnnotation` for example), or a member of :class:`AnnotationType`, such as ``AnnotationType.PO... | [
"Obtain",
"the",
"default",
"annotator",
"for",
"the",
"specified",
"annotation",
"type",
"and",
"set",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7061-L7080 | -1 | ||||||
48 | proycon/pynlpl | pynlpl/formats/folia.py | Document.parsemetadata | def parsemetadata(self, node):
"""Internal method to parse metadata"""
if 'type' in node.attrib:
self.metadatatype = node.attrib['type']
else:
#no type specified, default to native
self.metadatatype = "native"
if 'src' in node.attrib:
sel... | python | def parsemetadata(self, node):
"""Internal method to parse metadata"""
if 'type' in node.attrib:
self.metadatatype = node.attrib['type']
else:
#no type specified, default to native
self.metadatatype = "native"
if 'src' in node.attrib:
sel... | [
"def",
"parsemetadata",
"(",
"self",
",",
"node",
")",
":",
"if",
"'type'",
"in",
"node",
".",
"attrib",
":",
"self",
".",
"metadatatype",
"=",
"node",
".",
"attrib",
"[",
"'type'",
"]",
"else",
":",
"#no type specified, default to native",
"self",
".",
"m... | Internal method to parse metadata | [
"Internal",
"method",
"to",
"parse",
"metadata"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7216-L7261 | -1 | ||||||
49 | proycon/pynlpl | pynlpl/formats/folia.py | Document.pendingvalidation | def pendingvalidation(self, warnonly=None):
"""Perform any pending validations
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based on the document's FoLiA version (Warn only before FoLiA v1.5)
Returns:
... | python | def pendingvalidation(self, warnonly=None):
"""Perform any pending validations
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based on the document's FoLiA version (Warn only before FoLiA v1.5)
Returns:
... | [
"def",
"pendingvalidation",
"(",
"self",
",",
"warnonly",
"=",
"None",
")",
":",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"[PyNLPl FoLiA DEBUG] Processing pending validations (if any)\"",
",",
"file",
"=",
"stderr",
")",
"if",
"warnonly",
"is",
"None",
"... | Perform any pending validations
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based on the document's FoLiA version (Warn only before FoLiA v1.5)
Returns:
bool | [
"Perform",
"any",
"pending",
"validations"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7396-L7424 | -1 | ||||||
50 | proycon/pynlpl | pynlpl/formats/folia.py | Document.paragraphs | def paragraphs(self, index = None):
"""Return a generator of all paragraphs found in the document.
If an index is specified, return the n'th paragraph only (starting at 0)"""
if index is None:
return self.select(Paragraph)
else:
if index < 0:
inde... | python | def paragraphs(self, index = None):
"""Return a generator of all paragraphs found in the document.
If an index is specified, return the n'th paragraph only (starting at 0)"""
if index is None:
return self.select(Paragraph)
else:
if index < 0:
inde... | [
"def",
"paragraphs",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"return",
"self",
".",
"select",
"(",
"Paragraph",
")",
"else",
":",
"if",
"index",
"<",
"0",
":",
"index",
"=",
"sum",
"(",
"t",
".",
"count... | Return a generator of all paragraphs found in the document.
If an index is specified, return the n'th paragraph only (starting at 0) | [
"Return",
"a",
"generator",
"of",
"all",
"paragraphs",
"found",
"in",
"the",
"document",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7445-L7458 | -1 | ||||||
51 | proycon/pynlpl | pynlpl/formats/folia.py | Document.sentences | def sentences(self, index = None):
"""Return a generator of all sentence found in the document. Except for sentences in quotes.
If an index is specified, return the n'th sentence only (starting at 0)"""
if index is None:
return self.select(Sentence,None,True,[Quote])
else:
... | python | def sentences(self, index = None):
"""Return a generator of all sentence found in the document. Except for sentences in quotes.
If an index is specified, return the n'th sentence only (starting at 0)"""
if index is None:
return self.select(Sentence,None,True,[Quote])
else:
... | [
"def",
"sentences",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"return",
"self",
".",
"select",
"(",
"Sentence",
",",
"None",
",",
"True",
",",
"[",
"Quote",
"]",
")",
"else",
":",
"if",
"index",
"<",
"0",... | Return a generator of all sentence found in the document. Except for sentences in quotes.
If an index is specified, return the n'th sentence only (starting at 0) | [
"Return",
"a",
"generator",
"of",
"all",
"sentence",
"found",
"in",
"the",
"document",
".",
"Except",
"for",
"sentences",
"in",
"quotes",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L7460-L7473 | -1 |
Dataset Card for "code_x_glue_tc_nl_code_search_adv"
Dataset Summary
CodeXGLUE NL-code-search-Adv dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Text-Code/NL-code-search-Adv
The dataset we use comes from CodeSearchNet and we filter the dataset as the following:
- Remove examples that codes cannot be parsed into an abstract syntax tree.
- Remove examples that #tokens of documents is < 3 or >256
- Remove examples that documents contain special tokens (e.g. <img ...> or https:...)
- Remove examples that documents are not English.
Supported Tasks and Leaderboards
document-retrieval: The dataset can be used to train a model for retrieving top-k codes from a given English natural language query.
Languages
- Python programming language
- English natural language
Dataset Structure
Data Instances
An example of 'validation' looks as follows.
{
"argument_list": "",
"code": "def Func(arg_0, arg_1='.', arg_2=True, arg_3=False, **arg_4):\n \"\"\"Downloads Dailymotion videos by URL.\n \"\"\"\n\n arg_5 = get_content(rebuilt_url(arg_0))\n arg_6 = json.loads(match1(arg_5, r'qualities\":({.+?}),\"'))\n arg_7 = match1(arg_5, r'\"video_title\"\\s*:\\s*\"([^\"]+)\"') or \\\n match1(arg_5, r'\"title\"\\s*:\\s*\"([^\"]+)\"')\n arg_7 = unicodize(arg_7)\n\n for arg_8 in ['1080','720','480','380','240','144','auto']:\n try:\n arg_9 = arg_6[arg_8][1][\"url\"]\n if arg_9:\n break\n except KeyError:\n pass\n\n arg_10, arg_11, arg_12 = url_info(arg_9)\n\n print_info(site_info, arg_7, arg_10, arg_12)\n if not arg_3:\n download_urls([arg_9], arg_7, arg_11, arg_12, arg_1=arg_1, arg_2=arg_2)",
"code_tokens": ["def", "Func", "(", "arg_0", ",", "arg_1", "=", "'.'", ",", "arg_2", "=", "True", ",", "arg_3", "=", "False", ",", "**", "arg_4", ")", ":", "arg_5", "=", "get_content", "(", "rebuilt_url", "(", "arg_0", ")", ")", "arg_6", "=", "json", ".", "loads", "(", "match1", "(", "arg_5", ",", "r'qualities\":({.+?}),\"'", ")", ")", "arg_7", "=", "match1", "(", "arg_5", ",", "r'\"video_title\"\\s*:\\s*\"([^\"]+)\"'", ")", "or", "match1", "(", "arg_5", ",", "r'\"title\"\\s*:\\s*\"([^\"]+)\"'", ")", "arg_7", "=", "unicodize", "(", "arg_7", ")", "for", "arg_8", "in", "[", "'1080'", ",", "'720'", ",", "'480'", ",", "'380'", ",", "'240'", ",", "'144'", ",", "'auto'", "]", ":", "try", ":", "arg_9", "=", "arg_6", "[", "arg_8", "]", "[", "1", "]", "[", "\"url\"", "]", "if", "arg_9", ":", "break", "except", "KeyError", ":", "pass", "arg_10", ",", "arg_11", ",", "arg_12", "=", "url_info", "(", "arg_9", ")", "print_info", "(", "site_info", ",", "arg_7", ",", "arg_10", ",", "arg_12", ")", "if", "not", "arg_3", ":", "download_urls", "(", "[", "arg_9", "]", ",", "arg_7", ",", "arg_11", ",", "arg_12", ",", "arg_1", "=", "arg_1", ",", "arg_2", "=", "arg_2", ")"],
"docstring": "Downloads Dailymotion videos by URL.",
"docstring_summary": "Downloads Dailymotion videos by URL.",
"docstring_tokens": ["Downloads", "Dailymotion", "videos", "by", "URL", "."],
"func_name": "",
"id": 0,
"identifier": "dailymotion_download",
"language": "python",
"nwo": "soimort/you-get",
"original_string": "",
"parameters": "(url, output_dir='.', merge=True, info_only=False, **kwargs)",
"path": "src/you_get/extractors/dailymotion.py",
"repo": "",
"return_statement": "",
"score": 0.9997601509094238,
"sha": "b746ac01c9f39de94cac2d56f665285b0523b974",
"url": "https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/dailymotion.py#L13-L35"
}
Data Fields
In the following each data field in go is explained for each config. The data fields are the same among all splits.
default
| field name | type | description |
|---|---|---|
| id | int32 | Index of the sample |
| repo | string | repo: the owner/repo |
| path | string | path: the full path to the original file |
| func_name | string | func_name: the function or method name |
| original_string | string | original_string: the raw string before tokenization or parsing |
| language | string | language: the programming language |
| code | string | code/function: the part of the original_string that is code |
| code_tokens | Sequence[string] | code_tokens/function_tokens: tokenized version of code |
| docstring | string | docstring: the top-level comment or docstring, if it exists in the original string |
| docstring_tokens | Sequence[string] | docstring_tokens: tokenized version of docstring |
| sha | string | sha of the file |
| url | string | url of the file |
| docstring_summary | string | Summary of the docstring |
| parameters | string | parameters of the function |
| return_statement | string | return statement |
| argument_list | string | list of arguments of the function |
| identifier | string | identifier |
| nwo | string | nwo |
| score | datasets.Value("float"] | score for this search |
Data Splits
| name | train | validation | test |
|---|---|---|---|
| default | 251820 | 9604 | 19210 |
Dataset Creation
Curation Rationale
[More Information Needed]
Source Data
Initial Data Collection and Normalization
Data from CodeSearchNet Challenge dataset. [More Information Needed]
Who are the source language producers?
Software Engineering developers.
Annotations
Annotation process
[More Information Needed]
Who are the annotators?
[More Information Needed]
Personal and Sensitive Information
[More Information Needed]
Considerations for Using the Data
Social Impact of Dataset
[More Information Needed]
Discussion of Biases
[More Information Needed]
Other Known Limitations
[More Information Needed]
Additional Information
Dataset Curators
https://github.com/microsoft, https://github.com/madlag
Licensing Information
Computational Use of Data Agreement (C-UDA) License.
Citation Information
@article{DBLP:journals/corr/abs-2102-04664,
author = {Shuai Lu and
Daya Guo and
Shuo Ren and
Junjie Huang and
Alexey Svyatkovskiy and
Ambrosio Blanco and
Colin B. Clement and
Dawn Drain and
Daxin Jiang and
Duyu Tang and
Ge Li and
Lidong Zhou and
Linjun Shou and
Long Zhou and
Michele Tufano and
Ming Gong and
Ming Zhou and
Nan Duan and
Neel Sundaresan and
Shao Kun Deng and
Shengyu Fu and
Shujie Liu},
title = {CodeXGLUE: {A} Machine Learning Benchmark Dataset for Code Understanding
and Generation},
journal = {CoRR},
volume = {abs/2102.04664},
year = {2021}
}
@article{husain2019codesearchnet,
title={Codesearchnet challenge: Evaluating the state of semantic code search},
author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc},
journal={arXiv preprint arXiv:1909.09436},
year={2019}
}
Contributions
Thanks to @madlag (and partly also @ncoop57) for adding this dataset.
- Downloads last month
- 280