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_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
luckydonald/pytgbot
pytgbot/api_types/receivable/inline.py
InlineQuery.to_array
def to_array(self): """ Serializes this InlineQuery to a dictionary. :return: dictionary representation of this object. :rtype: dict """ array = super(InlineQuery, self).to_array() array['id'] = u(self.id) # py2: type unicode, py3: type str array['from']...
python
def to_array(self): """ Serializes this InlineQuery to a dictionary. :return: dictionary representation of this object. :rtype: dict """ array = super(InlineQuery, self).to_array() array['id'] = u(self.id) # py2: type unicode, py3: type str array['from']...
[ "def", "to_array", "(", "self", ")", ":", "array", "=", "super", "(", "InlineQuery", ",", "self", ")", ".", "to_array", "(", ")", "array", "[", "'id'", "]", "=", "u", "(", "self", ".", "id", ")", "# py2: type unicode, py3: type str", "array", "[", "'fr...
Serializes this InlineQuery to a dictionary. :return: dictionary representation of this object. :rtype: dict
[ "Serializes", "this", "InlineQuery", "to", "a", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L95-L109
luckydonald/pytgbot
pytgbot/api_types/receivable/inline.py
InlineQuery.from_array
def from_array(array): """ Deserialize a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="...
python
def from_array(array): """ Deserialize a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "from", "pytgbot", ".", "api...
Deserialize a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery
[ "Deserialize", "a", "new", "InlineQuery", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L113-L134
luckydonald/pytgbot
pytgbot/api_types/receivable/inline.py
ChosenInlineResult.to_array
def to_array(self): """ Serializes this ChosenInlineResult to a dictionary. :return: dictionary representation of this object. :rtype: dict """ array = super(ChosenInlineResult, self).to_array() array['result_id'] = u(self.result_id) # py2: type unicode, py3: ty...
python
def to_array(self): """ Serializes this ChosenInlineResult to a dictionary. :return: dictionary representation of this object. :rtype: dict """ array = super(ChosenInlineResult, self).to_array() array['result_id'] = u(self.result_id) # py2: type unicode, py3: ty...
[ "def", "to_array", "(", "self", ")", ":", "array", "=", "super", "(", "ChosenInlineResult", ",", "self", ")", ".", "to_array", "(", ")", "array", "[", "'result_id'", "]", "=", "u", "(", "self", ".", "result_id", ")", "# py2: type unicode, py3: type str", "...
Serializes this ChosenInlineResult to a dictionary. :return: dictionary representation of this object. :rtype: dict
[ "Serializes", "this", "ChosenInlineResult", "to", "a", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L248-L263
luckydonald/pytgbot
pytgbot/api_types/receivable/inline.py
ChosenInlineResult.from_array
def from_array(array): """ Deserialize a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert_type_or_raise(array, d...
python
def from_array(array): """ Deserialize a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert_type_or_raise(array, d...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "from", ".", ".", "receivabl...
Deserialize a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult
[ "Deserialize", "a", "new", "ChosenInlineResult", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L267-L289
luckydonald/pytgbot
code_generation/output/pytgbot/api_types/receivable/updates.py
Update.from_array
def from_array(array): """ Deserialize a new Update from a given dictionary. :return: new Update instance. :rtype: Update """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") ...
python
def from_array(array): """ Deserialize a new Update from a given dictionary. :return: new Update instance. :rtype: Update """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") ...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "from", "pytgbot", ".", "api...
Deserialize a new Update from a given dictionary. :return: new Update instance. :rtype: Update
[ "Deserialize", "a", "new", "Update", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/updates.py#L181-L212
delph-in/pydelphin
delphin/tokens.py
YyToken.from_dict
def from_dict(cls, d): """ Decode from a dictionary as from :meth:`to_dict`. """ return cls( d['id'], d['start'], d['end'], Lnk.charspan(d['from'], d['to']) if 'from' in d else None, # d.get('paths', [1]), form=d['fo...
python
def from_dict(cls, d): """ Decode from a dictionary as from :meth:`to_dict`. """ return cls( d['id'], d['start'], d['end'], Lnk.charspan(d['from'], d['to']) if 'from' in d else None, # d.get('paths', [1]), form=d['fo...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "return", "cls", "(", "d", "[", "'id'", "]", ",", "d", "[", "'start'", "]", ",", "d", "[", "'end'", "]", ",", "Lnk", ".", "charspan", "(", "d", "[", "'from'", "]", ",", "d", "[", "'to'", "...
Decode from a dictionary as from :meth:`to_dict`.
[ "Decode", "from", "a", "dictionary", "as", "from", ":", "meth", ":", "to_dict", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L68-L83
delph-in/pydelphin
delphin/tokens.py
YyToken.to_dict
def to_dict(self): """ Encode the token as a dictionary suitable for JSON serialization. """ d = { 'id': self.id, 'start': self.start, 'end': self.end, 'form': self.form } if self.lnk is not None: cfrom, cto = se...
python
def to_dict(self): """ Encode the token as a dictionary suitable for JSON serialization. """ d = { 'id': self.id, 'start': self.start, 'end': self.end, 'form': self.form } if self.lnk is not None: cfrom, cto = se...
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "{", "'id'", ":", "self", ".", "id", ",", "'start'", ":", "self", ".", "start", ",", "'end'", ":", "self", ".", "end", ",", "'form'", ":", "self", ".", "form", "}", "if", "self", ".", "lnk", ...
Encode the token as a dictionary suitable for JSON serialization.
[ "Encode", "the", "token", "as", "a", "dictionary", "suitable", "for", "JSON", "serialization", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L85-L107
delph-in/pydelphin
delphin/tokens.py
YyTokenLattice.from_string
def from_string(cls, s): """ Decode from the YY token lattice format. """ def _qstrip(s): return s[1:-1] # remove assumed quote characters tokens = [] for match in _yy_re.finditer(s): d = match.groupdict() lnk, pos = None, [] ...
python
def from_string(cls, s): """ Decode from the YY token lattice format. """ def _qstrip(s): return s[1:-1] # remove assumed quote characters tokens = [] for match in _yy_re.finditer(s): d = match.groupdict() lnk, pos = None, [] ...
[ "def", "from_string", "(", "cls", ",", "s", ")", ":", "def", "_qstrip", "(", "s", ")", ":", "return", "s", "[", "1", ":", "-", "1", "]", "# remove assumed quote characters", "tokens", "=", "[", "]", "for", "match", "in", "_yy_re", ".", "finditer", "(...
Decode from the YY token lattice format.
[ "Decode", "from", "the", "YY", "token", "lattice", "format", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L145-L174
delph-in/pydelphin
delphin/mrs/simplemrs.py
load
def load(fh, single=False, version=_default_version, strict=False, errors='warn'): """ Deserialize SimpleMRSs from a file (handle or filename) Args: fh (str, file): input filename or file object single: if `True`, only return the first read Xmrs object strict: deprecated; a...
python
def load(fh, single=False, version=_default_version, strict=False, errors='warn'): """ Deserialize SimpleMRSs from a file (handle or filename) Args: fh (str, file): input filename or file object single: if `True`, only return the first read Xmrs object strict: deprecated; a...
[ "def", "load", "(", "fh", ",", "single", "=", "False", ",", "version", "=", "_default_version", ",", "strict", "=", "False", ",", "errors", "=", "'warn'", ")", ":", "if", "isinstance", "(", "fh", ",", "stringtypes", ")", ":", "s", "=", "open", "(", ...
Deserialize SimpleMRSs from a file (handle or filename) Args: fh (str, file): input filename or file object single: if `True`, only return the first read Xmrs object strict: deprecated; a `True` value is the same as `errors='strict'`, and a `False` value is the same as ...
[ "Deserialize", "SimpleMRSs", "from", "a", "file", "(", "handle", "or", "filename", ")" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L58-L81
delph-in/pydelphin
delphin/mrs/simplemrs.py
loads
def loads(s, single=False, version=_default_version, strict=False, errors='warn'): """ Deserialize SimpleMRS string representations Args: s (str): a SimpleMRS string single (bool): if `True`, only return the first Xmrs object Returns: a generator of Xmrs objects (unles...
python
def loads(s, single=False, version=_default_version, strict=False, errors='warn'): """ Deserialize SimpleMRS string representations Args: s (str): a SimpleMRS string single (bool): if `True`, only return the first Xmrs object Returns: a generator of Xmrs objects (unles...
[ "def", "loads", "(", "s", ",", "single", "=", "False", ",", "version", "=", "_default_version", ",", "strict", "=", "False", ",", "errors", "=", "'warn'", ")", ":", "ms", "=", "deserialize", "(", "s", ",", "version", "=", "version", ",", "strict", "=...
Deserialize SimpleMRS string representations Args: s (str): a SimpleMRS string single (bool): if `True`, only return the first Xmrs object Returns: a generator of Xmrs objects (unless *single* is `True`)
[ "Deserialize", "SimpleMRS", "string", "representations" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L84-L99
delph-in/pydelphin
delphin/mrs/simplemrs.py
dumps
def dumps(ms, single=False, version=_default_version, properties=True, pretty_print=False, color=False, **kwargs): """ Serialize an Xmrs object to a SimpleMRS representation Args: ms: an iterator of Xmrs objects to serialize (unless the *single* option is `True`) singl...
python
def dumps(ms, single=False, version=_default_version, properties=True, pretty_print=False, color=False, **kwargs): """ Serialize an Xmrs object to a SimpleMRS representation Args: ms: an iterator of Xmrs objects to serialize (unless the *single* option is `True`) singl...
[ "def", "dumps", "(", "ms", ",", "single", "=", "False", ",", "version", "=", "_default_version", ",", "properties", "=", "True", ",", "pretty_print", "=", "False", ",", "color", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "pretty_prin...
Serialize an Xmrs object to a SimpleMRS representation Args: ms: an iterator of Xmrs objects to serialize (unless the *single* option is `True`) single: if `True`, treat *ms* as a single Xmrs object instead of as an iterator properties: if `False`, suppress variable ...
[ "Serialize", "an", "Xmrs", "object", "to", "a", "SimpleMRS", "representation" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L132-L153
delph-in/pydelphin
delphin/mrs/simplemrs.py
_read_lnk
def _read_lnk(tokens): """Read and return a tuple of the pred's lnk type and lnk value, if a pred lnk is specified.""" # < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE > lnk = None if tokens[0] == '<': tokens.popleft() # we just checked this is a left angle if tokens[0]...
python
def _read_lnk(tokens): """Read and return a tuple of the pred's lnk type and lnk value, if a pred lnk is specified.""" # < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE > lnk = None if tokens[0] == '<': tokens.popleft() # we just checked this is a left angle if tokens[0]...
[ "def", "_read_lnk", "(", "tokens", ")", ":", "# < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE >", "lnk", "=", "None", "if", "tokens", "[", "0", "]", "==", "'<'", ":", "tokens", ".", "popleft", "(", ")", "# we just checked this is a left angle", "if", "tok...
Read and return a tuple of the pred's lnk type and lnk value, if a pred lnk is specified.
[ "Read", "and", "return", "a", "tuple", "of", "the", "pred", "s", "lnk", "type", "and", "lnk", "value", "if", "a", "pred", "lnk", "is", "specified", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L338-L368
delph-in/pydelphin
delphin/mrs/simplemrs.py
serialize
def serialize(ms, version=_default_version, properties=True, pretty_print=False, color=False): """Serialize an MRS structure into a SimpleMRS string.""" delim = '\n' if pretty_print else _default_mrs_delim output = delim.join( _serialize_mrs(m, properties=properties, ...
python
def serialize(ms, version=_default_version, properties=True, pretty_print=False, color=False): """Serialize an MRS structure into a SimpleMRS string.""" delim = '\n' if pretty_print else _default_mrs_delim output = delim.join( _serialize_mrs(m, properties=properties, ...
[ "def", "serialize", "(", "ms", ",", "version", "=", "_default_version", ",", "properties", "=", "True", ",", "pretty_print", "=", "False", ",", "color", "=", "False", ")", ":", "delim", "=", "'\\n'", "if", "pretty_print", "else", "_default_mrs_delim", "outpu...
Serialize an MRS structure into a SimpleMRS string.
[ "Serialize", "an", "MRS", "structure", "into", "a", "SimpleMRS", "string", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L379-L390
delph-in/pydelphin
delphin/mrs/simplemrs.py
_serialize_argument
def _serialize_argument(rargname, value, varprops): """Serialize an MRS argument into the SimpleMRS format.""" _argument = '{rargname}: {value}{props}' if rargname == CONSTARG_ROLE: value = '"{}"'.format(value) props = '' if value in varprops: props = ' [ {} ]'.format( ' ...
python
def _serialize_argument(rargname, value, varprops): """Serialize an MRS argument into the SimpleMRS format.""" _argument = '{rargname}: {value}{props}' if rargname == CONSTARG_ROLE: value = '"{}"'.format(value) props = '' if value in varprops: props = ' [ {} ]'.format( ' ...
[ "def", "_serialize_argument", "(", "rargname", ",", "value", ",", "varprops", ")", ":", "_argument", "=", "'{rargname}: {value}{props}'", "if", "rargname", "==", "CONSTARG_ROLE", ":", "value", "=", "'\"{}\"'", ".", "format", "(", "value", ")", "props", "=", "'...
Serialize an MRS argument into the SimpleMRS format.
[ "Serialize", "an", "MRS", "argument", "into", "the", "SimpleMRS", "format", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L430-L449
delph-in/pydelphin
delphin/mrs/simplemrs.py
_serialize_ep
def _serialize_ep(ep, varprops, version=_default_version): """Serialize an Elementary Predication into the SimpleMRS encoding.""" # ('nodeid', 'pred', 'label', 'args', 'lnk', 'surface', 'base') args = ep[3] arglist = ' '.join([_serialize_argument(rarg, args[rarg], varprops) for r...
python
def _serialize_ep(ep, varprops, version=_default_version): """Serialize an Elementary Predication into the SimpleMRS encoding.""" # ('nodeid', 'pred', 'label', 'args', 'lnk', 'surface', 'base') args = ep[3] arglist = ' '.join([_serialize_argument(rarg, args[rarg], varprops) for r...
[ "def", "_serialize_ep", "(", "ep", ",", "varprops", ",", "version", "=", "_default_version", ")", ":", "# ('nodeid', 'pred', 'label', 'args', 'lnk', 'surface', 'base')", "args", "=", "ep", "[", "3", "]", "arglist", "=", "' '", ".", "join", "(", "[", "_serialize_ar...
Serialize an Elementary Predication into the SimpleMRS encoding.
[ "Serialize", "an", "Elementary", "Predication", "into", "the", "SimpleMRS", "encoding", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L452-L472
delph-in/pydelphin
delphin/mrs/simplemrs.py
_serialize_lnk
def _serialize_lnk(lnk): """Serialize a predication lnk to surface form into the SimpleMRS encoding.""" s = "" if lnk is not None: s = '<' if lnk.type == Lnk.CHARSPAN: cfrom, cto = lnk.data s += ''.join([str(cfrom), ':', str(cto)]) elif lnk.type == Lnk....
python
def _serialize_lnk(lnk): """Serialize a predication lnk to surface form into the SimpleMRS encoding.""" s = "" if lnk is not None: s = '<' if lnk.type == Lnk.CHARSPAN: cfrom, cto = lnk.data s += ''.join([str(cfrom), ':', str(cto)]) elif lnk.type == Lnk....
[ "def", "_serialize_lnk", "(", "lnk", ")", ":", "s", "=", "\"\"", "if", "lnk", "is", "not", "None", ":", "s", "=", "'<'", "if", "lnk", ".", "type", "==", "Lnk", ".", "CHARSPAN", ":", "cfrom", ",", "cto", "=", "lnk", ".", "data", "s", "+=", "''",...
Serialize a predication lnk to surface form into the SimpleMRS encoding.
[ "Serialize", "a", "predication", "lnk", "to", "surface", "form", "into", "the", "SimpleMRS", "encoding", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L475-L492
delph-in/pydelphin
delphin/mrs/simplemrs.py
_serialize_hcons
def _serialize_hcons(hcons): """Serialize [HandleConstraints] into the SimpleMRS encoding.""" toks = ['HCONS:', '<'] for hc in hcons: toks.extend(hc) # reln = hcon[1] # toks += [hcon[0], rel, str(hcon.lo)] toks += ['>'] return ' '.join(toks)
python
def _serialize_hcons(hcons): """Serialize [HandleConstraints] into the SimpleMRS encoding.""" toks = ['HCONS:', '<'] for hc in hcons: toks.extend(hc) # reln = hcon[1] # toks += [hcon[0], rel, str(hcon.lo)] toks += ['>'] return ' '.join(toks)
[ "def", "_serialize_hcons", "(", "hcons", ")", ":", "toks", "=", "[", "'HCONS:'", ",", "'<'", "]", "for", "hc", "in", "hcons", ":", "toks", ".", "extend", "(", "hc", ")", "# reln = hcon[1]", "# toks += [hcon[0], rel, str(hcon.lo)]", "toks", "+=", "[", "'>'", ...
Serialize [HandleConstraints] into the SimpleMRS encoding.
[ "Serialize", "[", "HandleConstraints", "]", "into", "the", "SimpleMRS", "encoding", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L495-L503
delph-in/pydelphin
delphin/mrs/simplemrs.py
_serialize_icons
def _serialize_icons(icons): """Serialize [IndividualConstraints] into the SimpleMRS encoding.""" toks = ['ICONS:', '<'] for ic in icons: toks.extend(ic) # toks += [str(icon.left), # icon.relation, # str(icon.right)] toks += ['>'] return ' '.join(tok...
python
def _serialize_icons(icons): """Serialize [IndividualConstraints] into the SimpleMRS encoding.""" toks = ['ICONS:', '<'] for ic in icons: toks.extend(ic) # toks += [str(icon.left), # icon.relation, # str(icon.right)] toks += ['>'] return ' '.join(tok...
[ "def", "_serialize_icons", "(", "icons", ")", ":", "toks", "=", "[", "'ICONS:'", ",", "'<'", "]", "for", "ic", "in", "icons", ":", "toks", ".", "extend", "(", "ic", ")", "# toks += [str(icon.left),", "# icon.relation,", "# str(icon.right)]", "t...
Serialize [IndividualConstraints] into the SimpleMRS encoding.
[ "Serialize", "[", "IndividualConstraints", "]", "into", "the", "SimpleMRS", "encoding", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L506-L515
delph-in/pydelphin
delphin/derivation.py
_UdfNodeBase.to_dict
def to_dict(self, fields=_all_fields, labels=None): """ Encode the node as a dictionary suitable for JSON serialization. Args: fields: if given, this is a whitelist of fields to include on nodes (`daughters` and `form` are always shown) labels: optional l...
python
def to_dict(self, fields=_all_fields, labels=None): """ Encode the node as a dictionary suitable for JSON serialization. Args: fields: if given, this is a whitelist of fields to include on nodes (`daughters` and `form` are always shown) labels: optional l...
[ "def", "to_dict", "(", "self", ",", "fields", "=", "_all_fields", ",", "labels", "=", "None", ")", ":", "fields", "=", "set", "(", "fields", ")", "diff", "=", "fields", ".", "difference", "(", "_all_fields", ")", "if", "isinstance", "(", "labels", ",",...
Encode the node as a dictionary suitable for JSON serialization. Args: fields: if given, this is a whitelist of fields to include on nodes (`daughters` and `form` are always shown) labels: optional label annotations to embed in the derivation dict; the va...
[ "Encode", "the", "node", "as", "a", "dictionary", "suitable", "for", "JSON", "serialization", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/derivation.py#L138-L162
delph-in/pydelphin
delphin/derivation.py
UdfNode.is_head
def is_head(self): """ Return `True` if the node is a head. A node is a head if it is marked as a head in the UDX format or it has no siblings. `False` is returned if the node is known to not be a head (has a sibling that is a head). Otherwise it is indeterminate whether...
python
def is_head(self): """ Return `True` if the node is a head. A node is a head if it is marked as a head in the UDX format or it has no siblings. `False` is returned if the node is known to not be a head (has a sibling that is a head). Otherwise it is indeterminate whether...
[ "def", "is_head", "(", "self", ")", ":", "if", "(", "self", ".", "_head", "or", "self", ".", "is_root", "(", ")", "or", "len", "(", "getattr", "(", "self", ".", "_parent", ",", "'daughters'", ",", "[", "None", "]", ")", ")", "==", "1", ")", ":"...
Return `True` if the node is a head. A node is a head if it is marked as a head in the UDX format or it has no siblings. `False` is returned if the node is known to not be a head (has a sibling that is a head). Otherwise it is indeterminate whether the node is a head, and `None` is ...
[ "Return", "True", "if", "the", "node", "is", "a", "head", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/derivation.py#L420-L436
delph-in/pydelphin
delphin/derivation.py
UdfNode.preterminals
def preterminals(self): """ Return the list of preterminals (i.e. lexical grammar-entities). """ nodes = [] for dtr in self.daughters: if isinstance(dtr, UdfTerminal): nodes.append(self) else: nodes.extend(dtr.preterminals()...
python
def preterminals(self): """ Return the list of preterminals (i.e. lexical grammar-entities). """ nodes = [] for dtr in self.daughters: if isinstance(dtr, UdfTerminal): nodes.append(self) else: nodes.extend(dtr.preterminals()...
[ "def", "preterminals", "(", "self", ")", ":", "nodes", "=", "[", "]", "for", "dtr", "in", "self", ".", "daughters", ":", "if", "isinstance", "(", "dtr", ",", "UdfTerminal", ")", ":", "nodes", ".", "append", "(", "self", ")", "else", ":", "nodes", "...
Return the list of preterminals (i.e. lexical grammar-entities).
[ "Return", "the", "list", "of", "preterminals", "(", "i", ".", "e", ".", "lexical", "grammar", "-", "entities", ")", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/derivation.py#L469-L479
delph-in/pydelphin
delphin/derivation.py
Derivation.from_string
def from_string(cls, s): """ Instantiate a `Derivation` from a UDF or UDX string representation. The UDF/UDX representations are as output by a processor like the `LKB <http://moin.delph-in.net/LkbTop>`_ or `ACE <http://sweaglesw.org/linguistics/ace/>`_, or from the :met...
python
def from_string(cls, s): """ Instantiate a `Derivation` from a UDF or UDX string representation. The UDF/UDX representations are as output by a processor like the `LKB <http://moin.delph-in.net/LkbTop>`_ or `ACE <http://sweaglesw.org/linguistics/ace/>`_, or from the :met...
[ "def", "from_string", "(", "cls", ",", "s", ")", ":", "if", "not", "(", "s", ".", "startswith", "(", "'('", ")", "and", "s", ".", "endswith", "(", "')'", ")", ")", ":", "raise", "ValueError", "(", "'Derivations must begin and end with parentheses: ( )'", "...
Instantiate a `Derivation` from a UDF or UDX string representation. The UDF/UDX representations are as output by a processor like the `LKB <http://moin.delph-in.net/LkbTop>`_ or `ACE <http://sweaglesw.org/linguistics/ace/>`_, or from the :meth:`UdfNode.to_udf` or :meth:`UdfNode.to_udx` ...
[ "Instantiate", "a", "Derivation", "from", "a", "UDF", "or", "UDX", "string", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/derivation.py#L549-L611
delph-in/pydelphin
delphin/mrs/penman.py
load
def load(fh, model): """ Deserialize PENMAN graphs from a file (handle or filename) Args: fh: filename or file object model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*) """ graphs = penman.load(fh, cls=XMRSCodec) xs =...
python
def load(fh, model): """ Deserialize PENMAN graphs from a file (handle or filename) Args: fh: filename or file object model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*) """ graphs = penman.load(fh, cls=XMRSCodec) xs =...
[ "def", "load", "(", "fh", ",", "model", ")", ":", "graphs", "=", "penman", ".", "load", "(", "fh", ",", "cls", "=", "XMRSCodec", ")", "xs", "=", "[", "model", ".", "from_triples", "(", "g", ".", "triples", "(", ")", ")", "for", "g", "in", "grap...
Deserialize PENMAN graphs from a file (handle or filename) Args: fh: filename or file object model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*)
[ "Deserialize", "PENMAN", "graphs", "from", "a", "file", "(", "handle", "or", "filename", ")" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/penman.py#L29-L41
delph-in/pydelphin
delphin/mrs/penman.py
loads
def loads(s, model): """ Deserialize PENMAN graphs from a string Args: s (str): serialized PENMAN graphs model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*) """ graphs = penman.loads(s, cls=XMRSCodec) xs = [model.from_...
python
def loads(s, model): """ Deserialize PENMAN graphs from a string Args: s (str): serialized PENMAN graphs model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*) """ graphs = penman.loads(s, cls=XMRSCodec) xs = [model.from_...
[ "def", "loads", "(", "s", ",", "model", ")", ":", "graphs", "=", "penman", ".", "loads", "(", "s", ",", "cls", "=", "XMRSCodec", ")", "xs", "=", "[", "model", ".", "from_triples", "(", "g", ".", "triples", "(", ")", ")", "for", "g", "in", "grap...
Deserialize PENMAN graphs from a string Args: s (str): serialized PENMAN graphs model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*)
[ "Deserialize", "PENMAN", "graphs", "from", "a", "string" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/penman.py#L44-L56
delph-in/pydelphin
delphin/mrs/penman.py
dump
def dump(destination, xs, model=None, properties=False, indent=True, **kwargs): """ Serialize Xmrs (or subclass) objects to PENMAN and write to a file. Args: destination: filename or file object xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: ...
python
def dump(destination, xs, model=None, properties=False, indent=True, **kwargs): """ Serialize Xmrs (or subclass) objects to PENMAN and write to a file. Args: destination: filename or file object xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: ...
[ "def", "dump", "(", "destination", ",", "xs", ",", "model", "=", "None", ",", "properties", "=", "False", ",", "indent", "=", "True", ",", "*", "*", "kwargs", ")", ":", "text", "=", "dumps", "(", "xs", ",", "model", "=", "model", ",", "properties",...
Serialize Xmrs (or subclass) objects to PENMAN and write to a file. Args: destination: filename or file object xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: Xmrs subclass used to get triples properties: if `True`, encode variable properties ...
[ "Serialize", "Xmrs", "(", "or", "subclass", ")", "objects", "to", "PENMAN", "and", "write", "to", "a", "file", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/penman.py#L59-L80
delph-in/pydelphin
delphin/mrs/penman.py
dumps
def dumps(xs, model=None, properties=False, indent=True, **kwargs): """ Serialize Xmrs (or subclass) objects to PENMAN notation Args: xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: Xmrs subclass used to get triples properties: if `True`, enco...
python
def dumps(xs, model=None, properties=False, indent=True, **kwargs): """ Serialize Xmrs (or subclass) objects to PENMAN notation Args: xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: Xmrs subclass used to get triples properties: if `True`, enco...
[ "def", "dumps", "(", "xs", ",", "model", "=", "None", ",", "properties", "=", "False", ",", "indent", "=", "True", ",", "*", "*", "kwargs", ")", ":", "xs", "=", "list", "(", "xs", ")", "if", "not", "xs", ":", "return", "''", "given_class", "=", ...
Serialize Xmrs (or subclass) objects to PENMAN notation Args: xs: iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to serialize model: Xmrs subclass used to get triples properties: if `True`, encode variable properties indent: if `True`, adaptively indent; if `False` ...
[ "Serialize", "Xmrs", "(", "or", "subclass", ")", "objects", "to", "PENMAN", "notation" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/penman.py#L83-L127
luckydonald/pytgbot
pytgbot/api_types/sendable/reply_markup.py
ReplyKeyboardMarkup.from_array
def from_array(array): """ Deserialize a new ReplyKeyboardMarkup from a given dictionary. :return: new ReplyKeyboardMarkup instance. :rtype: ReplyKeyboardMarkup """ if array is None or not array: return None # end if assert_type_or_raise(array...
python
def from_array(array): """ Deserialize a new ReplyKeyboardMarkup from a given dictionary. :return: new ReplyKeyboardMarkup instance. :rtype: ReplyKeyboardMarkup """ if array is None or not array: return None # end if assert_type_or_raise(array...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "data", "=", "{", "}", "da...
Deserialize a new ReplyKeyboardMarkup from a given dictionary. :return: new ReplyKeyboardMarkup instance. :rtype: ReplyKeyboardMarkup
[ "Deserialize", "a", "new", "ReplyKeyboardMarkup", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/reply_markup.py#L122-L142
luckydonald/pytgbot
pytgbot/api_types/sendable/reply_markup.py
InlineKeyboardMarkup.from_array
def from_array(array): """ Deserialize a new InlineKeyboardMarkup from a given dictionary. :return: new InlineKeyboardMarkup instance. :rtype: InlineKeyboardMarkup """ if array is None or not array: return None # end if assert_type_or_raise(ar...
python
def from_array(array): """ Deserialize a new InlineKeyboardMarkup from a given dictionary. :return: new InlineKeyboardMarkup instance. :rtype: InlineKeyboardMarkup """ if array is None or not array: return None # end if assert_type_or_raise(ar...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "data", "=", "{", "}", "da...
Deserialize a new InlineKeyboardMarkup from a given dictionary. :return: new InlineKeyboardMarkup instance. :rtype: InlineKeyboardMarkup
[ "Deserialize", "a", "new", "InlineKeyboardMarkup", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/reply_markup.py#L459-L476
luckydonald/pytgbot
pytgbot/webhook.py
Webhook._prepare_request
def _prepare_request(self, command, query): """ :param command: The Url command parameter :type command: str :param query: will get json encoded. :type query: dict :return: """ from luckydonaldUtils.encoding import to_native as n from pytgbot.a...
python
def _prepare_request(self, command, query): """ :param command: The Url command parameter :type command: str :param query: will get json encoded. :type query: dict :return: """ from luckydonaldUtils.encoding import to_native as n from pytgbot.a...
[ "def", "_prepare_request", "(", "self", ",", "command", ",", "query", ")", ":", "from", "luckydonaldUtils", ".", "encoding", "import", "to_native", "as", "n", "from", "pytgbot", ".", "api_types", ".", "sendable", "import", "Sendable", "from", "pytgbot", ".", ...
:param command: The Url command parameter :type command: str :param query: will get json encoded. :type query: dict :return:
[ ":", "param", "command", ":", "The", "Url", "command", "parameter", ":", "type", "command", ":", "str" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/webhook.py#L20-L45
luckydonald/pytgbot
pytgbot/webhook.py
Webhook.do
def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query): """ Send a request to the api. If the bot is set to return the json objects, it will look like this: ```json { "ok": bool, "result": {...}, # optionally...
python
def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query): """ Send a request to the api. If the bot is set to return the json objects, it will look like this: ```json { "ok": bool, "result": {...}, # optionally...
[ "def", "do", "(", "self", ",", "command", ",", "files", "=", "None", ",", "use_long_polling", "=", "False", ",", "request_timeout", "=", "None", ",", "*", "*", "query", ")", ":", "params", "=", "self", ".", "_prepare_request", "(", "command", ",", "que...
Send a request to the api. If the bot is set to return the json objects, it will look like this: ```json { "ok": bool, "result": {...}, # optionally present: "description": "human-readable description of the result", "error_code": int...
[ "Send", "a", "request", "to", "the", "api", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/webhook.py#L103-L141
luckydonald/pytgbot
code_generation/code_generator_online.py
parse_table
def parse_table(tag): """ returns tuple of type ("class"/"func") and list of param strings. :param tag: :return: """ first = True table_header = None table_type = 'unknown' param_strings = [] thead = tag.find('thead', recursive=False) theads = None # list (items in <tr> row...
python
def parse_table(tag): """ returns tuple of type ("class"/"func") and list of param strings. :param tag: :return: """ first = True table_header = None table_type = 'unknown' param_strings = [] thead = tag.find('thead', recursive=False) theads = None # list (items in <tr> row...
[ "def", "parse_table", "(", "tag", ")", ":", "first", "=", "True", "table_header", "=", "None", "table_type", "=", "'unknown'", "param_strings", "=", "[", "]", "thead", "=", "tag", ".", "find", "(", "'thead'", ",", "recursive", "=", "False", ")", "theads"...
returns tuple of type ("class"/"func") and list of param strings. :param tag: :return:
[ "returns", "tuple", "of", "type", "(", "class", "/", "func", ")", "and", "list", "of", "param", "strings", ".", ":", "param", "tag", ":", ":", "return", ":" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_online.py#L40-L123
luckydonald/pytgbot
code_generation/code_generator_online.py
safe_to_file
def safe_to_file(folder, results): """ Receives a list of results (type :class:`Clazz` or :class:`Function`), and put them into the right files in :var:`folder` :param folder: Where the files should be in. :type folder: str :param results: A list of :class:`Clazz` or :class:`Function` objects, wh...
python
def safe_to_file(folder, results): """ Receives a list of results (type :class:`Clazz` or :class:`Function`), and put them into the right files in :var:`folder` :param folder: Where the files should be in. :type folder: str :param results: A list of :class:`Clazz` or :class:`Function` objects, wh...
[ "def", "safe_to_file", "(", "folder", ",", "results", ")", ":", "functions", "=", "[", "]", "message_send_functions", "=", "[", "]", "clazzes", "=", "{", "}", "# \"filepath\": [Class, Class, ...]", "# split results into functions and classes", "for", "result", "in", ...
Receives a list of results (type :class:`Clazz` or :class:`Function`), and put them into the right files in :var:`folder` :param folder: Where the files should be in. :type folder: str :param results: A list of :class:`Clazz` or :class:`Function` objects, which will be used to calculate the source code. ...
[ "Receives", "a", "list", "of", "results", "(", "type", ":", "class", ":", "Clazz", "or", ":", "class", ":", "Function", ")", "and", "put", "them", "into", "the", "right", "files", "in", ":", "var", ":", "folder" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_online.py#L427-L502
luckydonald/pytgbot
code_generation/code_generator_online.py
calc_path_and_create_folders
def calc_path_and_create_folders(folder, import_path): """ calculate the path and create the needed folders """ file_path = abspath(path_join(folder, import_path[:import_path.rfind(".")].replace(".", folder_seperator) + ".py")) mkdir_p(dirname(file_path)) return file_path
python
def calc_path_and_create_folders(folder, import_path): """ calculate the path and create the needed folders """ file_path = abspath(path_join(folder, import_path[:import_path.rfind(".")].replace(".", folder_seperator) + ".py")) mkdir_p(dirname(file_path)) return file_path
[ "def", "calc_path_and_create_folders", "(", "folder", ",", "import_path", ")", ":", "file_path", "=", "abspath", "(", "path_join", "(", "folder", ",", "import_path", "[", ":", "import_path", ".", "rfind", "(", "\".\"", ")", "]", ".", "replace", "(", "\".\"",...
calculate the path and create the needed folders
[ "calculate", "the", "path", "and", "create", "the", "needed", "folders" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_online.py#L508-L512
luckydonald/pytgbot
examples/cli.py
read_file_to_buffer
def read_file_to_buffer(filename): """ Reads a file to string buffer :param filename: :return: """ f = open(filename, "r") buf = BytesIO(f.read()) f.close() return buf
python
def read_file_to_buffer(filename): """ Reads a file to string buffer :param filename: :return: """ f = open(filename, "r") buf = BytesIO(f.read()) f.close() return buf
[ "def", "read_file_to_buffer", "(", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "\"r\"", ")", "buf", "=", "BytesIO", "(", "f", ".", "read", "(", ")", ")", "f", ".", "close", "(", ")", "return", "buf" ]
Reads a file to string buffer :param filename: :return:
[ "Reads", "a", "file", "to", "string", "buffer", ":", "param", "filename", ":", ":", "return", ":" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/examples/cli.py#L38-L47
luckydonald/pytgbot
examples/cli.py
parse_args
def parse_args(string): """ `"yada hoa" yupi yeah 12 "" None "None"` -> `["yada hoa", "yupi", "yeah", 12, "", None, "None"]` :param str: :return: """ import ast is_quoted = False result_parts = [] current_str = "" while len(string) > 0: if string[0] == "\"": i...
python
def parse_args(string): """ `"yada hoa" yupi yeah 12 "" None "None"` -> `["yada hoa", "yupi", "yeah", 12, "", None, "None"]` :param str: :return: """ import ast is_quoted = False result_parts = [] current_str = "" while len(string) > 0: if string[0] == "\"": i...
[ "def", "parse_args", "(", "string", ")", ":", "import", "ast", "is_quoted", "=", "False", "result_parts", "=", "[", "]", "current_str", "=", "\"\"", "while", "len", "(", "string", ")", ">", "0", ":", "if", "string", "[", "0", "]", "==", "\"\\\"\"", "...
`"yada hoa" yupi yeah 12 "" None "None"` -> `["yada hoa", "yupi", "yeah", 12, "", None, "None"]` :param str: :return:
[ "yada", "hoa", "yupi", "yeah", "12", "None", "None", "-", ">", "[", "yada", "hoa", "yupi", "yeah", "12", "None", "None", "]", ":", "param", "str", ":", ":", "return", ":" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/examples/cli.py#L746-L785
luckydonald/pytgbot
examples/cli.py
Color.overwrite_color
def overwrite_color(self, string, color, prefix=False, reset=False): """ :param string: input :param color: new color :param prefix: if it also should start the color to at the beginning. :param reset: if it also should end the color at the ending. :type reset: bool...
python
def overwrite_color(self, string, color, prefix=False, reset=False): """ :param string: input :param color: new color :param prefix: if it also should start the color to at the beginning. :param reset: if it also should end the color at the ending. :type reset: bool...
[ "def", "overwrite_color", "(", "self", ",", "string", ",", "color", ",", "prefix", "=", "False", ",", "reset", "=", "False", ")", ":", "if", "isinstance", "(", "color", ",", "int", ")", ":", "color", "=", "self", ".", "prepare_color", "(", "color", "...
:param string: input :param color: new color :param prefix: if it also should start the color to at the beginning. :param reset: if it also should end the color at the ending. :type reset: bool | int | str :return:
[ ":", "param", "string", ":", "input", ":", "param", "color", ":", "new", "color", ":", "param", "prefix", ":", "if", "it", "also", "should", "start", "the", "color", "to", "at", "the", "beginning", ".", ":", "param", "reset", ":", "if", "it", "also",...
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/examples/cli.py#L164-L186
luckydonald/pytgbot
examples/cli.py
CLI.print_peer
def print_peer(self, peer, show_id=True, id_prefix="", reply=True): """ :param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool """ if isinstance(id_prefix, bool): if id_prefix: # True if isins...
python
def print_peer(self, peer, show_id=True, id_prefix="", reply=True): """ :param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool """ if isinstance(id_prefix, bool): if id_prefix: # True if isins...
[ "def", "print_peer", "(", "self", ",", "peer", ",", "show_id", "=", "True", ",", "id_prefix", "=", "\"\"", ",", "reply", "=", "True", ")", ":", "if", "isinstance", "(", "id_prefix", ",", "bool", ")", ":", "if", "id_prefix", ":", "# True", "if", "isin...
:param id_prefix: Prefix of the #id thing. Set a string, or true to have it generated. :type id_prefix: str|bool
[ ":", "param", "id_prefix", ":", "Prefix", "of", "the", "#id", "thing", ".", "Set", "a", "string", "or", "true", "to", "have", "it", "generated", ".", ":", "type", "id_prefix", ":", "str|bool" ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/examples/cli.py#L580-L601
delph-in/pydelphin
delphin/mrs/__init__.py
convert
def convert(txt, src_fmt, tgt_fmt, single=True, **kwargs): """ Convert a textual representation of \*MRS from one the src_fmt representation to the tgt_fmt representation. By default, only read and convert a single \*MRS object (e.g. for `mrx` this starts at <mrs> and not <mrs-list>), but changing t...
python
def convert(txt, src_fmt, tgt_fmt, single=True, **kwargs): """ Convert a textual representation of \*MRS from one the src_fmt representation to the tgt_fmt representation. By default, only read and convert a single \*MRS object (e.g. for `mrx` this starts at <mrs> and not <mrs-list>), but changing t...
[ "def", "convert", "(", "txt", ",", "src_fmt", ",", "tgt_fmt", ",", "single", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "importlib", "import", "import_module", "reader", "=", "import_module", "(", "'{}.{}'", ".", "format", "(", "'delphin.mrs'"...
Convert a textual representation of \*MRS from one the src_fmt representation to the tgt_fmt representation. By default, only read and convert a single \*MRS object (e.g. for `mrx` this starts at <mrs> and not <mrs-list>), but changing the `mode` argument to `corpus` (alternatively: `list`) reads and co...
[ "Convert", "a", "textual", "representation", "of", "\\", "*", "MRS", "from", "one", "the", "src_fmt", "representation", "to", "the", "tgt_fmt", "representation", ".", "By", "default", "only", "read", "and", "convert", "a", "single", "\\", "*", "MRS", "object...
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/__init__.py#L53-L95
delph-in/pydelphin
delphin/tdl.py
_peek
def _peek(tokens, n=0): """peek and drop comments""" return tokens.peek(n=n, skip=_is_comment, drop=True)
python
def _peek(tokens, n=0): """peek and drop comments""" return tokens.peek(n=n, skip=_is_comment, drop=True)
[ "def", "_peek", "(", "tokens", ",", "n", "=", "0", ")", ":", "return", "tokens", ".", "peek", "(", "n", "=", "n", ",", "skip", "=", "_is_comment", ",", "drop", "=", "True", ")" ]
peek and drop comments
[ "peek", "and", "drop", "comments" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1043-L1045
delph-in/pydelphin
delphin/tdl.py
_shift
def _shift(tokens): """pop the next token, then peek the gid of the following""" after = tokens.peek(n=1, skip=_is_comment, drop=True) tok = tokens._buffer.popleft() return tok[0], tok[1], tok[2], after[0]
python
def _shift(tokens): """pop the next token, then peek the gid of the following""" after = tokens.peek(n=1, skip=_is_comment, drop=True) tok = tokens._buffer.popleft() return tok[0], tok[1], tok[2], after[0]
[ "def", "_shift", "(", "tokens", ")", ":", "after", "=", "tokens", ".", "peek", "(", "n", "=", "1", ",", "skip", "=", "_is_comment", ",", "drop", "=", "True", ")", "tok", "=", "tokens", ".", "_buffer", ".", "popleft", "(", ")", "return", "tok", "[...
pop the next token, then peek the gid of the following
[ "pop", "the", "next", "token", "then", "peek", "the", "gid", "of", "the", "following" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1053-L1057
delph-in/pydelphin
delphin/tdl.py
_accumulate
def _accumulate(lexitems): """ Yield lists of tokens based on very simple parsing that checks the level of nesting within a structure. This is probably much faster than the LookaheadIterator method, but it is less safe; an unclosed list or AVM may cause it to build a list including the rest of the ...
python
def _accumulate(lexitems): """ Yield lists of tokens based on very simple parsing that checks the level of nesting within a structure. This is probably much faster than the LookaheadIterator method, but it is less safe; an unclosed list or AVM may cause it to build a list including the rest of the ...
[ "def", "_accumulate", "(", "lexitems", ")", ":", "data", "=", "[", "]", "stack", "=", "[", "]", "break_on", "=", "10", "in_def", "=", "False", "for", "item", "in", "lexitems", ":", "gid", "=", "item", "[", "0", "]", "# only yield comments outside of defi...
Yield lists of tokens based on very simple parsing that checks the level of nesting within a structure. This is probably much faster than the LookaheadIterator method, but it is less safe; an unclosed list or AVM may cause it to build a list including the rest of the file, or it may return a list that d...
[ "Yield", "lists", "of", "tokens", "based", "on", "very", "simple", "parsing", "that", "checks", "the", "level", "of", "nesting", "within", "a", "structure", ".", "This", "is", "probably", "much", "faster", "than", "the", "LookaheadIterator", "method", "but", ...
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1060-L1111
delph-in/pydelphin
delphin/tdl.py
_lex
def _lex(stream): """ Lex the input stream according to _tdl_lex_re. Yields (gid, token, line_number) """ lines = enumerate(stream, 1) line_no = pos = 0 try: while True: if pos == 0: line_no, line = next(lines) matches = _tdl_lex_re.fi...
python
def _lex(stream): """ Lex the input stream according to _tdl_lex_re. Yields (gid, token, line_number) """ lines = enumerate(stream, 1) line_no = pos = 0 try: while True: if pos == 0: line_no, line = next(lines) matches = _tdl_lex_re.fi...
[ "def", "_lex", "(", "stream", ")", ":", "lines", "=", "enumerate", "(", "stream", ",", "1", ")", "line_no", "=", "pos", "=", "0", "try", ":", "while", "True", ":", "if", "pos", "==", "0", ":", "line_no", ",", "line", "=", "next", "(", "lines", ...
Lex the input stream according to _tdl_lex_re. Yields (gid, token, line_number)
[ "Lex", "the", "input", "stream", "according", "to", "_tdl_lex_re", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1114-L1152
delph-in/pydelphin
delphin/tdl.py
_bounded
def _bounded(p1, p2, line, pos, line_no, lines): """Collect the contents of a bounded multiline string""" substrings = [] start_line_no = line_no end = pos while not line.startswith(p2, end): if line[end] == '\\': end += 2 else: end += 1 if end >= len(...
python
def _bounded(p1, p2, line, pos, line_no, lines): """Collect the contents of a bounded multiline string""" substrings = [] start_line_no = line_no end = pos while not line.startswith(p2, end): if line[end] == '\\': end += 2 else: end += 1 if end >= len(...
[ "def", "_bounded", "(", "p1", ",", "p2", ",", "line", ",", "pos", ",", "line_no", ",", "lines", ")", ":", "substrings", "=", "[", "]", "start_line_no", "=", "line_no", "end", "=", "pos", "while", "not", "line", ".", "startswith", "(", "p2", ",", "e...
Collect the contents of a bounded multiline string
[ "Collect", "the", "contents", "of", "a", "bounded", "multiline", "string" ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1155-L1176
delph-in/pydelphin
delphin/tdl.py
iterparse
def iterparse(source, encoding='utf-8'): """ Parse the TDL file *source* and iteratively yield parse events. If *source* is a filename, the file is opened and closed when the generator has finished, otherwise *source* is an open file object and will not be closed when the generator has finished. ...
python
def iterparse(source, encoding='utf-8'): """ Parse the TDL file *source* and iteratively yield parse events. If *source* is a filename, the file is opened and closed when the generator has finished, otherwise *source* is an open file object and will not be closed when the generator has finished. ...
[ "def", "iterparse", "(", "source", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "for", "event", "in", "_parse2", "(", "source", ")", ":", "yield", "event", "else", ":", "with", "io", ".", "open",...
Parse the TDL file *source* and iteratively yield parse events. If *source* is a filename, the file is opened and closed when the generator has finished, otherwise *source* is an open file object and will not be closed when the generator has finished. Parse events are `(event, object, lineno)` tuples,...
[ "Parse", "the", "TDL", "file", "*", "source", "*", "and", "iteratively", "yield", "parse", "events", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1180-L1216
delph-in/pydelphin
delphin/tdl.py
tokenize
def tokenize(s): """ Tokenize a string *s* of TDL code. """ return [m.group(m.lastindex) for m in _tdl_re.finditer(s)]
python
def tokenize(s): """ Tokenize a string *s* of TDL code. """ return [m.group(m.lastindex) for m in _tdl_re.finditer(s)]
[ "def", "tokenize", "(", "s", ")", ":", "return", "[", "m", ".", "group", "(", "m", ".", "lastindex", ")", "for", "m", "in", "_tdl_re", ".", "finditer", "(", "s", ")", "]" ]
Tokenize a string *s* of TDL code.
[ "Tokenize", "a", "string", "*", "s", "*", "of", "TDL", "code", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1544-L1548
delph-in/pydelphin
delphin/tdl.py
parse
def parse(f, encoding='utf-8'): """ Parse the TDL file *f* and yield the interpreted contents. If *f* is a filename, the file is opened and closed when the generator has finished, otherwise *f* is an open file object and will not be closed when the generator has finished. Args: f (str,...
python
def parse(f, encoding='utf-8'): """ Parse the TDL file *f* and yield the interpreted contents. If *f* is a filename, the file is opened and closed when the generator has finished, otherwise *f* is an open file object and will not be closed when the generator has finished. Args: f (str,...
[ "def", "parse", "(", "f", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "hasattr", "(", "f", ",", "'read'", ")", ":", "for", "event", "in", "_parse", "(", "f", ")", ":", "yield", "event", "else", ":", "with", "io", ".", "open", "(", "f", ","...
Parse the TDL file *f* and yield the interpreted contents. If *f* is a filename, the file is opened and closed when the generator has finished, otherwise *f* is an open file object and will not be closed when the generator has finished. Args: f (str, file): a filename or open file object ...
[ "Parse", "the", "TDL", "file", "*", "f", "*", "and", "yield", "the", "interpreted", "contents", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1614-L1633
delph-in/pydelphin
delphin/tdl.py
format
def format(obj, indent=0): """ Serialize TDL objects to strings. Args: obj: instance of :class:`Term`, :class:`Conjunction`, or :class:`TypeDefinition` classes or subclasses indent (int): number of spaces to indent the formatted object Returns: str: serialized form o...
python
def format(obj, indent=0): """ Serialize TDL objects to strings. Args: obj: instance of :class:`Term`, :class:`Conjunction`, or :class:`TypeDefinition` classes or subclasses indent (int): number of spaces to indent the formatted object Returns: str: serialized form o...
[ "def", "format", "(", "obj", ",", "indent", "=", "0", ")", ":", "if", "isinstance", "(", "obj", ",", "TypeDefinition", ")", ":", "return", "_format_typedef", "(", "obj", ",", "indent", ")", "elif", "isinstance", "(", "obj", ",", "Conjunction", ")", ":"...
Serialize TDL objects to strings. Args: obj: instance of :class:`Term`, :class:`Conjunction`, or :class:`TypeDefinition` classes or subclasses indent (int): number of spaces to indent the formatted object Returns: str: serialized form of *obj* Example: >>> conj =...
[ "Serialize", "TDL", "objects", "to", "strings", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L1872-L1906
delph-in/pydelphin
delphin/tdl.py
AVM.normalize
def normalize(self): """ Reduce trivial AVM conjunctions to just the AVM. For example, in `[ ATTR1 [ ATTR2 val ] ]` the value of `ATTR1` could be a conjunction with the sub-AVM `[ ATTR2 val ]`. This method removes the conjunction so the sub-AVM nests directly (equivalent...
python
def normalize(self): """ Reduce trivial AVM conjunctions to just the AVM. For example, in `[ ATTR1 [ ATTR2 val ] ]` the value of `ATTR1` could be a conjunction with the sub-AVM `[ ATTR2 val ]`. This method removes the conjunction so the sub-AVM nests directly (equivalent...
[ "def", "normalize", "(", "self", ")", ":", "for", "attr", "in", "self", ".", "_avm", ":", "val", "=", "self", ".", "_avm", "[", "attr", "]", "if", "isinstance", "(", "val", ",", "Conjunction", ")", ":", "val", ".", "normalize", "(", ")", "if", "l...
Reduce trivial AVM conjunctions to just the AVM. For example, in `[ ATTR1 [ ATTR2 val ] ]` the value of `ATTR1` could be a conjunction with the sub-AVM `[ ATTR2 val ]`. This method removes the conjunction so the sub-AVM nests directly (equivalent to `[ ATTR1.ATTR2 val ]` in TDL).
[ "Reduce", "trivial", "AVM", "conjunctions", "to", "just", "the", "AVM", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L230-L246
delph-in/pydelphin
delphin/tdl.py
AVM.features
def features(self, expand=False): """ Return the list of tuples of feature paths and feature values. Args: expand (bool): if `True`, expand all feature paths Example: >>> avm = AVM([('A.B', TypeIdentifier('1')), ... ('A.C', TypeIdentifier('...
python
def features(self, expand=False): """ Return the list of tuples of feature paths and feature values. Args: expand (bool): if `True`, expand all feature paths Example: >>> avm = AVM([('A.B', TypeIdentifier('1')), ... ('A.C', TypeIdentifier('...
[ "def", "features", "(", "self", ",", "expand", "=", "False", ")", ":", "fs", "=", "[", "]", "for", "featpath", ",", "val", "in", "super", "(", "AVM", ",", "self", ")", ".", "features", "(", "expand", "=", "expand", ")", ":", "# don't juse Conjunction...
Return the list of tuples of feature paths and feature values. Args: expand (bool): if `True`, expand all feature paths Example: >>> avm = AVM([('A.B', TypeIdentifier('1')), ... ('A.C', TypeIdentifier('2')]) >>> avm.features() [('A'...
[ "Return", "the", "list", "of", "tuples", "of", "feature", "paths", "and", "feature", "values", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L248-L276
delph-in/pydelphin
delphin/tdl.py
ConsList.values
def values(self): """ Return the list of values in the ConsList feature structure. """ if self._avm is None: return [] else: vals = [val for _, val in _collect_list_items(self)] # the < a . b > notation puts b on the last REST path, ...
python
def values(self): """ Return the list of values in the ConsList feature structure. """ if self._avm is None: return [] else: vals = [val for _, val in _collect_list_items(self)] # the < a . b > notation puts b on the last REST path, ...
[ "def", "values", "(", "self", ")", ":", "if", "self", ".", "_avm", "is", "None", ":", "return", "[", "]", "else", ":", "vals", "=", "[", "val", "for", "_", ",", "val", "in", "_collect_list_items", "(", "self", ")", "]", "# the < a . b > notation puts b...
Return the list of values in the ConsList feature structure.
[ "Return", "the", "list", "of", "values", "in", "the", "ConsList", "feature", "structure", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L327-L339
delph-in/pydelphin
delphin/tdl.py
ConsList.append
def append(self, value): """ Append an item to the end of an open ConsList. Args: value (:class:`Conjunction`, :class:`Term`): item to add Raises: :class:`TdlError`: when appending to a closed list """ if self._avm is not None and not self.termina...
python
def append(self, value): """ Append an item to the end of an open ConsList. Args: value (:class:`Conjunction`, :class:`Term`): item to add Raises: :class:`TdlError`: when appending to a closed list """ if self._avm is not None and not self.termina...
[ "def", "append", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_avm", "is", "not", "None", "and", "not", "self", ".", "terminated", ":", "path", "=", "self", ".", "_last_path", "if", "path", ":", "path", "+=", "'.'", "self", "[", "path",...
Append an item to the end of an open ConsList. Args: value (:class:`Conjunction`, :class:`Term`): item to add Raises: :class:`TdlError`: when appending to a closed list
[ "Append", "an", "item", "to", "the", "end", "of", "an", "open", "ConsList", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L341-L358
delph-in/pydelphin
delphin/tdl.py
ConsList.terminate
def terminate(self, end): """ Set the value of the tail of the list. Adding values via :meth:`append` places them on the `FIRST` feature of some level of the feature structure (e.g., `REST.FIRST`), while :meth:`terminate` places them on the final `REST` feature (e.g., `R...
python
def terminate(self, end): """ Set the value of the tail of the list. Adding values via :meth:`append` places them on the `FIRST` feature of some level of the feature structure (e.g., `REST.FIRST`), while :meth:`terminate` places them on the final `REST` feature (e.g., `R...
[ "def", "terminate", "(", "self", ",", "end", ")", ":", "if", "self", ".", "terminated", ":", "raise", "TdlError", "(", "'Cannot terminate a closed list.'", ")", "if", "end", "==", "LIST_TYPE", ":", "self", ".", "terminated", "=", "False", "elif", "end", "=...
Set the value of the tail of the list. Adding values via :meth:`append` places them on the `FIRST` feature of some level of the feature structure (e.g., `REST.FIRST`), while :meth:`terminate` places them on the final `REST` feature (e.g., `REST.REST`). If *end* is a :class:`Conj...
[ "Set", "the", "value", "of", "the", "tail", "of", "the", "list", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L360-L393
delph-in/pydelphin
delphin/tdl.py
Conjunction.normalize
def normalize(self): """ Rearrange the conjunction to a conventional form. This puts any coreference(s) first, followed by type terms, then followed by AVM(s) (including lists). AVMs are normalized via :meth:`AVM.normalize`. """ corefs = [] types = [] ...
python
def normalize(self): """ Rearrange the conjunction to a conventional form. This puts any coreference(s) first, followed by type terms, then followed by AVM(s) (including lists). AVMs are normalized via :meth:`AVM.normalize`. """ corefs = [] types = [] ...
[ "def", "normalize", "(", "self", ")", ":", "corefs", "=", "[", "]", "types", "=", "[", "]", "avms", "=", "[", "]", "for", "term", "in", "self", ".", "_terms", ":", "if", "isinstance", "(", "term", ",", "TypeTerm", ")", ":", "types", ".", "append"...
Rearrange the conjunction to a conventional form. This puts any coreference(s) first, followed by type terms, then followed by AVM(s) (including lists). AVMs are normalized via :meth:`AVM.normalize`.
[ "Rearrange", "the", "conjunction", "to", "a", "conventional", "form", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L547-L568
delph-in/pydelphin
delphin/tdl.py
Conjunction.add
def add(self, term): """ Add a term to the conjunction. Args: term (:class:`Term`, :class:`Conjunction`): term to add; if a :class:`Conjunction`, all of its terms are added to the current conjunction. Raises: :class:`TypeError`: wh...
python
def add(self, term): """ Add a term to the conjunction. Args: term (:class:`Term`, :class:`Conjunction`): term to add; if a :class:`Conjunction`, all of its terms are added to the current conjunction. Raises: :class:`TypeError`: wh...
[ "def", "add", "(", "self", ",", "term", ")", ":", "if", "isinstance", "(", "term", ",", "Conjunction", ")", ":", "for", "term_", "in", "term", ".", "terms", ":", "self", ".", "add", "(", "term_", ")", "elif", "isinstance", "(", "term", ",", "Term",...
Add a term to the conjunction. Args: term (:class:`Term`, :class:`Conjunction`): term to add; if a :class:`Conjunction`, all of its terms are added to the current conjunction. Raises: :class:`TypeError`: when *term* is an invalid type
[ "Add", "a", "term", "to", "the", "conjunction", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L575-L592
delph-in/pydelphin
delphin/tdl.py
Conjunction.types
def types(self): """Return the list of type terms in the conjunction.""" return [term for term in self._terms if isinstance(term, (TypeIdentifier, String, Regex))]
python
def types(self): """Return the list of type terms in the conjunction.""" return [term for term in self._terms if isinstance(term, (TypeIdentifier, String, Regex))]
[ "def", "types", "(", "self", ")", ":", "return", "[", "term", "for", "term", "in", "self", ".", "_terms", "if", "isinstance", "(", "term", ",", "(", "TypeIdentifier", ",", "String", ",", "Regex", ")", ")", "]" ]
Return the list of type terms in the conjunction.
[ "Return", "the", "list", "of", "type", "terms", "in", "the", "conjunction", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L594-L597
delph-in/pydelphin
delphin/tdl.py
Conjunction.features
def features(self, expand=False): """Return the list of feature-value pairs in the conjunction.""" featvals = [] for term in self._terms: if isinstance(term, AVM): featvals.extend(term.features(expand=expand)) return featvals
python
def features(self, expand=False): """Return the list of feature-value pairs in the conjunction.""" featvals = [] for term in self._terms: if isinstance(term, AVM): featvals.extend(term.features(expand=expand)) return featvals
[ "def", "features", "(", "self", ",", "expand", "=", "False", ")", ":", "featvals", "=", "[", "]", "for", "term", "in", "self", ".", "_terms", ":", "if", "isinstance", "(", "term", ",", "AVM", ")", ":", "featvals", ".", "extend", "(", "term", ".", ...
Return the list of feature-value pairs in the conjunction.
[ "Return", "the", "list", "of", "feature", "-", "value", "pairs", "in", "the", "conjunction", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L599-L605
delph-in/pydelphin
delphin/tdl.py
Conjunction.string
def string(self): """ Return the first string term in the conjunction, or `None`. """ for term in self._terms: if isinstance(term, String): return str(term) return None
python
def string(self): """ Return the first string term in the conjunction, or `None`. """ for term in self._terms: if isinstance(term, String): return str(term) return None
[ "def", "string", "(", "self", ")", ":", "for", "term", "in", "self", ".", "_terms", ":", "if", "isinstance", "(", "term", ",", "String", ")", ":", "return", "str", "(", "term", ")", "return", "None" ]
Return the first string term in the conjunction, or `None`.
[ "Return", "the", "first", "string", "term", "in", "the", "conjunction", "or", "None", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L607-L614
delph-in/pydelphin
delphin/tdl.py
TypeDefinition.documentation
def documentation(self, level='first'): """ Return the documentation of the type. By default, this is the first docstring on a top-level term. By setting *level* to `"top"`, the list of all docstrings on top-level terms is returned, including the type's `docstring` value...
python
def documentation(self, level='first'): """ Return the documentation of the type. By default, this is the first docstring on a top-level term. By setting *level* to `"top"`, the list of all docstrings on top-level terms is returned, including the type's `docstring` value...
[ "def", "documentation", "(", "self", ",", "level", "=", "'first'", ")", ":", "docs", "=", "(", "t", ".", "docstring", "for", "t", "in", "list", "(", "self", ".", "conjunction", ".", "terms", ")", "+", "[", "self", "]", "if", "t", ".", "docstring", ...
Return the documentation of the type. By default, this is the first docstring on a top-level term. By setting *level* to `"top"`, the list of all docstrings on top-level terms is returned, including the type's `docstring` value, if not `None`, as the last item. The docstring for the ...
[ "Return", "the", "documentation", "of", "the", "type", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L668-L690
delph-in/pydelphin
delphin/tdl.py
TdlDefinition.local_constraints
def local_constraints(self): """ Return the constraints defined in the local AVM. """ cs = [] for feat, val in self._avm.items(): try: if val.supertypes and not val._avm: cs.append((feat, val)) else: ...
python
def local_constraints(self): """ Return the constraints defined in the local AVM. """ cs = [] for feat, val in self._avm.items(): try: if val.supertypes and not val._avm: cs.append((feat, val)) else: ...
[ "def", "local_constraints", "(", "self", ")", ":", "cs", "=", "[", "]", "for", "feat", ",", "val", "in", "self", ".", "_avm", ".", "items", "(", ")", ":", "try", ":", "if", "val", ".", "supertypes", "and", "not", "val", ".", "_avm", ":", "cs", ...
Return the constraints defined in the local AVM.
[ "Return", "the", "constraints", "defined", "in", "the", "local", "AVM", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L876-L890
delph-in/pydelphin
delphin/tdl.py
TdlConsList.values
def values(self): """ Return the list of values. """ def collect(d): if d is None or d.get('FIRST') is None: return [] vals = [d['FIRST']] vals.extend(collect(d.get('REST'))) return vals return collect(self)
python
def values(self): """ Return the list of values. """ def collect(d): if d is None or d.get('FIRST') is None: return [] vals = [d['FIRST']] vals.extend(collect(d.get('REST'))) return vals return collect(self)
[ "def", "values", "(", "self", ")", ":", "def", "collect", "(", "d", ")", ":", "if", "d", "is", "None", "or", "d", ".", "get", "(", "'FIRST'", ")", "is", "None", ":", "return", "[", "]", "vals", "=", "[", "d", "[", "'FIRST'", "]", "]", "vals",...
Return the list of values.
[ "Return", "the", "list", "of", "values", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tdl.py#L905-L915
luckydonald/pytgbot
pytgbot/api_types/receivable/peer.py
ChatMember.from_array
def from_array(array): """ Deserialize a new ChatMember from a given dictionary. :return: new ChatMember instance. :rtype: ChatMember """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="arr...
python
def from_array(array): """ Deserialize a new ChatMember from a given dictionary. :return: new ChatMember instance. :rtype: ChatMember """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="arr...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "data", "=", "{", "}", "da...
Deserialize a new ChatMember from a given dictionary. :return: new ChatMember instance. :rtype: ChatMember
[ "Deserialize", "a", "new", "ChatMember", "from", "a", "given", "dictionary", "." ]
train
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/peer.py#L647-L677
delph-in/pydelphin
delphin/mrs/semi.py
Variable.from_dict
def from_dict(cls, d): """Instantiate a Variable from a dictionary representation.""" return cls( d['type'], tuple(d['parents']), list(d['properties'].items()) )
python
def from_dict(cls, d): """Instantiate a Variable from a dictionary representation.""" return cls( d['type'], tuple(d['parents']), list(d['properties'].items()) )
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "return", "cls", "(", "d", "[", "'type'", "]", ",", "tuple", "(", "d", "[", "'parents'", "]", ")", ",", "list", "(", "d", "[", "'properties'", "]", ".", "items", "(", ")", ")", ")" ]
Instantiate a Variable from a dictionary representation.
[ "Instantiate", "a", "Variable", "from", "a", "dictionary", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L77-L81
delph-in/pydelphin
delphin/mrs/semi.py
Role.from_dict
def from_dict(cls, d): """Instantiate a Role from a dictionary representation.""" return cls( d['rargname'], d['value'], list(d.get('properties', {}).items()), d.get('optional', False) )
python
def from_dict(cls, d): """Instantiate a Role from a dictionary representation.""" return cls( d['rargname'], d['value'], list(d.get('properties', {}).items()), d.get('optional', False) )
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "return", "cls", "(", "d", "[", "'rargname'", "]", ",", "d", "[", "'value'", "]", ",", "list", "(", "d", ".", "get", "(", "'properties'", ",", "{", "}", ")", ".", "items", "(", ")", ")", ","...
Instantiate a Role from a dictionary representation.
[ "Instantiate", "a", "Role", "from", "a", "dictionary", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L107-L114
delph-in/pydelphin
delphin/mrs/semi.py
Role.to_dict
def to_dict(self): """Return a dictionary representation of the Role.""" d = {'rargname': self.rargname, 'value': self.value} if self.properties: d['properties'] = self.properties if self.optional: d['optional'] = self.optional return d
python
def to_dict(self): """Return a dictionary representation of the Role.""" d = {'rargname': self.rargname, 'value': self.value} if self.properties: d['properties'] = self.properties if self.optional: d['optional'] = self.optional return d
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "{", "'rargname'", ":", "self", ".", "rargname", ",", "'value'", ":", "self", ".", "value", "}", "if", "self", ".", "properties", ":", "d", "[", "'properties'", "]", "=", "self", ".", "properties", ...
Return a dictionary representation of the Role.
[ "Return", "a", "dictionary", "representation", "of", "the", "Role", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L116-L123
delph-in/pydelphin
delphin/mrs/semi.py
Predicate.from_dict
def from_dict(cls, d): """Instantiate a Predicate from a dictionary representation.""" synopses = [tuple(map(Role.from_dict, synopsis)) for synopsis in d.get('synopses', [])] return cls(d['predicate'], tuple(d['parents']), synopses)
python
def from_dict(cls, d): """Instantiate a Predicate from a dictionary representation.""" synopses = [tuple(map(Role.from_dict, synopsis)) for synopsis in d.get('synopses', [])] return cls(d['predicate'], tuple(d['parents']), synopses)
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "synopses", "=", "[", "tuple", "(", "map", "(", "Role", ".", "from_dict", ",", "synopsis", ")", ")", "for", "synopsis", "in", "d", ".", "get", "(", "'synopses'", ",", "[", "]", ")", "]", "return...
Instantiate a Predicate from a dictionary representation.
[ "Instantiate", "a", "Predicate", "from", "a", "dictionary", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L144-L148
delph-in/pydelphin
delphin/mrs/semi.py
Predicate.to_dict
def to_dict(self): """Return a dictionary representation of the Predicate.""" return { 'predicate': self.predicate, 'parents': list(self.supertypes), 'synopses': [[role.to_dict() for role in synopsis] for synopsis in self.synopses] }
python
def to_dict(self): """Return a dictionary representation of the Predicate.""" return { 'predicate': self.predicate, 'parents': list(self.supertypes), 'synopses': [[role.to_dict() for role in synopsis] for synopsis in self.synopses] }
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "'predicate'", ":", "self", ".", "predicate", ",", "'parents'", ":", "list", "(", "self", ".", "supertypes", ")", ",", "'synopses'", ":", "[", "[", "role", ".", "to_dict", "(", ")", "for", "role...
Return a dictionary representation of the Predicate.
[ "Return", "a", "dictionary", "representation", "of", "the", "Predicate", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L150-L157
delph-in/pydelphin
delphin/mrs/semi.py
SemI.from_dict
def from_dict(cls, d): """Instantiate a SemI from a dictionary representation.""" read = lambda cls: (lambda pair: (pair[0], cls.from_dict(pair[1]))) return cls( variables=map(read(Variable), d.get('variables', {}).items()), properties=map(read(Property), d.get('propertie...
python
def from_dict(cls, d): """Instantiate a SemI from a dictionary representation.""" read = lambda cls: (lambda pair: (pair[0], cls.from_dict(pair[1]))) return cls( variables=map(read(Variable), d.get('variables', {}).items()), properties=map(read(Property), d.get('propertie...
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "read", "=", "lambda", "cls", ":", "(", "lambda", "pair", ":", "(", "pair", "[", "0", "]", ",", "cls", ".", "from_dict", "(", "pair", "[", "1", "]", ")", ")", ")", "return", "cls", "(", "var...
Instantiate a SemI from a dictionary representation.
[ "Instantiate", "a", "SemI", "from", "a", "dictionary", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L322-L330
delph-in/pydelphin
delphin/mrs/semi.py
SemI.to_dict
def to_dict(self): """Return a dictionary representation of the SemI.""" make = lambda pair: (pair[0], pair[1].to_dict()) return dict( variables=dict(make(v) for v in self.variables.items()), properties=dict(make(p) for p in self.properties.items()), roles=dic...
python
def to_dict(self): """Return a dictionary representation of the SemI.""" make = lambda pair: (pair[0], pair[1].to_dict()) return dict( variables=dict(make(v) for v in self.variables.items()), properties=dict(make(p) for p in self.properties.items()), roles=dic...
[ "def", "to_dict", "(", "self", ")", ":", "make", "=", "lambda", "pair", ":", "(", "pair", "[", "0", "]", ",", "pair", "[", "1", "]", ".", "to_dict", "(", ")", ")", "return", "dict", "(", "variables", "=", "dict", "(", "make", "(", "v", ")", "...
Return a dictionary representation of the SemI.
[ "Return", "a", "dictionary", "representation", "of", "the", "SemI", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/semi.py#L332-L340
delph-in/pydelphin
delphin/mrs/components.py
sort_vid_split
def sort_vid_split(vs): """ Split a valid variable string into its variable sort and id. Examples: >>> sort_vid_split('h3') ('h', '3') >>> sort_vid_split('ref-ind12') ('ref-ind', '12') """ match = var_re.match(vs) if match is None: raise ValueError('Inval...
python
def sort_vid_split(vs): """ Split a valid variable string into its variable sort and id. Examples: >>> sort_vid_split('h3') ('h', '3') >>> sort_vid_split('ref-ind12') ('ref-ind', '12') """ match = var_re.match(vs) if match is None: raise ValueError('Inval...
[ "def", "sort_vid_split", "(", "vs", ")", ":", "match", "=", "var_re", ".", "match", "(", "vs", ")", "if", "match", "is", "None", ":", "raise", "ValueError", "(", "'Invalid variable string: {}'", ".", "format", "(", "str", "(", "vs", ")", ")", ")", "els...
Split a valid variable string into its variable sort and id. Examples: >>> sort_vid_split('h3') ('h', '3') >>> sort_vid_split('ref-ind12') ('ref-ind', '12')
[ "Split", "a", "valid", "variable", "string", "into", "its", "variable", "sort", "and", "id", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L31-L45
delph-in/pydelphin
delphin/mrs/components.py
links
def links(xmrs): """Return the list of Links for the *xmrs*.""" # Links exist for every non-intrinsic argument that has a variable # that is the intrinsic variable of some other predicate, as well # as for label equalities when no argument link exists (even # considering transitivity). links = ...
python
def links(xmrs): """Return the list of Links for the *xmrs*.""" # Links exist for every non-intrinsic argument that has a variable # that is the intrinsic variable of some other predicate, as well # as for label equalities when no argument link exists (even # considering transitivity). links = ...
[ "def", "links", "(", "xmrs", ")", ":", "# Links exist for every non-intrinsic argument that has a variable", "# that is the intrinsic variable of some other predicate, as well", "# as for label equalities when no argument link exists (even", "# considering transitivity).", "links", "=", "[",...
Return the list of Links for the *xmrs*.
[ "Return", "the", "list", "of", "Links", "for", "the", "*", "xmrs", "*", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L298-L371
delph-in/pydelphin
delphin/mrs/components.py
hcons
def hcons(xmrs): """Return the list of all HandleConstraints in *xmrs*.""" return [ HandleConstraint(hi, reln, lo) for hi, reln, lo in sorted(xmrs.hcons(), key=lambda hc: var_id(hc[0])) ]
python
def hcons(xmrs): """Return the list of all HandleConstraints in *xmrs*.""" return [ HandleConstraint(hi, reln, lo) for hi, reln, lo in sorted(xmrs.hcons(), key=lambda hc: var_id(hc[0])) ]
[ "def", "hcons", "(", "xmrs", ")", ":", "return", "[", "HandleConstraint", "(", "hi", ",", "reln", ",", "lo", ")", "for", "hi", ",", "reln", ",", "lo", "in", "sorted", "(", "xmrs", ".", "hcons", "(", ")", ",", "key", "=", "lambda", "hc", ":", "v...
Return the list of all HandleConstraints in *xmrs*.
[ "Return", "the", "list", "of", "all", "HandleConstraints", "in", "*", "xmrs", "*", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L404-L409
delph-in/pydelphin
delphin/mrs/components.py
icons
def icons(xmrs): """Return the list of all IndividualConstraints in *xmrs*.""" return [ IndividualConstraint(left, reln, right) for left, reln, right in sorted(xmrs.icons(), key=lambda ic: var_id(ic[0])) ]
python
def icons(xmrs): """Return the list of all IndividualConstraints in *xmrs*.""" return [ IndividualConstraint(left, reln, right) for left, reln, right in sorted(xmrs.icons(), key=lambda ic: var_id(ic[0])) ]
[ "def", "icons", "(", "xmrs", ")", ":", "return", "[", "IndividualConstraint", "(", "left", ",", "reln", ",", "right", ")", "for", "left", ",", "reln", ",", "right", "in", "sorted", "(", "xmrs", ".", "icons", "(", ")", ",", "key", "=", "lambda", "ic...
Return the list of all IndividualConstraints in *xmrs*.
[ "Return", "the", "list", "of", "all", "IndividualConstraints", "in", "*", "xmrs", "*", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L427-L433
delph-in/pydelphin
delphin/mrs/components.py
split_pred_string
def split_pred_string(predstr): """ Split *predstr* and return the (lemma, pos, sense, suffix) components. Examples: >>> Pred.split_pred_string('_dog_n_1_rel') ('dog', 'n', '1', 'rel') >>> Pred.split_pred_string('quant_rel') ('quant', None, None, 'rel') """ predstr =...
python
def split_pred_string(predstr): """ Split *predstr* and return the (lemma, pos, sense, suffix) components. Examples: >>> Pred.split_pred_string('_dog_n_1_rel') ('dog', 'n', '1', 'rel') >>> Pred.split_pred_string('quant_rel') ('quant', None, None, 'rel') """ predstr =...
[ "def", "split_pred_string", "(", "predstr", ")", ":", "predstr", "=", "predstr", ".", "strip", "(", "'\"\\''", ")", "# surrounding quotes don't matter", "rel_added", "=", "False", "if", "not", "predstr", ".", "lower", "(", ")", ".", "endswith", "(", "'_rel'", ...
Split *predstr* and return the (lemma, pos, sense, suffix) components. Examples: >>> Pred.split_pred_string('_dog_n_1_rel') ('dog', 'n', '1', 'rel') >>> Pred.split_pred_string('quant_rel') ('quant', None, None, 'rel')
[ "Split", "*", "predstr", "*", "and", "return", "the", "(", "lemma", "pos", "sense", "suffix", ")", "components", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L595-L618
delph-in/pydelphin
delphin/mrs/components.py
is_valid_pred_string
def is_valid_pred_string(predstr): """ Return `True` if *predstr* is a valid predicate string. Examples: >>> is_valid_pred_string('"_dog_n_1_rel"') True >>> is_valid_pred_string('_dog_n_1') True >>> is_valid_pred_string('_dog_noun_1') False >>> is_val...
python
def is_valid_pred_string(predstr): """ Return `True` if *predstr* is a valid predicate string. Examples: >>> is_valid_pred_string('"_dog_n_1_rel"') True >>> is_valid_pred_string('_dog_n_1') True >>> is_valid_pred_string('_dog_noun_1') False >>> is_val...
[ "def", "is_valid_pred_string", "(", "predstr", ")", ":", "predstr", "=", "predstr", ".", "strip", "(", "'\"'", ")", ".", "lstrip", "(", "\"'\"", ")", "# this is a stricter regex than in Pred, but doesn't check POS", "return", "re", ".", "match", "(", "r'_([^ _\\\\]|...
Return `True` if *predstr* is a valid predicate string. Examples: >>> is_valid_pred_string('"_dog_n_1_rel"') True >>> is_valid_pred_string('_dog_n_1') True >>> is_valid_pred_string('_dog_noun_1') False >>> is_valid_pred_string('dog_noun_1') True
[ "Return", "True", "if", "*", "predstr", "*", "is", "a", "valid", "predicate", "string", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L621-L641
delph-in/pydelphin
delphin/mrs/components.py
normalize_pred_string
def normalize_pred_string(predstr): """ Normalize the predicate string *predstr* to a conventional form. This makes predicate strings more consistent by removing quotes and the `_rel` suffix, and by lowercasing them. Examples: >>> normalize_pred_string('"_dog_n_1_rel"') '_dog_n_1' ...
python
def normalize_pred_string(predstr): """ Normalize the predicate string *predstr* to a conventional form. This makes predicate strings more consistent by removing quotes and the `_rel` suffix, and by lowercasing them. Examples: >>> normalize_pred_string('"_dog_n_1_rel"') '_dog_n_1' ...
[ "def", "normalize_pred_string", "(", "predstr", ")", ":", "tokens", "=", "[", "t", "for", "t", "in", "split_pred_string", "(", "predstr", ")", "[", ":", "3", "]", "if", "t", "is", "not", "None", "]", "if", "predstr", ".", "lstrip", "(", "'\\'\"'", ")...
Normalize the predicate string *predstr* to a conventional form. This makes predicate strings more consistent by removing quotes and the `_rel` suffix, and by lowercasing them. Examples: >>> normalize_pred_string('"_dog_n_1_rel"') '_dog_n_1' >>> normalize_pred_string('_dog_n_1') ...
[ "Normalize", "the", "predicate", "string", "*", "predstr", "*", "to", "a", "conventional", "form", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L644-L660
delph-in/pydelphin
delphin/mrs/components.py
nodes
def nodes(xmrs): """Return the list of Nodes for *xmrs*.""" nodes = [] _props = xmrs.properties varsplit = sort_vid_split for p in xmrs.eps(): sortinfo = None iv = p.intrinsic_variable if iv is not None: sort, _ = varsplit(iv) sortinfo = _props(iv) ...
python
def nodes(xmrs): """Return the list of Nodes for *xmrs*.""" nodes = [] _props = xmrs.properties varsplit = sort_vid_split for p in xmrs.eps(): sortinfo = None iv = p.intrinsic_variable if iv is not None: sort, _ = varsplit(iv) sortinfo = _props(iv) ...
[ "def", "nodes", "(", "xmrs", ")", ":", "nodes", "=", "[", "]", "_props", "=", "xmrs", ".", "properties", "varsplit", "=", "sort_vid_split", "for", "p", "in", "xmrs", ".", "eps", "(", ")", ":", "sortinfo", "=", "None", "iv", "=", "p", ".", "intrinsi...
Return the list of Nodes for *xmrs*.
[ "Return", "the", "list", "of", "Nodes", "for", "*", "xmrs", "*", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L786-L801
delph-in/pydelphin
delphin/mrs/components.py
_VarGenerator.new
def new(self, sort, properties=None): """ Create a new variable for the given *sort*. """ if sort is None: sort = UNKNOWNSORT # find next available vid vid, index = self.vid, self.index while vid in index: vid += 1 varstring = '{}{}...
python
def new(self, sort, properties=None): """ Create a new variable for the given *sort*. """ if sort is None: sort = UNKNOWNSORT # find next available vid vid, index = self.vid, self.index while vid in index: vid += 1 varstring = '{}{}...
[ "def", "new", "(", "self", ",", "sort", ",", "properties", "=", "None", ")", ":", "if", "sort", "is", "None", ":", "sort", "=", "UNKNOWNSORT", "# find next available vid", "vid", ",", "index", "=", "self", ".", "vid", ",", "self", ".", "index", "while"...
Create a new variable for the given *sort*.
[ "Create", "a", "new", "variable", "for", "the", "given", "*", "sort", "*", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L85-L101
delph-in/pydelphin
delphin/mrs/components.py
Lnk.charspan
def charspan(cls, start, end): """ Create a Lnk object for a character span. Args: start: the initial character position (cfrom) end: the final character position (cto) """ return cls(Lnk.CHARSPAN, (int(start), int(end)))
python
def charspan(cls, start, end): """ Create a Lnk object for a character span. Args: start: the initial character position (cfrom) end: the final character position (cto) """ return cls(Lnk.CHARSPAN, (int(start), int(end)))
[ "def", "charspan", "(", "cls", ",", "start", ",", "end", ")", ":", "return", "cls", "(", "Lnk", ".", "CHARSPAN", ",", "(", "int", "(", "start", ")", ",", "int", "(", "end", ")", ")", ")" ]
Create a Lnk object for a character span. Args: start: the initial character position (cfrom) end: the final character position (cto)
[ "Create", "a", "Lnk", "object", "for", "a", "character", "span", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L160-L168
delph-in/pydelphin
delphin/mrs/components.py
Lnk.chartspan
def chartspan(cls, start, end): """ Create a Lnk object for a chart span. Args: start: the initial chart vertex end: the final chart vertex """ return cls(Lnk.CHARTSPAN, (int(start), int(end)))
python
def chartspan(cls, start, end): """ Create a Lnk object for a chart span. Args: start: the initial chart vertex end: the final chart vertex """ return cls(Lnk.CHARTSPAN, (int(start), int(end)))
[ "def", "chartspan", "(", "cls", ",", "start", ",", "end", ")", ":", "return", "cls", "(", "Lnk", ".", "CHARTSPAN", ",", "(", "int", "(", "start", ")", ",", "int", "(", "end", ")", ")", ")" ]
Create a Lnk object for a chart span. Args: start: the initial chart vertex end: the final chart vertex
[ "Create", "a", "Lnk", "object", "for", "a", "chart", "span", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L171-L179
delph-in/pydelphin
delphin/mrs/components.py
Lnk.tokens
def tokens(cls, tokens): """ Create a Lnk object for a token range. Args: tokens: a list of token identifiers """ return cls(Lnk.TOKENS, tuple(map(int, tokens)))
python
def tokens(cls, tokens): """ Create a Lnk object for a token range. Args: tokens: a list of token identifiers """ return cls(Lnk.TOKENS, tuple(map(int, tokens)))
[ "def", "tokens", "(", "cls", ",", "tokens", ")", ":", "return", "cls", "(", "Lnk", ".", "TOKENS", ",", "tuple", "(", "map", "(", "int", ",", "tokens", ")", ")", ")" ]
Create a Lnk object for a token range. Args: tokens: a list of token identifiers
[ "Create", "a", "Lnk", "object", "for", "a", "token", "range", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L182-L189
delph-in/pydelphin
delphin/mrs/components.py
_LnkMixin.cfrom
def cfrom(self): """ The initial character position in the surface string. Defaults to -1 if there is no valid cfrom value. """ cfrom = -1 try: if self.lnk.type == Lnk.CHARSPAN: cfrom = self.lnk.data[0] except AttributeError: ...
python
def cfrom(self): """ The initial character position in the surface string. Defaults to -1 if there is no valid cfrom value. """ cfrom = -1 try: if self.lnk.type == Lnk.CHARSPAN: cfrom = self.lnk.data[0] except AttributeError: ...
[ "def", "cfrom", "(", "self", ")", ":", "cfrom", "=", "-", "1", "try", ":", "if", "self", ".", "lnk", ".", "type", "==", "Lnk", ".", "CHARSPAN", ":", "cfrom", "=", "self", ".", "lnk", ".", "data", "[", "0", "]", "except", "AttributeError", ":", ...
The initial character position in the surface string. Defaults to -1 if there is no valid cfrom value.
[ "The", "initial", "character", "position", "in", "the", "surface", "string", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L232-L244
delph-in/pydelphin
delphin/mrs/components.py
_LnkMixin.cto
def cto(self): """ The final character position in the surface string. Defaults to -1 if there is no valid cto value. """ cto = -1 try: if self.lnk.type == Lnk.CHARSPAN: cto = self.lnk.data[1] except AttributeError: pass #...
python
def cto(self): """ The final character position in the surface string. Defaults to -1 if there is no valid cto value. """ cto = -1 try: if self.lnk.type == Lnk.CHARSPAN: cto = self.lnk.data[1] except AttributeError: pass #...
[ "def", "cto", "(", "self", ")", ":", "cto", "=", "-", "1", "try", ":", "if", "self", ".", "lnk", ".", "type", "==", "Lnk", ".", "CHARSPAN", ":", "cto", "=", "self", ".", "lnk", ".", "data", "[", "1", "]", "except", "AttributeError", ":", "pass"...
The final character position in the surface string. Defaults to -1 if there is no valid cto value.
[ "The", "final", "character", "position", "in", "the", "surface", "string", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L247-L259
delph-in/pydelphin
delphin/mrs/components.py
Pred.surface
def surface(cls, predstr): """Instantiate a Pred from its quoted string representation.""" lemma, pos, sense, _ = split_pred_string(predstr) return cls(Pred.SURFACE, lemma, pos, sense, predstr)
python
def surface(cls, predstr): """Instantiate a Pred from its quoted string representation.""" lemma, pos, sense, _ = split_pred_string(predstr) return cls(Pred.SURFACE, lemma, pos, sense, predstr)
[ "def", "surface", "(", "cls", ",", "predstr", ")", ":", "lemma", ",", "pos", ",", "sense", ",", "_", "=", "split_pred_string", "(", "predstr", ")", "return", "cls", "(", "Pred", ".", "SURFACE", ",", "lemma", ",", "pos", ",", "sense", ",", "predstr", ...
Instantiate a Pred from its quoted string representation.
[ "Instantiate", "a", "Pred", "from", "its", "quoted", "string", "representation", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L524-L527
delph-in/pydelphin
delphin/mrs/components.py
Pred.abstract
def abstract(cls, predstr): """Instantiate a Pred from its symbol string.""" lemma, pos, sense, _ = split_pred_string(predstr) return cls(Pred.ABSTRACT, lemma, pos, sense, predstr)
python
def abstract(cls, predstr): """Instantiate a Pred from its symbol string.""" lemma, pos, sense, _ = split_pred_string(predstr) return cls(Pred.ABSTRACT, lemma, pos, sense, predstr)
[ "def", "abstract", "(", "cls", ",", "predstr", ")", ":", "lemma", ",", "pos", ",", "sense", ",", "_", "=", "split_pred_string", "(", "predstr", ")", "return", "cls", "(", "Pred", ".", "ABSTRACT", ",", "lemma", ",", "pos", ",", "sense", ",", "predstr"...
Instantiate a Pred from its symbol string.
[ "Instantiate", "a", "Pred", "from", "its", "symbol", "string", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L536-L539
delph-in/pydelphin
delphin/mrs/components.py
Pred.surface_or_abstract
def surface_or_abstract(cls, predstr): """Instantiate a Pred from either its surface or abstract symbol.""" if predstr.strip('"').lstrip("'").startswith('_'): return cls.surface(predstr) else: return cls.abstract(predstr)
python
def surface_or_abstract(cls, predstr): """Instantiate a Pred from either its surface or abstract symbol.""" if predstr.strip('"').lstrip("'").startswith('_'): return cls.surface(predstr) else: return cls.abstract(predstr)
[ "def", "surface_or_abstract", "(", "cls", ",", "predstr", ")", ":", "if", "predstr", ".", "strip", "(", "'\"'", ")", ".", "lstrip", "(", "\"'\"", ")", ".", "startswith", "(", "'_'", ")", ":", "return", "cls", ".", "surface", "(", "predstr", ")", "els...
Instantiate a Pred from either its surface or abstract symbol.
[ "Instantiate", "a", "Pred", "from", "either", "its", "surface", "or", "abstract", "symbol", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L548-L553
delph-in/pydelphin
delphin/mrs/components.py
Pred.realpred
def realpred(cls, lemma, pos, sense=None): """Instantiate a Pred from its components.""" string_tokens = [lemma] if pos is not None: string_tokens.append(pos) if sense is not None: sense = str(sense) string_tokens.append(sense) predstr = '_'.jo...
python
def realpred(cls, lemma, pos, sense=None): """Instantiate a Pred from its components.""" string_tokens = [lemma] if pos is not None: string_tokens.append(pos) if sense is not None: sense = str(sense) string_tokens.append(sense) predstr = '_'.jo...
[ "def", "realpred", "(", "cls", ",", "lemma", ",", "pos", ",", "sense", "=", "None", ")", ":", "string_tokens", "=", "[", "lemma", "]", "if", "pos", "is", "not", "None", ":", "string_tokens", ".", "append", "(", "pos", ")", "if", "sense", "is", "not...
Instantiate a Pred from its components.
[ "Instantiate", "a", "Pred", "from", "its", "components", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L556-L565
delph-in/pydelphin
delphin/mrs/components.py
Node.properties
def properties(self): """ Morphosemantic property mapping. Unlike :attr:`sortinfo`, this does not include `cvarsort`. """ d = dict(self.sortinfo) if CVARSORT in d: del d[CVARSORT] return d
python
def properties(self): """ Morphosemantic property mapping. Unlike :attr:`sortinfo`, this does not include `cvarsort`. """ d = dict(self.sortinfo) if CVARSORT in d: del d[CVARSORT] return d
[ "def", "properties", "(", "self", ")", ":", "d", "=", "dict", "(", "self", ".", "sortinfo", ")", "if", "CVARSORT", "in", "d", ":", "del", "d", "[", "CVARSORT", "]", "return", "d" ]
Morphosemantic property mapping. Unlike :attr:`sortinfo`, this does not include `cvarsort`.
[ "Morphosemantic", "property", "mapping", "." ]
train
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/components.py#L762-L771
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
EntityRepresentation.update_get_params
def update_get_params(self): """Update HTTP GET params with the given fields that user wants to fetch.""" if isinstance(self._fields, (tuple, list)): # tuples & lists > x,y,z self.get_params["fields"] = ",".join([str(_) for _ in self._fields]) elif isinstance(self._fields, str): ...
python
def update_get_params(self): """Update HTTP GET params with the given fields that user wants to fetch.""" if isinstance(self._fields, (tuple, list)): # tuples & lists > x,y,z self.get_params["fields"] = ",".join([str(_) for _ in self._fields]) elif isinstance(self._fields, str): ...
[ "def", "update_get_params", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_fields", ",", "(", "tuple", ",", "list", ")", ")", ":", "# tuples & lists > x,y,z", "self", ".", "get_params", "[", "\"fields\"", "]", "=", "\",\"", ".", "join", "...
Update HTTP GET params with the given fields that user wants to fetch.
[ "Update", "HTTP", "GET", "params", "with", "the", "given", "fields", "that", "user", "wants", "to", "fetch", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L54-L59
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
EntityRepresentation._fetch_meta_data
def _fetch_meta_data(self): """Makes an API call to fetch meta data for the given probe and stores the raw data.""" is_success, meta_data = AtlasRequest( url_path=self.API_META_URL.format(self.id), key=self.api_key, server=self.server, verify=self.verify, ...
python
def _fetch_meta_data(self): """Makes an API call to fetch meta data for the given probe and stores the raw data.""" is_success, meta_data = AtlasRequest( url_path=self.API_META_URL.format(self.id), key=self.api_key, server=self.server, verify=self.verify, ...
[ "def", "_fetch_meta_data", "(", "self", ")", ":", "is_success", ",", "meta_data", "=", "AtlasRequest", "(", "url_path", "=", "self", ".", "API_META_URL", ".", "format", "(", "self", ".", "id", ")", ",", "key", "=", "self", ".", "api_key", ",", "server", ...
Makes an API call to fetch meta data for the given probe and stores the raw data.
[ "Makes", "an", "API", "call", "to", "fetch", "meta", "data", "for", "the", "given", "probe", "and", "stores", "the", "raw", "data", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L61-L75
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
Probe._populate_data
def _populate_data(self): """Assing some probe's raw meta data from API response to instance properties""" if self.id is None: self.id = self.meta_data.get("id") self.is_anchor = self.meta_data.get("is_anchor") self.country_code = self.meta_data.get("country_code") se...
python
def _populate_data(self): """Assing some probe's raw meta data from API response to instance properties""" if self.id is None: self.id = self.meta_data.get("id") self.is_anchor = self.meta_data.get("is_anchor") self.country_code = self.meta_data.get("country_code") se...
[ "def", "_populate_data", "(", "self", ")", ":", "if", "self", ".", "id", "is", "None", ":", "self", ".", "id", "=", "self", ".", "meta_data", ".", "get", "(", "\"id\"", ")", "self", ".", "is_anchor", "=", "self", ".", "meta_data", ".", "get", "(", ...
Assing some probe's raw meta data from API response to instance properties
[ "Assing", "some", "probe", "s", "raw", "meta", "data", "from", "API", "response", "to", "instance", "properties" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L90-L106
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
Measurement._populate_data
def _populate_data(self): """Assinging some measurement's raw meta data from API response to instance properties""" if self.id is None: self.id = self.meta_data.get("id") self.stop_time = None self.creation_time = None self.start_time = None self.populate_tim...
python
def _populate_data(self): """Assinging some measurement's raw meta data from API response to instance properties""" if self.id is None: self.id = self.meta_data.get("id") self.stop_time = None self.creation_time = None self.start_time = None self.populate_tim...
[ "def", "_populate_data", "(", "self", ")", ":", "if", "self", ".", "id", "is", "None", ":", "self", ".", "id", "=", "self", ".", "meta_data", ".", "get", "(", "\"id\"", ")", "self", ".", "stop_time", "=", "None", "self", ".", "creation_time", "=", ...
Assinging some measurement's raw meta data from API response to instance properties
[ "Assinging", "some", "measurement", "s", "raw", "meta", "data", "from", "API", "response", "to", "instance", "properties" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L121-L142
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
Measurement.get_type
def get_type(self): """ Getting type of measurement keeping backwards compatibility for v2 API output changes. """ mtype = None if "type" not in self.meta_data: return mtype mtype = self.meta_data["type"] if isinstance(mtype, dict): ...
python
def get_type(self): """ Getting type of measurement keeping backwards compatibility for v2 API output changes. """ mtype = None if "type" not in self.meta_data: return mtype mtype = self.meta_data["type"] if isinstance(mtype, dict): ...
[ "def", "get_type", "(", "self", ")", ":", "mtype", "=", "None", "if", "\"type\"", "not", "in", "self", ".", "meta_data", ":", "return", "mtype", "mtype", "=", "self", ".", "meta_data", "[", "\"type\"", "]", "if", "isinstance", "(", "mtype", ",", "dict"...
Getting type of measurement keeping backwards compatibility for v2 API output changes.
[ "Getting", "type", "of", "measurement", "keeping", "backwards", "compatibility", "for", "v2", "API", "output", "changes", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L144-L159
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/api_meta_data.py
Measurement.populate_times
def populate_times(self): """ Populates all different meta data times that comes with measurement if they are present. """ stop_time = self.meta_data.get("stop_time") if stop_time: stop_naive = datetime.utcfromtimestamp(stop_time) self.stop_time = ...
python
def populate_times(self): """ Populates all different meta data times that comes with measurement if they are present. """ stop_time = self.meta_data.get("stop_time") if stop_time: stop_naive = datetime.utcfromtimestamp(stop_time) self.stop_time = ...
[ "def", "populate_times", "(", "self", ")", ":", "stop_time", "=", "self", ".", "meta_data", ".", "get", "(", "\"stop_time\"", ")", "if", "stop_time", ":", "stop_naive", "=", "datetime", ".", "utcfromtimestamp", "(", "stop_time", ")", "self", ".", "stop_time"...
Populates all different meta data times that comes with measurement if they are present.
[ "Populates", "all", "different", "meta", "data", "times", "that", "comes", "with", "measurement", "if", "they", "are", "present", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/api_meta_data.py#L161-L179
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasSource.set_type
def set_type(self, value): """Setter for type attribute""" if value not in self.types_available: log = "Sources field 'type' should be in one of %s" % ( self.types_available ) raise MalFormattedSource(log) self._type = value
python
def set_type(self, value): """Setter for type attribute""" if value not in self.types_available: log = "Sources field 'type' should be in one of %s" % ( self.types_available ) raise MalFormattedSource(log) self._type = value
[ "def", "set_type", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ".", "types_available", ":", "log", "=", "\"Sources field 'type' should be in one of %s\"", "%", "(", "self", ".", "types_available", ")", "raise", "MalFormattedSource", ...
Setter for type attribute
[ "Setter", "for", "type", "attribute" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L83-L90
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasSource.set_tags
def set_tags(self, value): """Setter for tags attribute""" log = ( 'Sources fields "tags" should be a dict in the format ' '{"include": [ "tag1", "tag2", "tagN" ],' '"exclude": [ "tag1", "tag2", "tagN" ] }' ) if not isinstance(value, dict): ...
python
def set_tags(self, value): """Setter for tags attribute""" log = ( 'Sources fields "tags" should be a dict in the format ' '{"include": [ "tag1", "tag2", "tagN" ],' '"exclude": [ "tag1", "tag2", "tagN" ] }' ) if not isinstance(value, dict): ...
[ "def", "set_tags", "(", "self", ",", "value", ")", ":", "log", "=", "(", "'Sources fields \"tags\" should be a dict in the format '", "'{\"include\": [ \"tag1\", \"tag2\", \"tagN\" ],'", "'\"exclude\": [ \"tag1\", \"tag2\", \"tagN\" ] }'", ")", "if", "not", "isinstance", "(", "...
Setter for tags attribute
[ "Setter", "for", "tags", "attribute" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L100-L120
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasSource.build_api_struct
def build_api_struct(self): """ Calls the clean method of the class and returns the info in a structure that Atlas API is accepting. """ self.clean() r = { "type": self._type, "requested": self._requested, "value": self._value }...
python
def build_api_struct(self): """ Calls the clean method of the class and returns the info in a structure that Atlas API is accepting. """ self.clean() r = { "type": self._type, "requested": self._requested, "value": self._value }...
[ "def", "build_api_struct", "(", "self", ")", ":", "self", ".", "clean", "(", ")", "r", "=", "{", "\"type\"", ":", "self", ".", "_type", ",", "\"requested\"", ":", "self", ".", "_requested", ",", "\"value\"", ":", "self", ".", "_value", "}", "if", "se...
Calls the clean method of the class and returns the info in a structure that Atlas API is accepting.
[ "Calls", "the", "clean", "method", "of", "the", "class", "and", "returns", "the", "info", "in", "a", "structure", "that", "Atlas", "API", "is", "accepting", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L135-L149
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasChangeSource.set_type
def set_type(self, value): """Setter for type attribute""" if self.action == "remove" and value != "probes": log = "Sources field 'type' when action is remove should always be 'probes'." raise MalFormattedSource(log) self._type = value
python
def set_type(self, value): """Setter for type attribute""" if self.action == "remove" and value != "probes": log = "Sources field 'type' when action is remove should always be 'probes'." raise MalFormattedSource(log) self._type = value
[ "def", "set_type", "(", "self", ",", "value", ")", ":", "if", "self", ".", "action", "==", "\"remove\"", "and", "value", "!=", "\"probes\"", ":", "log", "=", "\"Sources field 'type' when action is remove should always be 'probes'.\"", "raise", "MalFormattedSource", "(...
Setter for type attribute
[ "Setter", "for", "type", "attribute" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L173-L178
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasChangeSource.set_tags
def set_tags(self, value): """Setter for tags attribute""" if self.action == "remove": log = ( "Tag-based filtering can only be used when adding " "participant probes for a measurement." ) raise MalFormattedSource(log) super(Atl...
python
def set_tags(self, value): """Setter for tags attribute""" if self.action == "remove": log = ( "Tag-based filtering can only be used when adding " "participant probes for a measurement." ) raise MalFormattedSource(log) super(Atl...
[ "def", "set_tags", "(", "self", ",", "value", ")", ":", "if", "self", ".", "action", "==", "\"remove\"", ":", "log", "=", "(", "\"Tag-based filtering can only be used when adding \"", "\"participant probes for a measurement.\"", ")", "raise", "MalFormattedSource", "(", ...
Setter for tags attribute
[ "Setter", "for", "tags", "attribute" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L188-L196
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasChangeSource.set_action
def set_action(self, value): """Setter for action attribute""" if value not in ("remove", "add"): log = "Sources field 'action' should be 'remove' or 'add'." raise MalFormattedSource(log) self._action = value
python
def set_action(self, value): """Setter for action attribute""" if value not in ("remove", "add"): log = "Sources field 'action' should be 'remove' or 'add'." raise MalFormattedSource(log) self._action = value
[ "def", "set_action", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "(", "\"remove\"", ",", "\"add\"", ")", ":", "log", "=", "\"Sources field 'action' should be 'remove' or 'add'.\"", "raise", "MalFormattedSource", "(", "log", ")", "self", ".",...
Setter for action attribute
[ "Setter", "for", "action", "attribute" ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L206-L211
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/source.py
AtlasChangeSource.clean
def clean(self): """ Cleans/checks user has entered all required attributes. This might save some queries from being sent to server if they are totally wrong. """ if not all([self._type, self._requested, self._value, self._action]): raise MalFormattedSource( ...
python
def clean(self): """ Cleans/checks user has entered all required attributes. This might save some queries from being sent to server if they are totally wrong. """ if not all([self._type, self._requested, self._value, self._action]): raise MalFormattedSource( ...
[ "def", "clean", "(", "self", ")", ":", "if", "not", "all", "(", "[", "self", ".", "_type", ",", "self", ".", "_requested", ",", "self", ".", "_value", ",", "self", ".", "_action", "]", ")", ":", "raise", "MalFormattedSource", "(", "\"<type, requested, ...
Cleans/checks user has entered all required attributes. This might save some queries from being sent to server if they are totally wrong.
[ "Cleans", "/", "checks", "user", "has", "entered", "all", "required", "attributes", ".", "This", "might", "save", "some", "queries", "from", "being", "sent", "to", "server", "if", "they", "are", "totally", "wrong", "." ]
train
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/source.py#L216-L224