repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.addidsuffix | def addidsuffix(self, idsuffix, recursive = True):
"""Appends a suffix to this element's ID, and optionally to all child IDs as well. There is sually no need to call this directly, invoked implicitly by :meth:`copy`"""
if self.id: self.id += idsuffix
if recursive:
for e in self:
... | python | def addidsuffix(self, idsuffix, recursive = True):
"""Appends a suffix to this element's ID, and optionally to all child IDs as well. There is sually no need to call this directly, invoked implicitly by :meth:`copy`"""
if self.id: self.id += idsuffix
if recursive:
for e in self:
... | Appends a suffix to this element's ID, and optionally to all child IDs as well. There is sually no need to call this directly, invoked implicitly by :meth:`copy` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1263-L1271 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.setparents | def setparents(self):
"""Correct all parent relations for elements within the scop. There is sually no need to call this directly, invoked implicitly by :meth:`copy`"""
for c in self:
if isinstance(c, AbstractElement):
c.parent = self
c.setparents() | python | def setparents(self):
"""Correct all parent relations for elements within the scop. There is sually no need to call this directly, invoked implicitly by :meth:`copy`"""
for c in self:
if isinstance(c, AbstractElement):
c.parent = self
c.setparents() | Correct all parent relations for elements within the scop. There is sually no need to call this directly, invoked implicitly by :meth:`copy` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1273-L1278 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.setdoc | def setdoc(self,newdoc):
"""Set a different document. Usually no need to call this directly, invoked implicitly by :meth:`copy`"""
self.doc = newdoc
if self.doc and self.id:
self.doc.index[self.id] = self
for c in self:
if isinstance(c, AbstractElement):
... | python | def setdoc(self,newdoc):
"""Set a different document. Usually no need to call this directly, invoked implicitly by :meth:`copy`"""
self.doc = newdoc
if self.doc and self.id:
self.doc.index[self.id] = self
for c in self:
if isinstance(c, AbstractElement):
... | Set a different document. Usually no need to call this directly, invoked implicitly by :meth:`copy` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1280-L1287 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.hastext | def hastext(self,cls='current',strict=True, correctionhandling=CorrectionHandling.CURRENT): #pylint: disable=too-many-return-statements
"""Does this element have text (of the specified class)
By default, and unlike :meth:`text`, this checks strictly, i.e. the element itself must have the text and it is... | python | def hastext(self,cls='current',strict=True, correctionhandling=CorrectionHandling.CURRENT): #pylint: disable=too-many-return-statements
"""Does this element have text (of the specified class)
By default, and unlike :meth:`text`, this checks strictly, i.e. the element itself must have the text and it is... | Does this element have text (of the specified class)
By default, and unlike :meth:`text`, this checks strictly, i.e. the element itself must have the text and it is not inherited from its children.
Parameters:
cls (str): The class of the text content to obtain, defaults to ``current``.
... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1289-L1321 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.hasphon | def hasphon(self,cls='current',strict=True,correctionhandling=CorrectionHandling.CURRENT): #pylint: disable=too-many-return-statements
"""Does this element have phonetic content (of the specified class)
By default, and unlike :meth:`phon`, this checks strictly, i.e. the element itself must have the pho... | python | def hasphon(self,cls='current',strict=True,correctionhandling=CorrectionHandling.CURRENT): #pylint: disable=too-many-return-statements
"""Does this element have phonetic content (of the specified class)
By default, and unlike :meth:`phon`, this checks strictly, i.e. the element itself must have the pho... | Does this element have phonetic content (of the specified class)
By default, and unlike :meth:`phon`, this checks strictly, i.e. the element itself must have the phonetic content and it is not inherited from its children.
Parameters:
cls (str): The class of the phonetic content to obtain, ... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1323-L1355 |
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... | 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. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1357-L1364 |
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
... | Associate a document with this element.
Arguments:
doc (:class:`Document`): A document
Each element must be associated with a FoLiA document. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1366-L1385 |
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... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1406-L1455 |
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.
"... | 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. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1458-L1471 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.deepvalidation | def deepvalidation(self):
"""Perform deep validation of this element.
Raises:
:class:`DeepValidationError`
"""
if self.doc and self.doc.deepvalidation and self.set and self.set[0] != '_':
try:
self.doc.setdefinitions[self.set].testclass(self.cls)
... | python | def deepvalidation(self):
"""Perform deep validation of this element.
Raises:
:class:`DeepValidationError`
"""
if self.doc and self.doc.deepvalidation and self.set and self.set[0] != '_':
try:
self.doc.setdefinitions[self.set].testclass(self.cls)
... | Perform deep validation of this element.
Raises:
:class:`DeepValidationError` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1486-L1503 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.findreplaceables | def findreplaceables(Class, parent, set=None,**kwargs):
"""Internal method to find replaceable elements. Auxiliary function used by :meth:`AbstractElement.replace`. Can be overriden for more fine-grained control."""
return list(parent.select(Class,set,False)) | python | def findreplaceables(Class, parent, set=None,**kwargs):
"""Internal method to find replaceable elements. Auxiliary function used by :meth:`AbstractElement.replace`. Can be overriden for more fine-grained control."""
return list(parent.select(Class,set,False)) | Internal method to find replaceable elements. Auxiliary function used by :meth:`AbstractElement.replace`. Can be overriden for more fine-grained control. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1766-L1768 |
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... | Recompute textual value based on the text content of the children. Only supported on elements that are a ``TEXTCONTAINER`` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1772-L1782 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.replace | def replace(self, child, *args, **kwargs):
"""Appends a child element like ``append()``, but replaces any existing child element of the same type and set. If no such child element exists, this will act the same as append()
Keyword arguments:
alternative (bool): If set to True, the *replaced... | python | def replace(self, child, *args, **kwargs):
"""Appends a child element like ``append()``, but replaces any existing child element of the same type and set. If no such child element exists, this will act the same as append()
Keyword arguments:
alternative (bool): If set to True, the *replaced... | Appends a child element like ``append()``, but replaces any existing child element of the same type and set. If no such child element exists, this will act the same as append()
Keyword arguments:
alternative (bool): If set to True, the *replaced* element will be made into an alternative. Simply use... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1784-L1838 |
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!
... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1840-L1860 |
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... | 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) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1862-L1874 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.xml | def xml(self, attribs = None,elements = None, skipchildren = False):
"""Serialises the FoLiA element and all its contents to XML.
Arguments are mostly for internal use.
Returns:
an lxml.etree.Element
See also:
:meth:`AbstractElement.xmlstring` - for direct stri... | python | def xml(self, attribs = None,elements = None, skipchildren = False):
"""Serialises the FoLiA element and all its contents to XML.
Arguments are mostly for internal use.
Returns:
an lxml.etree.Element
See also:
:meth:`AbstractElement.xmlstring` - for direct stri... | Serialises the FoLiA element and all its contents to XML.
Arguments are mostly for internal use.
Returns:
an lxml.etree.Element
See also:
:meth:`AbstractElement.xmlstring` - for direct string output | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1877-L2047 |
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... | 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 | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2050-L2110 |
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... | Serialises this FoLiA element and all its contents to XML.
Returns:
str: a string with XML representation for this element and all its children | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2114-L2129 |
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... | 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 ... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2132-L2201 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.count | def count(self, Class, set=None, recursive=True, ignore=True, node=None):
"""Like :meth:`AbstractElement.select`, but instead of returning the elements, it merely counts them.
Returns:
int
"""
return sum(1 for i in self.select(Class,set,recursive,ignore,node) ) | python | def count(self, Class, set=None, recursive=True, ignore=True, node=None):
"""Like :meth:`AbstractElement.select`, but instead of returning the elements, it merely counts them.
Returns:
int
"""
return sum(1 for i in self.select(Class,set,recursive,ignore,node) ) | Like :meth:`AbstractElement.select`, but instead of returning the elements, it merely counts them.
Returns:
int | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2203-L2209 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.items | def items(self, founditems=[]): #pylint: disable=dangerous-default-value
"""Returns a depth-first flat list of *all* items below this element (not limited to AbstractElement)"""
l = []
for e in self.data:
if e not in founditems: #prevent going in recursive loops
l.ap... | python | def items(self, founditems=[]): #pylint: disable=dangerous-default-value
"""Returns a depth-first flat list of *all* items below this element (not limited to AbstractElement)"""
l = []
for e in self.data:
if e not in founditems: #prevent going in recursive loops
l.ap... | Returns a depth-first flat list of *all* items below this element (not limited to AbstractElement) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2211-L2219 |
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:
... | Get the metadata that applies to this element, automatically inherited from parent elements | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2221-L2234 |
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... | Get the index at which an element occurs, recursive by default!
Returns:
int | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2238-L2278 |
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... | Returns a boolean indicating whether this element precedes the other element | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2280-L2296 |
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... | Generic depth first search algorithm using a callback function, continues as long as the callback function returns None | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2299-L2308 |
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... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2310-L2367 |
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 ... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2371-L2379 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.leftcontext | def leftcontext(self, size, placeholder=None, scope=None):
"""Returns the left context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope"""
if size == 0: return [] #for efficiency
context = []
e = self
... | python | def leftcontext(self, size, placeholder=None, scope=None):
"""Returns the left context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope"""
if size == 0: return [] #for efficiency
context = []
e = self
... | Returns the left context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2381-L2398 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.rightcontext | def rightcontext(self, size, placeholder=None, scope=None):
"""Returns the right context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope"""
if size == 0: return [] #for efficiency
context = []
e = self
... | python | def rightcontext(self, size, placeholder=None, scope=None):
"""Returns the right context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope"""
if size == 0: return [] #for efficiency
context = []
e = self
... | Returns the right context for an element, as a list. This method crosses sentence/paragraph boundaries by default, which can be restricted by setting scope | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2401-L2417 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.context | def context(self, size, placeholder=None, scope=None):
"""Returns this word in context, {size} words to the left, the current word, and {size} words to the right"""
return self.leftcontext(size, placeholder,scope) + [self] + self.rightcontext(size, placeholder,scope) | python | def context(self, size, placeholder=None, scope=None):
"""Returns this word in context, {size} words to the left, the current word, and {size} words to the right"""
return self.leftcontext(size, placeholder,scope) + [self] + self.rightcontext(size, placeholder,scope) | Returns this word in context, {size} words to the left, the current word, and {size} words to the right | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2419-L2421 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.relaxng | def relaxng(cls, includechildren=True,extraattribs = None, extraelements=None, origclass = None):
"""Returns a RelaxNG definition for this element (as an XML element (lxml.etree) rather than a string)"""
E = ElementMaker(namespace="http://relaxng.org/ns/structure/1.0",nsmap={None:'http://relaxng.org/ns... | python | def relaxng(cls, includechildren=True,extraattribs = None, extraelements=None, origclass = None):
"""Returns a RelaxNG definition for this element (as an XML element (lxml.etree) rather than a string)"""
E = ElementMaker(namespace="http://relaxng.org/ns/structure/1.0",nsmap={None:'http://relaxng.org/ns... | Returns a RelaxNG definition for this element (as an XML element (lxml.etree) rather than a string) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2424-L2579 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.parsexml | def parsexml(Class, node, doc, **kwargs): #pylint: disable=bad-classmethod-argument
"""Internal class method used for turning an XML element into an instance of the Class.
Args:
* ``node`` - XML Element
* ``doc`` - Document
Returns:
An instance of the curren... | python | def parsexml(Class, node, doc, **kwargs): #pylint: disable=bad-classmethod-argument
"""Internal class method used for turning an XML element into an instance of the Class.
Args:
* ``node`` - XML Element
* ``doc`` - Document
Returns:
An instance of the curren... | Internal class method used for turning an XML element into an instance of the Class.
Args:
* ``node`` - XML Element
* ``doc`` - Document
Returns:
An instance of the current Class. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2582-L2724 |
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... | Removes the child element | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2729-L2738 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.incorrection | def incorrection(self):
"""Is this element part of a correction? If it is, it returns the Correction element (evaluating to True), otherwise it returns None"""
e = self.parent
while e:
if isinstance(e, Correction):
return e
if isinstance(e, AbstractStruct... | python | def incorrection(self):
"""Is this element part of a correction? If it is, it returns the Correction element (evaluating to True), otherwise it returns None"""
e = self.parent
while e:
if isinstance(e, Correction):
return e
if isinstance(e, AbstractStruct... | Is this element part of a correction? If it is, it returns the Correction element (evaluating to True), otherwise it returns None | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2740-L2750 |
proycon/pynlpl | pynlpl/formats/folia.py | AllowCorrections.correct | def correct(self, **kwargs):
"""Apply a correction (TODO: documentation to be written still)"""
if 'insertindex_offset' in kwargs:
del kwargs['insertindex_offset'] #dealt with in an earlier stage
if 'confidence' in kwargs and kwargs['confidence'] is None:
del kwargs['co... | python | def correct(self, **kwargs):
"""Apply a correction (TODO: documentation to be written still)"""
if 'insertindex_offset' in kwargs:
del kwargs['insertindex_offset'] #dealt with in an earlier stage
if 'confidence' in kwargs and kwargs['confidence'] is None:
del kwargs['co... | Apply a correction (TODO: documentation to be written still) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L2856-L3007 |
proycon/pynlpl | pynlpl/formats/folia.py | AllowTokenAnnotation.annotations | def annotations(self,Class,set=None):
"""Obtain child elements (annotations) 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`
Se... | python | def annotations(self,Class,set=None):
"""Obtain child elements (annotations) 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`
Se... | Obtain child elements (annotations) 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 ... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3015-L3044 |
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)) | Returns an integer indicating whether such as annotation exists, and if so, how many.
See :meth:`AllowTokenAnnotation.annotations`` for a description of the parameters. | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3046-L3050 |
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... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3052-L3078 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.append | def append(self, child, *args, **kwargs):
"""See ``AbstractElement.append()``"""
e = super(AbstractStructureElement,self).append(child, *args, **kwargs)
self._setmaxid(e)
return e | python | def append(self, child, *args, **kwargs):
"""See ``AbstractElement.append()``"""
e = super(AbstractStructureElement,self).append(child, *args, **kwargs)
self._setmaxid(e)
return e | See ``AbstractElement.append()`` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3202-L3206 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.words | def words(self, index = None):
"""Returns a generator of Word elements found (recursively) under this element.
Arguments:
* ``index``: If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all
"""
if index is None:
... | python | def words(self, index = None):
"""Returns a generator of Word elements found (recursively) under this element.
Arguments:
* ``index``: If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all
"""
if index is None:
... | Returns a generator of Word elements found (recursively) under this element.
Arguments:
* ``index``: If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning the list of all | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3214-L3228 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.paragraphs | def paragraphs(self, index = None):
"""Returns a generator of Paragraph elements found (recursively) under this element.
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 generator of all
"""
... | python | def paragraphs(self, index = None):
"""Returns a generator of Paragraph elements found (recursively) under this element.
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 generator of all
"""
... | Returns a generator of Paragraph elements found (recursively) under this element.
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 generator of all | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3231-L3245 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.sentences | def sentences(self, index = None):
"""Returns a generator of Sentence elements found (recursively) under this element
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning a generator of all
"""
i... | python | def sentences(self, index = None):
"""Returns a generator of Sentence elements found (recursively) under this element
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning a generator of all
"""
i... | Returns a generator of Sentence elements found (recursively) under this element
Arguments:
index (int or None): If set to an integer, will retrieve and return the n'th element (starting at 0) instead of returning a generator of all | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3247-L3261 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractStructureElement.layers | def layers(self, annotationtype=None,set=None):
"""Returns a list of annotation layers found *directly* under this element, does not include alternative layers"""
if inspect.isclass(annotationtype): annotationtype = annotationtype.ANNOTATIONTYPE
return [ x for x in self.select(AbstractAnnotation... | python | def layers(self, annotationtype=None,set=None):
"""Returns a list of annotation layers found *directly* under this element, does not include alternative layers"""
if inspect.isclass(annotationtype): annotationtype = annotationtype.ANNOTATIONTYPE
return [ x for x in self.select(AbstractAnnotation... | Returns a list of annotation layers found *directly* under this element, does not include alternative layers | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3263-L3266 |
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) | Does the specified annotation layer exist? | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3268-L3271 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractTextMarkup.xml | def xml(self, attribs = None,elements = None, skipchildren = False):
"""See :meth:`AbstractElement.xml`"""
if not attribs: attribs = {}
if self.idref:
attribs['id'] = self.idref
return super(AbstractTextMarkup,self).xml(attribs,elements, skipchildren) | python | def xml(self, attribs = None,elements = None, skipchildren = False):
"""See :meth:`AbstractElement.xml`"""
if not attribs: attribs = {}
if self.idref:
attribs['id'] = self.idref
return super(AbstractTextMarkup,self).xml(attribs,elements, skipchildren) | See :meth:`AbstractElement.xml` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3336-L3341 |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractTextMarkup.json | def json(self,attribs =None, recurse=True, ignorelist=False):
"""See :meth:`AbstractElement.json`"""
if not attribs: attribs = {}
if self.idref:
attribs['id'] = self.idref
return super(AbstractTextMarkup,self).json(attribs,recurse, ignorelist) | python | def json(self,attribs =None, recurse=True, ignorelist=False):
"""See :meth:`AbstractElement.json`"""
if not attribs: attribs = {}
if self.idref:
attribs['id'] = self.idref
return super(AbstractTextMarkup,self).json(attribs,recurse, ignorelist) | See :meth:`AbstractElement.json` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3343-L3348 |
proycon/pynlpl | pynlpl/formats/folia.py | TextContent.text | def text(self, normalize_spaces=False):
"""Obtain the text (unicode instance)"""
return super(TextContent,self).text(normalize_spaces=normalize_spaces) | python | def text(self, normalize_spaces=False):
"""Obtain the text (unicode instance)"""
return super(TextContent,self).text(normalize_spaces=normalize_spaces) | Obtain the text (unicode instance) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3490-L3492 |
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... | Returns and validates the Text Content's reference. Raises UnresolvableTextContent when invalid | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3502-L3519 |
proycon/pynlpl | pynlpl/formats/folia.py | TextContent.xml | def xml(self, attribs = None,elements = None, skipchildren = False):
"""See :meth:`AbstractElement.xml`"""
attribs = {}
if not self.offset is None:
attribs['{' + NSFOLIA + '}offset'] = str(self.offset)
if self.parent and self.ref:
attribs['{' + NSFOLIA + '}ref'] =... | python | def xml(self, attribs = None,elements = None, skipchildren = False):
"""See :meth:`AbstractElement.xml`"""
attribs = {}
if not self.offset is None:
attribs['{' + NSFOLIA + '}offset'] = str(self.offset)
if self.parent and self.ref:
attribs['{' + NSFOLIA + '}ref'] =... | See :meth:`AbstractElement.xml` | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3596-L3616 |
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... | Return and validate the Phonetic Content's reference. Raises UnresolvableTextContent when invalid | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3715-L3732 |
proycon/pynlpl | pynlpl/formats/folia.py | PhonContent.finddefaultreference | def finddefaultreference(self):
"""Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually e... | python | def finddefaultreference(self):
"""Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually e... | Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3765-L3787 |
proycon/pynlpl | pynlpl/formats/folia.py | PhonContent.findreplaceables | def findreplaceables(Class, parent, set, **kwargs):#pylint: disable=bad-classmethod-argument
"""(Method for internal usage, see AbstractElement)"""
#some extra behaviour for text content elements, replace also based on the 'corrected' attribute:
if 'cls' not in kwargs:
kwargs['cls'] ... | python | def findreplaceables(Class, parent, set, **kwargs):#pylint: disable=bad-classmethod-argument
"""(Method for internal usage, see AbstractElement)"""
#some extra behaviour for text content elements, replace also based on the 'corrected' attribute:
if 'cls' not in kwargs:
kwargs['cls'] ... | (Method for internal usage, see AbstractElement) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3796-L3804 |
proycon/pynlpl | pynlpl/formats/folia.py | PhonContent.parsexml | def parsexml(Class, node, doc, **kwargs):#pylint: disable=bad-classmethod-argument
"""(Method for internal usage, see AbstractElement)"""
if not kwargs: kwargs = {}
if 'offset' in node.attrib:
kwargs['offset'] = int(node.attrib['offset'])
if 'ref' in node.attrib:
... | python | def parsexml(Class, node, doc, **kwargs):#pylint: disable=bad-classmethod-argument
"""(Method for internal usage, see AbstractElement)"""
if not kwargs: kwargs = {}
if 'offset' in node.attrib:
kwargs['offset'] = int(node.attrib['offset'])
if 'ref' in node.attrib:
... | (Method for internal usage, see AbstractElement) | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3808-L3815 |
proycon/pynlpl | pynlpl/formats/folia.py | Word.morphemes | def morphemes(self,set=None):
"""Generator yielding all morphemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead"""
for layer in self.select(MorphologyLayer):
for m in layer.select(Morpheme, set):
yield m | python | def morphemes(self,set=None):
"""Generator yielding all morphemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead"""
for layer in self.select(MorphologyLayer):
for m in layer.select(Morpheme, set):
yield m | Generator yielding all morphemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4081-L4085 |
proycon/pynlpl | pynlpl/formats/folia.py | Word.phonemes | def phonemes(self,set=None):
"""Generator yielding all phonemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead"""
for layer in self.select(PhonologyLayer):
for p in layer.select(Phoneme, set):
yield p | python | def phonemes(self,set=None):
"""Generator yielding all phonemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead"""
for layer in self.select(PhonologyLayer):
for p in layer.select(Phoneme, set):
yield p | Generator yielding all phonemes (in a particular set if specified). For retrieving one specific morpheme by index, use morpheme() instead | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4087-L4091 |
proycon/pynlpl | pynlpl/formats/folia.py | Word.morpheme | def morpheme(self,index, set=None):
"""Returns a specific morpheme, the n'th morpheme (given the particular set if specified)."""
for layer in self.select(MorphologyLayer):
for i, m in enumerate(layer.select(Morpheme, set)):
if index == i:
return m
... | python | def morpheme(self,index, set=None):
"""Returns a specific morpheme, the n'th morpheme (given the particular set if specified)."""
for layer in self.select(MorphologyLayer):
for i, m in enumerate(layer.select(Morpheme, set)):
if index == i:
return m
... | Returns a specific morpheme, the n'th morpheme (given the particular set if specified). | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4093-L4099 |
proycon/pynlpl | pynlpl/formats/folia.py | Word.phoneme | def phoneme(self,index, set=None):
"""Returns a specific phoneme, the n'th morpheme (given the particular set if specified)."""
for layer in self.select(PhonologyLayer):
for i, p in enumerate(layer.select(Phoneme, set)):
if index == i:
return p
rai... | python | def phoneme(self,index, set=None):
"""Returns a specific phoneme, the n'th morpheme (given the particular set if specified)."""
for layer in self.select(PhonologyLayer):
for i, p in enumerate(layer.select(Phoneme, set)):
if index == i:
return p
rai... | Returns a specific phoneme, the n'th morpheme (given the particular set if specified). | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4102-L4108 |
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:`... | 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... | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L4178-L4213 |
CodeSearchNet
This is an unofficial reupload of the code_search_net dataset in the parquet format. I have also removed the columns func_code_tokens, func_documentation_tokens, and split_name as they are not relevant. The original repository relies on a Python module that is downloaded and executed to unpack the dataset, which is a potential security risk but importantly raises an annoying warning. As a plus, parquets load faster.
Original model card:
Dataset Card for CodeSearchNet corpus
Dataset Summary
CodeSearchNet corpus is a dataset of 2 milllion (comment, code) pairs from opensource libraries hosted on GitHub. It contains code and documentation for several programming languages.
CodeSearchNet corpus was gathered to support the CodeSearchNet challenge, to explore the problem of code retrieval using natural language.
Supported Tasks and Leaderboards
language-modeling: The dataset can be used to train a model for modelling programming languages, which consists in building language models for programming languages.
Languages
- Go programming language
- Java programming language
- Javascript programming language
- PHP programming language
- Python programming language
- Ruby programming language
Dataset Structure
Data Instances
A data point consists of a function code along with its documentation. Each data point also contains meta data on the function, such as the repository it was extracted from.
{
'id': '0',
'repository_name': 'organisation/repository',
'func_path_in_repository': 'src/path/to/file.py',
'func_name': 'func',
'whole_func_string': 'def func(args):\n"""Docstring"""\n [...]',
'language': 'python',
'func_code_string': '[...]',
'func_code_tokens': ['def', 'func', '(', 'args', ')', ...],
'func_documentation_string': 'Docstring',
'func_documentation_string_tokens': ['Docstring'],
'split_name': 'train',
'func_code_url': 'https://github.com/<org>/<repo>/blob/<hash>/src/path/to/file.py#L111-L150'
}
Data Fields
id: Arbitrary numberrepository_name: name of the GitHub repositoryfunc_path_in_repository: tl;dr: path to the file which holds the function in the repositoryfunc_name: name of the function in the filewhole_func_string: Code + documentation of the functionlanguage: Programming language in whoch the function is writtenfunc_code_string: Function codefunc_code_tokens: Tokens yielded by Treesitterfunc_documentation_string: Function documentationfunc_documentation_string_tokens: Tokens yielded by Treesittersplit_name: Name of the split to which the example belongs (one of train, test or valid)func_code_url: URL to the function code on Github
Data Splits
Three splits are available:
- train
- test
- valid
Dataset Creation
Curation Rationale
[More Information Needed]
Source Data
Initial Data Collection and Normalization
All information can be retrieved in the original technical review
Corpus collection:
Corpus has been collected from publicly available open-source non-fork GitHub repositories, using libraries.io to identify all projects which are used by at least one other project, and sort them by “popularity” as indicated by the number of stars and forks.
Then, any projects that do not have a license or whose license does not explicitly permit the re-distribution of parts of the project were removed. Treesitter - GitHub's universal parser - has been used to then tokenize all Go, Java, JavaScript, Python, PHP and Ruby functions (or methods) using and, where available, their respective documentation text using a heuristic regular expression.
Corpus filtering:
Functions without documentation are removed from the corpus. This yields a set of pairs ($c_i$, $d_i$) where ci is some function documented by di. Pairs ($c_i$, $d_i$) are passed through the folllowing preprocessing tasks:
- Documentation $d_i$ is truncated to the first full paragraph to remove in-depth discussion of function arguments and return values
- Pairs in which $d_i$ is shorter than three tokens are removed
- Functions $c_i$ whose implementation is shorter than three lines are removed
- Functions whose name contains the substring “test” are removed
- Constructors and standard extenion methods (eg
__str__in Python ortoStringin Java) are removed - Duplicates and near duplicates functions are removed, in order to keep only one version of the function
Who are the source language producers?
OpenSource contributors produced the code and documentations.
The dataset was gatherered and preprocessed automatically.
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
[More Information Needed]
Licensing Information
Each example in the dataset has is extracted from a GitHub repository, and each repository has its own license. Example-wise license information is not (yet) included in this dataset: you will need to find out yourself which license the code is using.
Citation Information
@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 @SBrandeis for adding this dataset.
- Downloads last month
- 1,077