Datasets:
Tasks:
Summarization
Languages:
English
Upload AutoTrain files
Browse files- raw/validate.json +15 -0
raw/validate.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"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 previousdelimiter + e.phon(cls, \"\", strict, correctionhandling)\n if correctionhandling in (CorrectionHandling.ORIGINAL, CorrectionHandling.EITHER):\n for e in self:\n if isinstance(e, Original):\n return previousdelimiter + e.phon(cls, \"\", correctionhandling)\n raise NoSuchPhon","signature":"def phon(self, cls = 'current', previousdelimiter=\"\",strict=False, correctionhandling=CorrectionHandling.CURRENT)","docstring":"See :meth:`AbstractElement.phon`","loss_without_docstring":3.34634161,"loss_with_docstring":3.1858766079,"factor":1.0503676136}
|
2 |
+
{"code":" \n return self.next(Class,scope, True)","signature":"def previous(self, Class=True, scope=True)","docstring":"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.\n\n Arguments:\n * ``Class``: The class to select; any python class subclassed off `'AbstractElement``. Set to ``True`` to constrain to the same class as that of the current instance, set to ``None`` to not constrain at all\n * ``scope``: A list of classes which are never crossed looking for a next element. Set to ``True`` to constrain to a default list of structure elements (Sentence,Paragraph,Division,Event, ListItem,Caption), set to ``None`` to not constrain at all.","loss_without_docstring":16.4070491791,"loss_with_docstring":20.2137088776,"factor":0.8116793053}
|
3 |
+
{"code":" \n\n if self.offset is None: return None #nothing to test\n if self.ref:\n ref = self.doc[self.ref]\n else:\n ref = self.finddefaultreference()\n\n if not ref:\n raise UnresolvableTextContent(\"Default reference for textcontent not found!\")\n elif not ref.hastext(self.cls):\n raise UnresolvableTextContent(\"Reference (ID \" + str(ref.id) + \") has no such text (class=\" + self.cls+\")\")\n elif validate and self.text() != ref.textcontent(self.cls).text()[self.offset:self.offset+len(self.data[0])]:\n raise UnresolvableTextContent(\"Reference (ID \" + str(ref.id) + \", class=\" + self.cls+\") found but no text match at specified offset (\"+str(self.offset)+\")! Expected '\" + self.text() + \"', got '\" + ref.textcontent(self.cls).text()[self.offset:self.offset+len(self.data[0])] +\"'\")\n else:\n #finally, we made it!\n return ref","signature":"def getreference(self, validate=True)","docstring":"Returns and validates the Text Content's reference. Raises UnresolvableTextContent when invalid","loss_without_docstring":4.400683403,"loss_with_docstring":3.9937839508,"factor":1.1018831908}
|
4 |
+
{"code":" \n\n if size == 0: return [] #for efficiency\n\n context = []\n e = self\n while len(context) < size:\n e = e.previous(True,scope)\n if not e: break\n context.append(e)\n\n if placeholder:\n while len(context) < size:\n context.append(placeholder)\n\n context.reverse()\n return context","signature":"def leftcontext(self, size, placeholder=None, scope=None)","docstring":"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","loss_without_docstring":3.7681286335,"loss_with_docstring":3.9110825062,"factor":0.9634490266}
|
5 |
+
{"code":" \n\n for e in self.select(AlternativeLayers,None, True, ['Original','Suggestion']): #pylint: disable=too-many-nested-blocks\n if Class is None:\n yield e\n elif len(e) >= 1: #child elements?\n for e2 in e:\n try:\n if isinstance(e2, Class):\n try:\n if set is None or e2.set == set:\n yield e #not e2\n break #yield an alternative only once (in case there are multiple matches)\n except AttributeError:\n continue\n except AttributeError:\n continue","signature":"def alternatives(self, Class=None, set=None)","docstring":"Generator over alternatives, either all or only of a specific annotation type, and possibly restrained also by set.\n\n Arguments:\n * ``Class`` - The Class you want to retrieve (e.g. PosAnnotation). Or set to None to select all alternatives regardless of what type they are.\n * ``set`` - The set you want to retrieve (defaults to None, which selects irregardless of set)\n\n Returns:\n Generator over Alternative elements","loss_without_docstring":7.8411931992,"loss_with_docstring":7.0912370682,"factor":1.1057581525}
|
6 |
+
{"code":" \n\n\n if not parent.__class__.accepts(Class, raiseexceptions, parent):\n return False\n\n if Class.OCCURRENCES > 0:\n #check if the parent doesn't have too many already\n count = parent.count(Class,None,True,[True, AbstractStructureElement]) #never descend into embedded structure annotatioton\n if count >= Class.OCCURRENCES:\n if raiseexceptions:\n if parent.id:\n extra = ' (id=' + parent.id + ')'\n else:\n extra = ''\n raise DuplicateAnnotationError(\"Unable to add another object of type \" + Class.__name__ + \" to \" + parent.__class__.__name__ + \" \" + extra + \". There are already \" + str(count) + \" instances of this class, which is the maximum.\")\n else:\n return False\n\n if Class.OCCURRENCES_PER_SET > 0 and set and Class.REQUIRED_ATTRIBS and Attrib.CLASS in Class.REQUIRED_ATTRIBS:\n count = parent.count(Class,set,True, [True, AbstractStructureElement])\n if count >= Class.OCCURRENCES_PER_SET:\n if raiseexceptions:\n if parent.id:\n extra = ' (id=' + parent.id + ')'\n else:\n extra = ''\n raise DuplicateAnnotationError(\"Unable to add another object of set \" + set + \" and type \" + Class.__name__ + \" to \" + parent.__class__.__name__ + \" \" + extra + \". There are already \" + str(count) + \" instances of this class, which is the maximum for the set.\")\n else:\n return False\n\n\n\n return True","signature":"def addable(Class, parent, set=None, raiseexceptions=True)","docstring":"Tests whether a new element of this class can be added to the parent.\n\n This method is mostly for internal use.\n This will use the ``OCCURRENCES`` property, but may be overidden by subclasses for more customised behaviour.\n\n Parameters:\n parent (:class:`AbstractElement`): The element that is being added to\n set (str or None): The set\n raiseexceptions (bool): Raise an exception if the element can't be added?\n\n Returns:\n bool\n\n Raises:\n ValueError","loss_without_docstring":3.5760352612,"loss_with_docstring":3.4062948227,"factor":1.0498313996}
|
7 |
+
{"code":" \n\n if index is None:\n try:\n return next(self.select(New,None,False))\n except StopIteration:\n raise NoSuchAnnotation\n else:\n for e in self.select(New,None,False):\n return e[index]\n raise NoSuchAnnotation","signature":"def new(self,index = None)","docstring":"Get the new corrected annotation.\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.6277852058,"loss_with_docstring":4.5607280731,"factor":1.2339664009}
|
8 |
+
{"code":" \n #if no set is associated with the layer yet, we learn it from span annotation elements that are added\n if self.set is False or self.set is None:\n if inspect.isclass(child):\n if issubclass(child,AbstractSpanAnnotation):\n if 'set' in kwargs:\n self.set = kwargs['set']\n elif isinstance(child, AbstractSpanAnnotation):\n if child.set:\n self.set = child.set\n elif isinstance(child, Correction):\n #descend into corrections to find the proper set for this layer (derived from span annotation elements)\n for e in itertools.chain( child.new(), child.original(), child.suggestions() ):\n if isinstance(e, AbstractSpanAnnotation) and e.set:\n self.set = e.set\n break\n\n return super(AbstractAnnotationLayer, self).append(child, *args, **kwargs)","signature":"def append(self, child, *args, **kwargs)","docstring":"See :meth:`AbstractElement.append`","loss_without_docstring":5.4176630974,"loss_with_docstring":5.1905508041,"factor":1.0437549505}
|
9 |
+
{"code":" if 'cls' not in kwargs:\n kwargs['cls'] = 'current'\n replace = super(PhonContent, Class).findreplaceables(parent, set, **kwargs)\n replace = [ x for x in replace if x.cls == kwargs['cls']]\n del kwargs['cls'] #always delete what we processed\n return replace","signature":"def findreplaceables(Class, parent, set, **kwargs):#pylint: disable=bad-classmethod-argument\n \n #some extra behaviour for text content elements, replace also based on the 'corrected' attribute","docstring":"(Method for internal usage, see AbstractElement)","loss_without_docstring":6.4132418633,"loss_with_docstring":6.6529626846,"factor":0.9639678091}
|
10 |
+
{"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.phoncontent(cls, correctionhandling)\n if correctionhandling in (CorrectionHandling.ORIGINAL, CorrectionHandling.EITHER):\n for e in self:\n if isinstance(e, Original):\n return e.phoncontent(cls, correctionhandling)\n raise NoSuchPhon","signature":"def phoncontent(self, cls='current', correctionhandling=CorrectionHandling.CURRENT)","docstring":"See :meth:`AbstractElement.phoncontent`","loss_without_docstring":2.9124343395,"loss_with_docstring":2.777816534,"factor":1.0484617338}
|
11 |
+
{"code":" \n self.doc = newdoc\n if self.doc and self.id:\n self.doc.index[self.id] = self\n for c in self:\n if isinstance(c, AbstractElement):\n c.setdoc(newdoc)","signature":"def setdoc(self,newdoc)","docstring":"Set a different document. Usually no need to call this directly, invoked implicitly by :meth:`copy`","loss_without_docstring":4.0701856613,"loss_with_docstring":3.6779494286,"factor":1.1066453578}
|
12 |
+
{"code":" \n l = self.count(type,set,True,default_ignore_annotations)\n if len(l) >= 1:\n return l[0]\n else:\n raise NoSuchAnnotation()","signature":"def annotation(self, type, set=None)","docstring":"Will return a **single** annotation (even if there are multiple). Raises a ``NoSuchAnnotation`` exception if none was found","loss_without_docstring":9.081199646,"loss_with_docstring":6.7261571884,"factor":1.3501319389}
|
13 |
+
{"code":" \n\n for span in self.select(AbstractSpanAnnotation,None,True):\n if tuple(span.wrefs()) == words:\n return span\n raise NoSuchAnnotation","signature":"def findspan(self, *words)","docstring":"Returns the span element which spans over the specified words or morphemes.\n\n See also:\n :meth:`Word.findspans`","loss_without_docstring":18.4863834381,"loss_with_docstring":24.5394935608,"factor":0.7533319053}
|
14 |
+
{"code":" \n l = []\n for e in self.data:\n l += e.items()\n return l","signature":"def items(self)","docstring":"Returns a depth-first flat list of all items in the document","loss_without_docstring":6.0095562935,"loss_with_docstring":5.5848360062,"factor":1.0760488378}
|
15 |
+
{"code":" \n if Class is True: Class = self.__class__\n if scope is True: scope = STRUCTURESCOPE\n\n structural = Class is not None and issubclass(Class,AbstractStructureElement)\n\n if reverse:\n order = reversed\n descendindex = -1\n else:\n order = lambda x: x #pylint: disable=redefined-variable-type\n descendindex = 0\n\n child = self\n parent = self.parent\n while parent: #pylint: disable=too-many-nested-blocks\n if len(parent) > 1:\n returnnext = False\n for e in order(parent):\n if e is child:\n #we found the current item, next item will be the one to return\n returnnext = True\n elif returnnext and e.auth and not isinstance(e,AbstractAnnotationLayer) and (not structural or (structural and (not isinstance(e,(AbstractTokenAnnotation,TextContent)) ) )):\n if structural and isinstance(e,Correction):\n if not list(e.select(AbstractStructureElement)): #skip-over non-structural correction\n continue\n\n if Class is None or (isinstance(Class,tuple) and (any(isinstance(e,C) for C in Class))) or isinstance(e,Class):\n return e\n else:\n #this is not yet the element of the type we are looking for, we are going to descend again in the very leftmost (rightmost if reversed) branch only\n while e.data:\n e = e.data[descendindex]\n if not isinstance(e, AbstractElement):\n return None #we've gone too far\n if e.auth and not isinstance(e,AbstractAnnotationLayer):\n if Class is None or (isinstance(Class,tuple) and (any(isinstance(e,C) for C in Class))) or isinstance(e,Class):\n return e\n else:\n #descend deeper\n continue\n return None\n\n #generational iteration\n child = parent\n if scope is not None and child.__class__ in scope:\n #you shall not pass!\n break\n parent = parent.parent\n\n return None","signature":"def next(self, Class=True, scope=True, reverse=False)","docstring":"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.\n\n Arguments:\n * ``Class``: The class to select; any python class subclassed off `'AbstractElement``, may also be a tuple of multiple classes. Set to ``True`` to constrain to the same class as that of the current instance, set to ``None`` to not constrain at all\n * ``scope``: A list of classes which are never crossed looking for a next element. Set to ``True`` to constrain to a default list of structure elements (Sentence,Paragraph,Division,Event, ListItem,Caption), set to ``None`` to not constrain at all.","loss_without_docstring":5.5505290031,"loss_with_docstring":5.393289566,"factor":1.029154644}
|