jaty54 commited on
Commit
967031d
·
1 Parent(s): 048d2be

Upload AutoTrain files

Browse files
Files changed (1) hide show
  1. raw/test.json +15 -0
raw/test.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"code":" \n if self.set is False or self.set is None:\n if len(self.data) == 0: #just skip if there are no children\n return None\n else:\n raise ValueError(\"No set specified or derivable for annotation layer \" + self.__class__.__name__)\n return super(AbstractAnnotationLayer, self).xml(attribs, elements, skipchildren)","signature":"def xml(self, attribs = None,elements = None, skipchildren = False)","docstring":"See :meth:`AbstractElement.xml`","loss_without_docstring":7.0215940475,"loss_with_docstring":6.4072804451,"factor":1.0958774331}
2
+ {"code":" \n attribs = {}\n if not self.offset is None:\n attribs['{' + NSFOLIA + '}offset'] = str(self.offset)\n if self.parent and self.ref:\n attribs['{' + NSFOLIA + '}ref'] = self.ref\n\n #if self.cls != 'current' and not (self.cls == 'original' and any( isinstance(x, Original) for x in self.ancestors() ) ):\n # attribs['{' + NSFOLIA + '}class'] = self.cls\n #else:\n # if '{' + NSFOLIA + '}class' in attribs:\n # del attribs['{' + NSFOLIA + '}class']\n #return E.t(self.value, **attribs)\n\n e = super(TextContent,self).xml(attribs,elements,skipchildren)\n if '{' + NSFOLIA + '}class' in e.attrib and e.attrib['{' + NSFOLIA + '}class'] == \"current\":\n #delete 'class=current'\n del e.attrib['{' + NSFOLIA + '}class']\n\n return e","signature":"def xml(self, attribs = None,elements = None, skipchildren = False)","docstring":"See :meth:`AbstractElement.xml`","loss_without_docstring":3.1833612919,"loss_with_docstring":3.134873867,"factor":1.0154671055}
3
+ {"code":" \n if index is None:\n return self.select(Suggestion,None,False, False)\n else:\n for i, e in enumerate(self.select(Suggestion,None,False, False)):\n if index == i:\n return e\n raise IndexError","signature":"def suggestions(self,index=None)","docstring":"Get suggestions for correction.\n\n Yields:\n :class:`Suggestion` element that encapsulate the suggested annotations (if index is ``None``, default)\n\n Returns:\n a :class:`Suggestion` element that encapsulate the suggested annotations (if index is set)\n\n Raises:\n :class:`IndexError`","loss_without_docstring":4.0129351616,"loss_with_docstring":5.3962607384,"factor":0.7436510866}
4
+ {"code":" \n jsonnode = {}\n\n jsonnode['type'] = self.XMLTAG\n if self.id:\n jsonnode['id'] = self.id\n if self.set:\n jsonnode['set'] = self.set\n if self.cls:\n jsonnode['class'] = self.cls\n if self.annotator:\n jsonnode['annotator'] = self.annotator\n if self.annotatortype:\n if self.annotatortype == AnnotatorType.AUTO:\n jsonnode['annotatortype'] = \"auto\"\n elif self.annotatortype == AnnotatorType.MANUAL:\n jsonnode['annotatortype'] = \"manual\"\n if self.confidence is not None:\n jsonnode['confidence'] = self.confidence\n if self.n:\n jsonnode['n'] = self.n\n if self.auth:\n jsonnode['auth'] = self.auth\n if self.datetime:\n jsonnode['datetime'] = self.datetime.strftime(\"%Y-%m-%dT%H:%M:%S\")\n\n if recurse: #pylint: disable=too-many-nested-blocks\n jsonnode['children'] = []\n if self.TEXTCONTAINER:\n jsonnode['text'] = self.text()\n if self.PHONCONTAINER:\n jsonnode['phon'] = self.phon()\n for child in self:\n if self.TEXTCONTAINER and isstring(child):\n jsonnode['children'].append(child)\n elif not self.PHONCONTAINER:\n #check ignore list\n ignore = False\n if ignorelist:\n for e in ignorelist:\n if isinstance(child,e):\n ignore = True\n break\n if not ignore:\n jsonnode['children'].append(child.json(attribs,recurse,ignorelist))\n\n if attribs:\n for attrib in attribs:\n jsonnode[attrib] = attribs\n\n return jsonnode","signature":"def json(self, attribs=None, recurse=True, ignorelist=False)","docstring":"Serialises the FoLiA element and all its contents to a Python dictionary suitable for serialisation to JSON.\n\n Example::\n\n import json\n json.dumps(word.json())\n\n Returns:\n dict","loss_without_docstring":2.3621320724,"loss_with_docstring":2.519900322,"factor":0.9373910753}
5
+ {"code":" \n l = self.layers(annotationtype, set)\n return (len(l) > 0)","signature":"def hasannotationlayer(self, annotationtype=None,set=None)","docstring":"Does the specified annotation layer exist?","loss_without_docstring":5.1826400757,"loss_with_docstring":4.5005350113,"factor":1.1515608839}
6
+ {"code":" if e not in founditems: #prevent going in recursive loops\n l.append(e)\n if isinstance(e, AbstractElement):\n l += e.items(l)\n return l","signature":"def items(self, founditems=[]): #pylint: disable=dangerous-default-value\n \n l = []\n for e in self.data","docstring":"Returns a depth-first flat list of *all* items below this element (not limited to AbstractElement)","loss_without_docstring":10.0730142593,"loss_with_docstring":5.3765964508,"factor":1.8734927108}
7
+ {"code":" return True\n else:\n try:\n if strict:\n self.textcontent(cls, correctionhandling) #will raise NoSuchTextException when not found\n return True\n else:\n #Check children\n for e in self:\n if e.PRINTABLE and not isinstance(e, TextContent):\n if e.hastext(cls, strict, correctionhandling):\n return True\n\n self.textcontent(cls, correctionhandling) #will raise NoSuchTextException when not found\n return True\n except NoSuchText:\n return False","signature":"def hastext(self,cls='current',strict=True, correctionhandling=CorrectionHandling.CURRENT): #pylint: disable=too-many-return-statements\n \n if not self.PRINTABLE: #only printable elements can hold text\n return False\n elif self.TEXTCONTAINER","docstring":"Does this element have text (of the specified class)\n\n 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.\n\n Parameters:\n cls (str): The class of the text content to obtain, defaults to ``current``.\n strict (bool): Set this if you are strictly interested in the text explicitly associated with the element, without recursing into children. Defaults to ``True``.\n correctionhandling: Specifies what text to check for when corrections are encountered. The default is ``CorrectionHandling.CURRENT``, which will retrieve the corrected\/current text. You can set this to ``CorrectionHandling.ORIGINAL`` if you want the text prior to correction, and ``CorrectionHandling.EITHER`` if you don't care.\n\n Returns:\n bool","loss_without_docstring":4.143237114,"loss_with_docstring":4.585316658,"factor":0.9035880012}
8
+ {"code":" \n for e in self.select(Original,None,False, False):\n if not allowempty and len(e) == 0: continue\n return True\n return False","signature":"def hasoriginal(self,allowempty=False)","docstring":"Does the correction record the old annotations prior to correction?","loss_without_docstring":6.8541898727,"loss_with_docstring":7.1173639297,"factor":0.9630236616}
9
+ {"code":" \n\n if issubclass(type, AbstractAnnotationLayer):\n layerclass = type\n else:\n layerclass = ANNOTATIONTYPE2LAYERCLASS[type.ANNOTATIONTYPE]\n e = self\n while True:\n if not e.parent: break\n e = e.parent\n for layer in e.select(layerclass,set,False):\n if type is layerclass:\n for e2 in layer.select(AbstractSpanAnnotation,set,True, (True, Word, Morpheme)):\n if not isinstance(e2, AbstractSpanRole) and self in e2.wrefs():\n yield e2\n else:\n for e2 in layer.select(type,set,True, (True, Word, Morpheme)):\n if not isinstance(e2, AbstractSpanRole) and self in e2.wrefs():\n yield e2","signature":"def findspans(self, type,set=None)","docstring":"Yields span annotation elements of the specified type that include this word.\n\n Arguments:\n 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.\n set (str or None): Constrain by set\n\n Example::\n\n for chunk in word.findspans(folia.Chunk):\n print(\" Chunk class=\", chunk.cls, \" words=\")\n for word2 in chunk.wrefs(): #print all words in the chunk (of which the word is a part)\n print(word2, end=\"\")\n print()\n\n Yields:\n Matching span annotation instances (derived from :class:`AbstractSpanAnnotation`)","loss_without_docstring":4.3998055458,"loss_with_docstring":3.6430127621,"factor":1.2077381643}
10
+ {"code":" \n if not attribs: attribs = {}\n if self.idref:\n attribs['id'] = self.idref\n return super(AbstractTextMarkup,self).xml(attribs,elements, skipchildren)","signature":"def xml(self, attribs = None,elements = None, skipchildren = False)","docstring":"See :meth:`AbstractElement.xml`","loss_without_docstring":4.5026726723,"loss_with_docstring":3.8170909882,"factor":1.1796084207}
11
+ {"code":" \n for layer in self.select(PhonologyLayer):\n for i, p in enumerate(layer.select(Phoneme, set)):\n if index == i:\n return p\n raise NoSuchAnnotation","signature":"def phoneme(self,index, set=None)","docstring":"Returns a specific phoneme, the n'th morpheme (given the particular set if specified).","loss_without_docstring":9.6466608047,"loss_with_docstring":9.0928964615,"factor":1.0609007642}
12
+ {"code":" \n if index is None:\n try:\n return next(self.select(Current,None,False))\n except StopIteration:\n raise NoSuchAnnotation\n else:\n for e in self.select(Current,None,False):\n return e[index]\n raise NoSuchAnnotation","signature":"def current(self,index=None)","docstring":"Get the current authoritative annotation (used with suggestions in a structural context)\n\n This returns only one annotation if multiple exist, use `index` to select another in the sequence.\n\n Returns:\n an annotation element (:class:`AbstractElement`)\n\n Raises:\n :class:`NoSuchAnnotation`","loss_without_docstring":5.1554737091,"loss_with_docstring":4.5628190041,"factor":1.1298878401}
13
+ {"code":" \n if cls == 'original': correctionhandling = CorrectionHandling.ORIGINAL #backward compatibility\n if correctionhandling in (CorrectionHandling.CURRENT, CorrectionHandling.EITHER):\n for e in self:\n if isinstance(e, New) or isinstance(e, Current):\n return e.hastext(cls,strict, correctionhandling)\n if correctionhandling in (CorrectionHandling.ORIGINAL, CorrectionHandling.EITHER):\n for e in self:\n if isinstance(e, Original):\n return e.hastext(cls,strict, correctionhandling)\n return False","signature":"def hastext(self, cls='current',strict=True, correctionhandling=CorrectionHandling.CURRENT)","docstring":"See :meth:`AbstractElement.hastext`","loss_without_docstring":2.7148892879,"loss_with_docstring":2.6148703098,"factor":1.0382500722}
14
+ {"code":" \n if not isinstance(child, AbstractElement):\n raise ValueError(\"Expected AbstractElement, got \" + str(type(child)))\n if child.parent == self:\n child.parent = None\n self.data.remove(child)\n #delete from index\n if child.id and self.doc and child.id in self.doc.index:\n del self.doc.index[child.id]","signature":"def remove(self, child)","docstring":"Removes the child element","loss_without_docstring":3.4989612103,"loss_with_docstring":3.4293808937,"factor":1.0202894688}
15
+ {"code":" \n result = function(self)\n if result is not None:\n return result\n for e in self:\n result = e.depthfirstsearch(function)\n if result is not None:\n return result\n return None","signature":"def depthfirstsearch(self, function)","docstring":"Generic depth first search algorithm using a callback function, continues as long as the callback function returns None","loss_without_docstring":2.2764616013,"loss_with_docstring":2.4212138653,"factor":0.9402150029}