本文整理汇总了Python中kqml.KQMLList.sets方法的典型用法代码示例。如果您正苦于以下问题:Python KQMLList.sets方法的具体用法?Python KQMLList.sets怎么用?Python KQMLList.sets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kqml.KQMLList
的用法示例。
在下文中一共展示了KQMLList.sets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_display_figure
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def send_display_figure(self, path):
msg = KQMLPerformative('tell')
content = KQMLList('display-image')
content.set('type', 'simulation')
content.sets('path', path)
msg.set('content', content)
self.send(msg)
示例2: make_failure
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def make_failure(self, reason=None, description=None):
msg = KQMLList('FAILURE')
if reason:
msg.set('reason', reason)
if description:
msg.sets('description', description)
return msg
示例3: test_respond_choose_nonsense
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def test_respond_choose_nonsense():
bs = BioSense_Module(testing=True)
msg_content = KQMLList('CHOOSE-SENSE')
msg_content.sets('ekb-term', ekb_from_text('bagel'))
res = bs.respond_choose_sense(msg_content)
print(res)
assert res.head() == 'SUCCESS'
assert res.get('agents')[0].gets('ont-type') is None
示例4: _get_perf
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def _get_perf(text, msg_id):
"""Return a request message for a given text."""
msg = KQMLPerformative('REQUEST')
msg.set('receiver', 'READER')
content = KQMLList('run-text')
content.sets('text', text)
msg.set('content', content)
msg.set('reply-with', msg_id)
return msg
示例5: send_null_provenance
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def send_null_provenance(self, stmt, for_what, reason=''):
"""Send out that no provenance could be found for a given Statement."""
content_fmt = ('<h4>No supporting evidence found for {statement} from '
'{cause}{reason}.</h4>')
content = KQMLList('add-provenance')
stmt_txt = EnglishAssembler([stmt]).make_model()
content.sets('html', content_fmt.format(statement=stmt_txt,
cause=for_what, reason=reason))
return self.tell(content)
示例6: _get_drug_kqml
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def _get_drug_kqml(drug_list):
drugs = KQMLList()
for dn, pci in drug_list:
drug = KQMLList()
drug.sets('name', dn.replace(' ', '-'))
if pci:
drug.sets('pubchem_id', pci)
drugs.append(drug)
return drugs
示例7: test_respond_get_synonyms
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def test_respond_get_synonyms():
bs = BioSense_Module(testing=True)
msg_content = KQMLList('GET-SYNONYMS')
msg_content.sets('entity', mek1_ekb)
res = bs.respond_get_synonyms(msg_content)
assert res.head() == 'SUCCESS'
syns = res.get('synonyms')
syn_strs = [s.gets(':name') for s in syns]
assert 'MAP2K1' in syn_strs
assert 'MEK1' in syn_strs
assert 'MKK1' in syn_strs
示例8: test_respond_choose_sense_is_member
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def test_respond_choose_sense_is_member():
bs = BioSense_Module(testing=True)
msg_content = KQMLList('CHOOSE-SENSE-IS-MEMBER')
msg_content.sets('ekb-term', mek1_ekb)
msg_content.sets('collection', mek_ekb)
print(msg_content)
res = bs.respond_choose_sense_is_member(msg_content)
print(res)
print(res.head())
assert(res.head() == 'SUCCESS')
assert(res.get('is-member') == 'TRUE')
示例9: report_paths_graph
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def report_paths_graph(self, paths_list):
from indra.assemblers.graph import GraphAssembler
from indra.util import flatten
path_stmts = [stmts_from_json(l) for l in paths_list]
all_stmts = flatten(path_stmts)
ga = GraphAssembler(all_stmts)
ga.make_model()
resource = get_img_path('qca_paths.png')
ga.save_pdf(resource)
content = KQMLList('display-image')
content.set('type', 'simulation')
content.sets('path', resource)
self.tell(content)
示例10: test_respond_choose_sense
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def test_respond_choose_sense():
bs = BioSense_Module(testing=True)
msg_content = KQMLList('CHOOSE-SENSE')
msg_content.sets('ekb-term', mek1_ekb)
res = bs.respond_choose_sense(msg_content)
print(res)
agents = res.get('agents')
assert agents and agents.data
agent = agents[0]
name = agent.gets('name')
assert name == 'MAP2K1'
ont_type = agent.get('ont-type')
assert ont_type == 'ONT::GENE'
示例11: send_display_model
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def send_display_model(self, diagrams):
for diagram_type, resource in diagrams.items():
if not resource:
continue
if diagram_type == 'sbgn':
content = KQMLList('display-sbgn')
content.set('type', diagram_type)
content.sets('graph', resource)
else:
content = KQMLList('display-image')
content.set('type', diagram_type)
content.sets('path', resource)
self.tell(content)
示例12: respond_describe_model
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def respond_describe_model(self, content):
"""Convert the model to natural language."""
# Get the model.
model_id = self._get_model_id(content)
model = self.mra.get_model_by_id(model_id)
# Turn the model into a text description.
english_assembler = EnglishAssembler(model)
desc = english_assembler.make_model()
# Respond to the BA.
resp = KQMLList('SUCCESS')
resp.sets('description', desc)
return resp
示例13: respond_model_get_json
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def respond_model_get_json(self, content):
"""Return response content to model-get-json request."""
try:
model_id = self._get_model_id(content)
except Exception:
model_id = None
model = self.mra.get_model_by_id(model_id)
if model is not None:
model_msg = encode_indra_stmts(model)
reply = KQMLList('SUCCESS')
reply.sets('model', model_msg)
else:
reply = self.make_failure('MISSING_MODEL')
return reply
示例14: get_ambiguities_msg
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def get_ambiguities_msg(ambiguities):
sa = []
for term_id, ambiguity in ambiguities.items():
msg = KQMLList(term_id)
pr = ambiguity[0]['preferred']
pr_dbids = '|'.join([':'.join((k, v)) for
k, v in pr['refs'].items()])
term = KQMLList('term')
term.set('ont-type', pr['type'])
term.sets('ids', pr_dbids)
term.sets('name', pr['name'])
msg.set('preferred', term)
alt = ambiguity[0]['alternative']
alt_dbids = '|'.join([':'.join((k, v)) for
k, v in alt['refs'].items()])
term = KQMLList('term')
term.set('ont-type', alt['type'])
term.sets('ids', alt_dbids)
term.sets('name', alt['name'])
msg.set('alternative', term)
sa.append(msg)
ambiguities_msg = KQMLList(sa)
return ambiguities_msg
示例15: test_respond_choose_sense_what_member
# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import sets [as 别名]
def test_respond_choose_sense_what_member():
bs = BioSense_Module(testing=True)
msg_content = KQMLList('CHOOSE-SENSE-WHAT-MEMBER')
msg_content.sets('collection', mek_ekb)
print(msg_content)
res = bs.respond_choose_sense_what_member(msg_content)
print(res)
print(res.head())
assert(res.head() == 'SUCCESS')
assert(len(res.get('members')) == 2)
m1 = res.get('members')[0]
m2 = res.get('members')[1]
assert m1.gets('name') == 'MAP2K1', m1.gets('name')
assert m2.gets('name') == 'MAP2K2', m2.gets('name')