def summarize(self): summary = { 'stmt_types': [statement_base_verb(v) for v in self.get_stmt_types()], 'query_subj': self.query.subj, 'query_obj': self.query.obj } return summary
def summarize(self): if self.query.stmt_type: stmt_type = statement_base_verb(self.query.stmt_type.lower()) else: stmt_type = None summary = {'stmt_type': stmt_type, 'query_subj': self.query.subj, 'other_agents': self.get_other_agents([self.query.subj], other_role='object')} return summary
def to_english(self): agent = _assemble_agent_str(self.entity).agent_str if self.entity_role == 'subject': verb = statement_base_verb(self.stmt_type.lower()) verb = verb[0].lower() + verb[1:] sentence = f'What does {agent} {verb}?' elif self.entity_role == 'object': verb = statement_present_verb(self.stmt_type.lower()) verb = verb[0].lower() + verb[1:] sentence = f'What {verb} {agent}?' sentence = sentence[0].upper() + sentence[1:] if self.terminal_ns: sentence += f' ({", ".join(self.terminal_ns).upper()})' return sentence
def _build_verb_map(): # We first get all statement types stmts = get_all_descendants(Statement) verb_map = {} # These are statement types that aren't binary and therefore don't need # to be included in the verb map non_binary = ('hasactivity', 'activeform', 'selfmodification', 'autophosphorylation', 'transphosphorylation', 'event', 'unresolved', 'association', 'complex') for stmt in stmts: # Get the class name name = stmt.__name__ if name.lower() in non_binary: continue # Get the base verb form of the statement, e.g., "phosphorylate" base_verb = statement_base_verb(name.lower()) verb_map[base_verb] = {'stmt': name, 'type': 'base'} # Get the present form of the statement, e.g., "inhibits" present_verb = statement_present_verb(name.lower()) verb_map[present_verb] = {'stmt': name, 'type': 'present'} # Get the passive / state form of the statement, e.g., "activated" passive_verb = statement_passive_verb(name.lower()) verb_map[passive_verb] = {'stmt': name, 'type': 'passive'} return verb_map
def test_get_base_verb(): assert ea.statement_base_verb('inhibition') == 'inhibit' assert ea.statement_base_verb('dephosphorylation') == 'dephosphorylate' assert ea.statement_base_verb('complex') == 'bind'