_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8900 | InlineQueryResultCachedVoice.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedVoice, self).to_array()
# 'type' and 'id' given by superclass
array['voice_file_id'] = u(self.voice_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = | python | {
"resource": ""
} |
q8901 | InlineQueryResultCachedAudio.from_array | train | def from_array(array):
"""
Deserialize a new InlineQueryResultCachedAudio from a given dictionary.
:return: new InlineQueryResultCachedAudio instance.
:rtype: InlineQueryResultCachedAudio
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup
data = {}
# 'type' is given by class type
data['id'] = u(array.get('id'))
data['audio_file_id'] = u(array.get('audio_file_id'))
data['caption'] = u(array.get('caption')) if array.get('caption') is not None else None
data['parse_mode'] = u(array.get('parse_mode')) if array.get('parse_mode') is not None else None
data['reply_markup'] = | python | {
"resource": ""
} |
q8902 | InputTextMessageContent.to_array | train | def to_array(self):
"""
Serializes this InputTextMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputTextMessageContent, self).to_array()
array['message_text'] = u(self.message_text) # py2: type unicode, py3: type str
if self.parse_mode is not None:
| python | {
"resource": ""
} |
q8903 | InputLocationMessageContent.to_array | train | def to_array(self):
"""
Serializes this InputLocationMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputLocationMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
| python | {
"resource": ""
} |
q8904 | InputLocationMessageContent.from_array | train | def from_array(array):
"""
Deserialize a new InputLocationMessageContent from a given dictionary.
:return: new InputLocationMessageContent instance.
:rtype: InputLocationMessageContent
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
| python | {
"resource": ""
} |
q8905 | InputVenueMessageContent.to_array | train | def to_array(self):
"""
Serializes this InputVenueMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputVenueMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # | python | {
"resource": ""
} |
q8906 | InputVenueMessageContent.from_array | train | def from_array(array):
"""
Deserialize a new InputVenueMessageContent from a given dictionary.
:return: new InputVenueMessageContent instance.
:rtype: InputVenueMessageContent
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['latitude'] = float(array.get('latitude'))
data['longitude'] = float(array.get('longitude'))
data['title'] = | python | {
"resource": ""
} |
q8907 | InputContactMessageContent.to_array | train | def to_array(self):
"""
Serializes this InputContactMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputContactMessageContent, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8908 | can_strip_prefix | train | def can_strip_prefix(text:str, prefix:str) -> (bool, str):
"""
If the given text starts with the given prefix, True and the text without that prefix is returned.
Else False and the original text is returned.
Note: the text always is stripped, before returning.
:param text:
:param prefix:
:return: (bool, str) :class:`bool` whether he text | python | {
"resource": ""
} |
q8909 | Function.class_name | train | def class_name(self) -> str:
"""
Makes the fist letter big, keep the rest of the camelCaseApiName.
"""
if not self.api_name: # empty string
| python | {
"resource": ""
} |
q8910 | Function.class_name_teleflask_message | train | def class_name_teleflask_message(self) -> str:
"""
If it starts with `Send` remove that.
"""
# strip leading "Send"
name = self.class_name # "sendPhoto" -> "SendPhoto"
name = name[4:] if name.startswith('Send') else name # "SendPhoto" -> "Photo"
name = name + "Message" # "Photo" -> "PhotoMessage"
# e.g. "MessageMessage" | python | {
"resource": ""
} |
q8911 | Import.full | train | def full(self):
""" self.path + "." + self.name """
if self.path:
if self.name:
return self.path + "." + self.name
else:
return self.path
| python | {
"resource": ""
} |
q8912 | ResponseBot.do | train | def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query):
"""
Return the request params we would send to the api.
"""
url, params = self._prepare_request(command, query)
return {
"url": url, "params": params, "files": files, "stream": use_long_polling,
| python | {
"resource": ""
} |
q8913 | Update.to_array | train | def to_array(self):
"""
Serializes this Update to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Update, self).to_array()
array['update_id'] = int(self.update_id) # type int
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.edited_message is not None:
array['edited_message'] = self.edited_message.to_array() # type Message
if self.channel_post is not None:
array['channel_post'] = self.channel_post.to_array() # type Message
if self.edited_channel_post is not None:
array['edited_channel_post'] = self.edited_channel_post.to_array() # type Message
if self.inline_query is not None:
array['inline_query'] = self.inline_query.to_array() # type InlineQuery
| python | {
"resource": ""
} |
q8914 | WebhookInfo.to_array | train | def to_array(self):
"""
Serializes this WebhookInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(WebhookInfo, self).to_array()
array['url'] = u(self.url) # py2: type unicode, py3: type str
array['has_custom_certificate'] = bool(self.has_custom_certificate) # type bool
array['pending_update_count'] = int(self.pending_update_count) # | python | {
"resource": ""
} |
q8915 | WebhookInfo.from_array | train | def from_array(array):
"""
Deserialize a new WebhookInfo from a given dictionary.
:return: new WebhookInfo instance.
:rtype: WebhookInfo
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['url'] = u(array.get('url'))
data['has_custom_certificate'] = bool(array.get('has_custom_certificate'))
data['pending_update_count'] = int(array.get('pending_update_count'))
data['last_error_date'] = int(array.get('last_error_date')) if array.get('last_error_date') is not None else None
data['last_error_message'] = u(array.get('last_error_message')) | python | {
"resource": ""
} |
q8916 | CallbackQuery.to_array | train | def to_array(self):
"""
Serializes this CallbackQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(CallbackQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['chat_instance'] = u(self.chat_instance) # py2: type unicode, py3: type str
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.inline_message_id is not None:
array['inline_message_id'] = u(self.inline_message_id) # py2: | python | {
"resource": ""
} |
q8917 | CallbackQuery.from_array | train | def from_array(array):
"""
Deserialize a new CallbackQuery from a given dictionary.
:return: new CallbackQuery instance.
:rtype: CallbackQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ..receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['chat_instance'] = u(array.get('chat_instance'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is | python | {
"resource": ""
} |
q8918 | ResponseParameters.to_array | train | def to_array(self):
"""
Serializes this ResponseParameters to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ResponseParameters, self).to_array()
if self.migrate_to_chat_id is not None:
| python | {
"resource": ""
} |
q8919 | ResponseParameters.from_array | train | def from_array(array):
"""
Deserialize a new ResponseParameters from a given dictionary.
:return: new ResponseParameters instance.
:rtype: ResponseParameters
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
| python | {
"resource": ""
} |
q8920 | Xmrs.from_xmrs | train | def from_xmrs(cls, xmrs, **kwargs):
"""
Facilitate conversion among subclasses.
Args:
xmrs (:class:`Xmrs`): instance to convert from; possibly
an instance of a subclass, such as :class:`Mrs` or
:class:`Dmrs`
| python | {
"resource": ""
} |
q8921 | Xmrs.is_connected | train | def is_connected(self):
"""
Return `True` if the Xmrs represents a connected graph.
Subgraphs can be connected through things like arguments,
QEQs, and label equalities.
"""
nids = set(self._nodeids) # the nids left to find
if len(nids) == 0:
raise XmrsError('Cannot compute connectedness of an empty Xmrs.')
# build a basic dict graph of relations
edges = []
# label connections
for lbl in self.labels():
lblset = self.labelset(lbl)
edges.extend((x, y) for x in lblset for y in lblset if x != y)
# argument connections
_vars = self._vars
for nid in nids:
for rarg, tgt in self.args(nid).items():
if tgt not in _vars:
continue
if IVARG_ROLE in _vars[tgt]['refs']:
tgtnids = list(_vars[tgt]['refs'][IVARG_ROLE])
elif tgt in self._hcons:
tgtnids = list(self.labelset(self.hcon(tgt)[2]))
| python | {
"resource": ""
} |
q8922 | Xmrs.validate | train | def validate(self):
"""
Check that the Xmrs is well-formed.
The Xmrs is analyzed and a list of problems is compiled. If
any problems exist, an :exc:`XmrsError` is raised with the list
joined as the error message. A well-formed Xmrs has the
following properties:
* All predications have an intrinsic variable
* Every intrinsic variable belongs one predication and maybe
one quantifier
* Every predication has no more than one quantifier
* All predications have a label
* The graph of predications form a net (i.e. are connected).
Connectivity can be established with variable arguments,
QEQs, or label-equality.
* The lo-handle for each QEQ must exist as the label of a
predication
"""
errors = []
ivs, bvs = {}, {}
_vars = self._vars
_hcons = self._hcons
labels = defaultdict(set)
# ep_args = {}
for ep in self.eps():
nid, lbl, args, is_q = (
ep.nodeid, ep.label, ep.args, ep.is_quantifier()
)
if lbl is None:
errors.append('EP ({}) is missing a label.'.format(nid))
labels[lbl].add(nid)
iv = args.get(IVARG_ROLE)
if iv is None:
errors.append('EP {nid} is missing an intrinsic variable.'
.format(nid))
if is_q:
if iv in bvs:
errors.append('{} is the bound variable for more than '
| python | {
"resource": ""
} |
q8923 | Mrs.to_dict | train | def to_dict(self, short_pred=True, properties=True):
"""
Encode the Mrs as a dictionary suitable for JSON serialization.
"""
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _ep(ep, short_pred=True):
p = ep.pred.short_form() if short_pred else ep.pred.string
d = dict(label=ep.label, predicate=p, arguments=ep.args)
if ep.lnk is not None: d['lnk'] = _lnk(ep)
return d
def _hcons(hc): return {'relation':hc[1], 'high':hc[0], 'low':hc[2]}
def _icons(ic): return {'relation':ic[1], 'left':ic[0], 'right':ic[2]}
def _var(v):
d = {'type': var_sort(v)}
if properties and self.properties(v):
d['properties'] = self.properties(v)
return d
d = dict(
relations=[_ep(ep, short_pred=short_pred) for ep in self.eps()],
constraints=([_hcons(hc) for hc in self.hcons()] +
| python | {
"resource": ""
} |
q8924 | Dmrs.to_dict | train | def to_dict(self, short_pred=True, properties=True):
"""
Encode the Dmrs as a dictionary suitable for JSON serialization.
"""
qs = set(self.nodeids(quantifier=True))
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _node(node, short_pred=True):
p = node.pred.short_form() if short_pred else node.pred.string
d = dict(nodeid=node.nodeid, predicate=p)
if node.lnk is not None: d['lnk'] = _lnk(node)
if properties and node.sortinfo:
if node.nodeid not in qs:
d['sortinfo'] = node.sortinfo
if node.surface is not None: d['surface'] = node.surface
if node.base is not None: d['base'] = node.base
if node.carg is not None: d['carg'] = node.carg
return d
def _link(link): return {
'from': link.start, 'to': link.end,
'rargname': link.rargname, 'post': link.post
}
d = dict(
nodes=[_node(n) for n in nodes(self)],
| python | {
"resource": ""
} |
q8925 | Dmrs.to_triples | train | def to_triples(self, short_pred=True, properties=True):
"""
Encode the Dmrs as triples suitable for PENMAN serialization.
"""
ts = []
qs = set(self.nodeids(quantifier=True))
for n in nodes(self):
pred = n.pred.short_form() if short_pred else n.pred.string
ts.append((n.nodeid, 'predicate', pred))
if n.lnk is not None:
ts.append((n.nodeid, 'lnk', '"{}"'.format(str(n.lnk))))
if n.carg is not None:
ts.append((n.nodeid, 'carg', '"{}"'.format(n.carg)))
if properties and n.nodeid not in qs:
| python | {
"resource": ""
} |
q8926 | Invoice.to_array | train | def to_array(self):
"""
Serializes this Invoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Invoice, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['start_parameter'] | python | {
"resource": ""
} |
q8927 | ShippingAddress.to_array | train | def to_array(self):
"""
Serializes this ShippingAddress to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ShippingAddress, self).to_array()
array['country_code'] = u(self.country_code) # py2: type unicode, py3: type str
array['state'] = u(self.state) # py2: type unicode, py3: type str
array['city'] = u(self.city) # | python | {
"resource": ""
} |
q8928 | OrderInfo.to_array | train | def to_array(self):
"""
Serializes this OrderInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(OrderInfo, self).to_array()
if self.name is not None:
array['name'] = u(self.name) # py2: type | python | {
"resource": ""
} |
q8929 | SuccessfulPayment.to_array | train | def to_array(self):
"""
Serializes this SuccessfulPayment to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(SuccessfulPayment, self).to_array()
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
array['telegram_payment_charge_id'] = u(self.telegram_payment_charge_id) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8930 | SuccessfulPayment.from_array | train | def from_array(array):
"""
Deserialize a new SuccessfulPayment from a given dictionary.
:return: new SuccessfulPayment instance.
:rtype: SuccessfulPayment
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['currency'] = u(array.get('currency'))
data['total_amount'] = int(array.get('total_amount'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['telegram_payment_charge_id'] = u(array.get('telegram_payment_charge_id'))
| python | {
"resource": ""
} |
q8931 | ShippingQuery.to_array | train | def to_array(self):
"""
Serializes this ShippingQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ShippingQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
| python | {
"resource": ""
} |
q8932 | ShippingQuery.from_array | train | def from_array(array):
"""
Deserialize a new ShippingQuery from a given dictionary.
:return: new ShippingQuery instance.
:rtype: ShippingQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = | python | {
"resource": ""
} |
q8933 | PreCheckoutQuery.to_array | train | def to_array(self):
"""
Serializes this PreCheckoutQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PreCheckoutQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
| python | {
"resource": ""
} |
q8934 | PreCheckoutQuery.from_array | train | def from_array(array):
"""
Deserialize a new PreCheckoutQuery from a given dictionary.
:return: new PreCheckoutQuery instance.
:rtype: PreCheckoutQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
| python | {
"resource": ""
} |
q8935 | InputMediaPhoto.to_array | train | def to_array(self):
"""
Serializes this InputMediaPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputMediaPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['media'] = u(self.media) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8936 | dump | train | def dump(destination, ms, single=False, pretty_print=False, **kwargs):
"""
Serialize Xmrs objects to the Prolog representation and write to a file.
Args:
destination: filename or file object where data will be written
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
pretty_print: if `True`, add newlines and indentation
"""
text = dumps(ms,
| python | {
"resource": ""
} |
q8937 | dumps | train | def dumps(ms, single=False, pretty_print=False, **kwargs):
"""
Serialize an Xmrs object to the Prolog 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 | python | {
"resource": ""
} |
q8938 | convert | train | def convert(path, source_fmt, target_fmt, select='result:mrs',
properties=True, show_status=False, predicate_modifiers=False,
color=False, pretty_print=False, indent=None):
"""
Convert between various DELPH-IN Semantics representations.
Args:
path (str, file): filename, testsuite directory, open file, or
stream of input representations
source_fmt (str): convert from this format
target_fmt (str): convert to this format
select (str): TSQL query for selecting data (ignored if *path*
is not a testsuite directory; default: `"result:mrs"`)
properties (bool): include morphosemantic properties if `True`
(default: `True`)
show_status (bool): show disconnected EDS nodes (ignored if
*target_fmt* is not `"eds"`; default: `False`)
predicate_modifiers (bool): apply EDS predicate modification
for certain kinds of patterns (ignored if *target_fmt* is
not an EDS format; default: `False`)
color (bool): apply syntax highlighting if `True` and
*target_fmt* is `"simplemrs"` (default: `False`)
pretty_print (bool): if `True`, format the output with
newlines and default indentation (default: `False`)
indent (int, optional): specifies an explicit number of spaces
for indentation (implies *pretty_print*)
Returns:
str: the converted representation
"""
if source_fmt.startswith('eds') and not target_fmt.startswith('eds'):
raise ValueError(
'Conversion from EDS to non-EDS currently not supported.')
if indent:
pretty_print = True
indent = 4 if indent is True else safe_int(indent)
if len(tsql.inspect_query('select ' + select)['projection']) != 1:
raise ValueError('Exactly 1 column must be given in selection query: '
'(e.g., result:mrs)')
# read
loads = _get_codec(source_fmt)
if path is None:
xs = loads(sys.stdin.read())
elif hasattr(path, 'read'):
xs = loads(path.read())
elif os.path.isdir(path):
ts = itsdb.TestSuite(path)
xs = [
next(iter(loads(r[0])), None)
for r in tsql.select(select, ts)
]
else:
xs = loads(open(path, 'r').read())
# write
dumps = _get_codec(target_fmt, load=False)
kwargs = {}
if color: kwargs['color'] = color
if pretty_print: kwargs['pretty_print'] = pretty_print
| python | {
"resource": ""
} |
q8939 | non_argument_modifiers | train | def non_argument_modifiers(role='ARG1', only_connecting=True):
"""
Return a function that finds non-argument modifier dependencies.
Args:
role (str): the role that is assigned to the dependency
only_connecting (bool): if `True`, only return dependencies
that connect separate components in the basic dependencies;
if `False`, all non-argument modifier dependencies are
included
Returns:
a function with signature `func(xmrs, deps)` that returns a
mapping of non-argument modifier dependencies
Examples:
The default function behaves like the LKB:
>>> func = non_argument_modifiers()
A variation is similar to DMRS's MOD/EQ links:
>>> func = non_argument_modifiers(role="MOD", only_connecting=False)
"""
def func(xmrs, deps):
edges = []
for src in deps:
for _, tgt in deps[src]:
edges.append((src, tgt))
components = _connected_components(xmrs.nodeids(), edges)
ccmap = {}
for i, component in enumerate(components):
for n in component:
ccmap[n] = i
| python | {
"resource": ""
} |
q8940 | dumps | train | def dumps(ms, single=False,
properties=False, pretty_print=True,
show_status=False, predicate_modifiers=False, **kwargs):
"""
Serialize an Xmrs object to a Eds representation
Args:
ms: an iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to
serialize (unless the *single* option is `True`)
single (bool): if `True`, treat *ms* as a single
:class:`~delphin.mrs.xmrs.Xmrs` object instead of as an
iterator
properties (bool): if `False`, suppress variable properties
pretty_print (bool): if `True`, add newlines and indentation
show_status (bool): if `True`, annotate disconnected graphs and
| python | {
"resource": ""
} |
q8941 | Eds.nodes | train | def nodes(self):
"""Return the list of nodes."""
getnode = self._nodes.__getitem__
| python | {
"resource": ""
} |
q8942 | Eds.to_dict | train | def to_dict(self, properties=True):
"""
Encode the Eds as a dictionary suitable for JSON serialization.
"""
nodes = {}
for node in self.nodes():
nd = {
'label': node.pred.short_form(),
'edges': self.edges(node.nodeid)
}
if node.lnk is not None:
nd['lnk'] = {'from': node.cfrom, 'to': node.cto}
if properties:
if node.cvarsort is not None:
| python | {
"resource": ""
} |
q8943 | Eds.to_triples | train | def to_triples(self, short_pred=True, properties=True):
"""
Encode the Eds as triples suitable for PENMAN serialization.
"""
node_triples, edge_triples = [], []
# sort nodeids just so top var is first
nodes = sorted(self.nodes(), key=lambda n: n.nodeid != self.top)
for node in nodes:
nid = node.nodeid
pred = node.pred.short_form() if short_pred else node.pred.string
node_triples.append((nid, 'predicate', pred))
| python | {
"resource": ""
} |
q8944 | LookaheadIterator.next | train | def next(self, skip=None):
"""
Remove the next datum from the buffer and return it.
"""
buffer = self._buffer
popleft = buffer.popleft
if skip is not None:
while True:
try:
if not skip(buffer[0]):
break
| python | {
"resource": ""
} |
q8945 | InlineQueryResultPhoto.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_url'] = u(self.photo_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.photo_width is not None:
array['photo_width'] = int(self.photo_width) # type int
| python | {
"resource": ""
} |
q8946 | InlineQueryResultMpeg4Gif.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_url'] = u(self.mpeg4_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.mpeg4_width is not None:
array['mpeg4_width'] = int(self.mpeg4_width) # type int
| python | {
"resource": ""
} |
q8947 | InlineQueryResultVideo.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_url'] = u(self.video_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.video_width is not None:
array['video_width'] = int(self.video_width) # type int
if self.video_height is not None:
array['video_height'] = int(self.video_height) # type int
| python | {
"resource": ""
} |
q8948 | InlineQueryResultVoice.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVoice, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['voice_url'] = u(self.voice_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
| python | {
"resource": ""
} |
q8949 | InlineQueryResultDocument.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultDocument to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultDocument, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['document_url'] = u(self.document_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.caption is not None:
| python | {
"resource": ""
} |
q8950 | InlineQueryResultVenue.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultVenue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVenue, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: | python | {
"resource": ""
} |
q8951 | InlineQueryResultCachedPhoto.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_file_id'] = u(self.photo_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is | python | {
"resource": ""
} |
q8952 | InlineQueryResultCachedMpeg4Gif.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_file_id'] = u(self.mpeg4_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # | python | {
"resource": ""
} |
q8953 | InlineQueryResultCachedSticker.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedSticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedSticker, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8954 | InlineQueryResultCachedVideo.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_file_id'] = u(self.video_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
| python | {
"resource": ""
} |
q8955 | InlineQueryResultCachedAudio.to_array | train | def to_array(self):
"""
Serializes this InlineQueryResultCachedAudio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedAudio, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['audio_file_id'] = u(self.audio_file_id) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
| python | {
"resource": ""
} |
q8956 | MessageEntity.to_array | train | def to_array(self):
"""
Serializes this MessageEntity to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(MessageEntity, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['offset'] = int(self.offset) # type int
array['length'] = int(self.length) | python | {
"resource": ""
} |
q8957 | PhotoSize.to_array | train | def to_array(self):
"""
Serializes this PhotoSize to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PhotoSize, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
| python | {
"resource": ""
} |
q8958 | Audio.to_array | train | def to_array(self):
"""
Serializes this Audio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Audio, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.performer is not None:
array['performer'] = u(self.performer) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if | python | {
"resource": ""
} |
q8959 | Audio.from_array | train | def from_array(array):
"""
Deserialize a new Audio from a given dictionary.
:return: new Audio instance.
:rtype: Audio
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.media import PhotoSize
data = {}
data['file_id'] = u(array.get('file_id'))
data['duration'] = int(array.get('duration'))
data['performer'] = u(array.get('performer')) if array.get('performer') is not None else None
| python | {
"resource": ""
} |
q8960 | Document.to_array | train | def to_array(self):
"""
Serializes this Document to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Document, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.thumb is not None: | python | {
"resource": ""
} |
q8961 | Animation.to_array | train | def to_array(self):
"""
Serializes this Animation to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Animation, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
array['duration'] = int(self.duration) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_name is not None:
| python | {
"resource": ""
} |
q8962 | Voice.to_array | train | def to_array(self):
"""
Serializes this Voice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Voice, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.mime_type is | python | {
"resource": ""
} |
q8963 | VideoNote.to_array | train | def to_array(self):
"""
Serializes this VideoNote to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(VideoNote, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['length'] = int(self.length) # type int
array['duration'] = int(self.duration) | python | {
"resource": ""
} |
q8964 | Contact.to_array | train | def to_array(self):
"""
Serializes this Contact to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Contact, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8965 | Location.to_array | train | def to_array(self):
"""
Serializes this Location to a dictionary.
:return: dictionary representation of this object.
:rtype: | python | {
"resource": ""
} |
q8966 | Location.from_array | train | def from_array(array):
"""
Deserialize a new Location from a given dictionary.
:return: new Location instance.
:rtype: Location
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, | python | {
"resource": ""
} |
q8967 | Venue.to_array | train | def to_array(self):
"""
Serializes this Venue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Venue, self).to_array()
array['location'] = self.location.to_array() # type Location
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8968 | UserProfilePhotos.to_array | train | def to_array(self):
"""
Serializes this UserProfilePhotos to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
| python | {
"resource": ""
} |
q8969 | File.to_array | train | def to_array(self):
"""
Serializes this File to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(File, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.file_size is not None:
| python | {
"resource": ""
} |
q8970 | ChatPhoto.to_array | train | def to_array(self):
"""
Serializes this ChatPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ChatPhoto, self).to_array()
| python | {
"resource": ""
} |
q8971 | Sticker.to_array | train | def to_array(self):
"""
Serializes this Sticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Sticker, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.emoji is not None:
array['emoji'] = u(self.emoji) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8972 | Game.to_array | train | def to_array(self):
"""
Serializes this Game to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Game, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['photo'] = self._as_array(self.photo) # type list of PhotoSize
if self.text is not None:
array['text'] = u(self.text) # py2: type unicode, py3: type str
if | python | {
"resource": ""
} |
q8973 | VideoNote.from_array | train | def from_array(array):
"""
Deserialize a new VideoNote from a given dictionary.
:return: new VideoNote instance.
:rtype: VideoNote
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['file_id'] = u(array.get('file_id'))
data['length'] = int(array.get('length'))
| python | {
"resource": ""
} |
q8974 | ReplyKeyboardMarkup.to_array | train | def to_array(self):
"""
Serializes this ReplyKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ReplyKeyboardMarkup, self).to_array()
array['keyboard'] = self._as_array(self.keyboard) # type list of list of KeyboardButton
if self.resize_keyboard is not None:
array['resize_keyboard'] = | python | {
"resource": ""
} |
q8975 | KeyboardButton.to_array | train | def to_array(self):
"""
Serializes this KeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(KeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.request_contact is not None:
| python | {
"resource": ""
} |
q8976 | KeyboardButton.from_array | train | def from_array(array):
"""
Deserialize a new KeyboardButton from a given dictionary.
:return: new KeyboardButton instance.
:rtype: KeyboardButton
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['text'] = u(array.get('text'))
data['request_contact'] = bool(array.get('request_contact')) | python | {
"resource": ""
} |
q8977 | ReplyKeyboardRemove.to_array | train | def to_array(self):
"""
Serializes this ReplyKeyboardRemove to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ReplyKeyboardRemove, self).to_array()
| python | {
"resource": ""
} |
q8978 | InlineKeyboardMarkup.to_array | train | def to_array(self):
"""
Serializes this InlineKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineKeyboardMarkup, self).to_array()
| python | {
"resource": ""
} |
q8979 | InlineKeyboardButton.to_array | train | def to_array(self):
"""
Serializes this InlineKeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineKeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.url is not None:
array['url'] = u(self.url) # py2: type unicode, py3: type str
if self.callback_data is not None:
array['callback_data'] = u(self.callback_data) # py2: type unicode, py3: type str
if self.switch_inline_query is not None:
array['switch_inline_query'] = u(self.switch_inline_query) # py2: type unicode, py3: type str
if self.switch_inline_query_current_chat is | python | {
"resource": ""
} |
q8980 | InlineKeyboardButton.from_array | train | def from_array(array):
"""
Deserialize a new InlineKeyboardButton from a given dictionary.
:return: new InlineKeyboardButton instance.
:rtype: InlineKeyboardButton
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.updates import CallbackGame
data = {}
data['text'] = u(array.get('text'))
data['url'] = u(array.get('url')) if array.get('url') is not None else None
data['callback_data'] = u(array.get('callback_data')) if array.get('callback_data') is not None else None
data['switch_inline_query'] = u(array.get('switch_inline_query')) | python | {
"resource": ""
} |
q8981 | ForceReply.to_array | train | def to_array(self):
"""
Serializes this ForceReply to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
| python | {
"resource": ""
} |
q8982 | ForceReply.from_array | train | def from_array(array):
"""
Deserialize a new ForceReply from a given dictionary.
:return: new ForceReply instance.
:rtype: ForceReply
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
| python | {
"resource": ""
} |
q8983 | PassportElementErrorDataField.to_array | train | def to_array(self):
"""
Serializes this PassportElementErrorDataField to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorDataField, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
| python | {
"resource": ""
} |
q8984 | PassportElementErrorReverseSide.to_array | train | def to_array(self):
"""
Serializes this PassportElementErrorReverseSide to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorReverseSide, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, | python | {
"resource": ""
} |
q8985 | PassportElementErrorFiles.to_array | train | def to_array(self):
"""
Serializes this PassportElementErrorFiles to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorFiles, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, | python | {
"resource": ""
} |
q8986 | PassportElementErrorFiles.from_array | train | def from_array(array):
"""
Deserialize a new PassportElementErrorFiles from a given dictionary.
:return: new PassportElementErrorFiles instance.
:rtype: PassportElementErrorFiles
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['source'] = u(array.get('source'))
data['type'] = u(array.get('type')) | python | {
"resource": ""
} |
q8987 | PassportElementErrorUnspecified.to_array | train | def to_array(self):
"""
Serializes this PassportElementErrorUnspecified to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorUnspecified, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type | python | {
"resource": ""
} |
q8988 | PassportElementErrorUnspecified.from_array | train | def from_array(array):
"""
Deserialize a new PassportElementErrorUnspecified from a given dictionary.
:return: new PassportElementErrorUnspecified instance.
:rtype: PassportElementErrorUnspecified
"""
if array is None or not array:
| python | {
"resource": ""
} |
q8989 | InlineQuery.to_array | train | 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'] = self.from_peer.to_array() # type User
array['query'] = u(self.query) # | python | {
"resource": ""
} |
q8990 | InlineQuery.from_array | train | 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="array")
from pytgbot.api_types.receivable.media import Location
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] | python | {
"resource": ""
} |
q8991 | ChosenInlineResult.to_array | train | 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: type | python | {
"resource": ""
} |
q8992 | ChosenInlineResult.from_array | train | 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, dict, parameter_name="array")
from ..receivable.media import Location
| python | {
"resource": ""
} |
q8993 | Update.from_array | train | 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")
from pytgbot.api_types.receivable.inline import ChosenInlineResult
from pytgbot.api_types.receivable.inline import InlineQuery
from pytgbot.api_types.receivable.payments import PreCheckoutQuery
from pytgbot.api_types.receivable.payments import ShippingQuery
from pytgbot.api_types.receivable.updates import CallbackQuery
from pytgbot.api_types.receivable.updates import Message
data = {}
data['update_id'] = int(array.get('update_id'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is not None else None
data['edited_message'] = Message.from_array(array.get('edited_message')) if array.get('edited_message') is not None else None
data['channel_post'] = Message.from_array(array.get('channel_post')) if array.get('channel_post') is not None else None
data['edited_channel_post'] = Message.from_array(array.get('edited_channel_post')) if array.get('edited_channel_post') is not None else None
data['inline_query'] = InlineQuery.from_array(array.get('inline_query')) if | python | {
"resource": ""
} |
q8994 | YyToken.to_dict | train | 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 = self.lnk.data
d['from'] = cfrom
d['to'] = cto
# d['paths'] = self.paths
if self.surface is not None:
| python | {
"resource": ""
} |
q8995 | YyTokenLattice.from_string | train | 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, []
if d['lnkfrom'] is not None:
lnk = Lnk.charspan(d['lnkfrom'], d['lnkto'])
if d['pos'] is not None:
ps = d['pos'].strip().split()
pos = list(zip(map(_qstrip, ps[::2]), map(float, ps[1::2])))
tokens.append(
YyToken(
int(d['id']),
int(d['start']),
int(d['end']),
| python | {
"resource": ""
} |
q8996 | loads | train | 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 | python | {
"resource": ""
} |
q8997 | dumps | train | 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`)
single: if `True`, treat *ms* as a single Xmrs object instead
of as an iterator
properties: if `False`, suppress variable properties
pretty_print: if `True`, add newlines and indentation
color: if `True`, colorize the output with ANSI color codes
Returns:
| python | {
"resource": ""
} |
q8998 | _read_lnk | train | 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] == '>':
pass # empty <> brackets the same as no lnk specified
# edge lnk: ['@', EDGE, ...]
elif tokens[0] == '@':
tokens.popleft() # remove the @
lnk = Lnk.edge(tokens.popleft()) # edge lnks only have one number | python | {
"resource": ""
} |
q8999 | serialize | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.