Natural language (indra.assemblers.english.assembler)¶
-
class
indra.assemblers.english.assembler.AgentWithCoordinates(agent_str, name, db_refs, coords=None)[source]¶ English representation of an agent.
Parameters: - agent_str (str) – Full English description of an agent.
- name (str) – Name of an agent.
- db_refs (dict) – Dictionary of database identifiers associated with this agent.
- coords (tuple(int)) – A tuple of integers representing coordinates of agent name in a text. If not provided, coords will be set to coordinates of name in agent_str. When AgentWithCoordinates is a part of SentenceBuilder or EnglishAssembler, the coords represent the location of agent name in the SentenceBuilder.sentence or EnglishAssembler.model.
-
class
indra.assemblers.english.assembler.EnglishAssembler(stmts=None)[source]¶ This assembler generates English sentences from INDRA Statements.
Parameters: stmts (Optional[list[indra.statements.Statement]]) – A list of INDRA Statements to be added to the assembler. -
statements¶ A list of INDRA Statements to assemble.
Type: list[indra.statements.Statement]
-
model¶ The assembled sentences as a single string.
Type: str
-
stmt_agents¶ A list containing lists of AgentWithCoordinates objects for each of the assembled statements. Coordinates represent the location of agents in the model.
Type: list[list[AgentWithCoordinates]]
-
-
class
indra.assemblers.english.assembler.SentenceBuilder[source]¶ Builds a sentence from agents and strings.
-
agents¶ A list of AgentWithCoordinates objects that are part of a sentence. The coordinates of the agent name are being dynamically updated as the sentence is being constructed.
Type: list[AgentWithCoordinates]
-
sentence¶ A sentence that is being built by the builder.
Type: str
-
append(element)[source]¶ Append an element to the end of the sentence.
Parameters: element (str or AgentWithCoordinates) – A string or AgentWithCoordinates object to be appended in the end of the sentence. Agent’s name coordinates are updated relative to the current length of the sentence.
-
append_as_list(lst, oxford=True)[source]¶ Append a list of elements in a gramatically correct way.
Parameters: - lst (list[str] or list[AgentWithCoordinates]) – A list of elements to append. Elements in this list represent a sequence and grammar standards require the use of appropriate punctuation and conjunction to connect them (e.g. [ag1, ag2, ag3]).
- oxford (Optional[bool]) – Whether to use oxford grammar standards. Default: True
-
append_as_sentence(lst)[source]¶ Append a list of elements by concatenating them together.
Note: a list of elements here are parts of sentence that do not represent a sequence and do not need to have extra punctuation or conjunction between them.
Parameters: lst (list[str] or list[AgentWithCoordinates]) – A list of elements to append. Elements in this list do not represent a sequence and do not need to have extra punctuation or conjunction between them (e.g. [subj, ‘ is a GAP for ‘, obj]).
-
prepend(element)[source]¶ Prepend an element to the beginning of the sentence.
Parameters: element (str or AgentWithCoordinates) – A string or AgentWithCoordinates object to be added in the beginning of the sentence. All existing agents’ names coordinates are updated relative to the new length of the sentence.
-
-
indra.assemblers.english.assembler.english_join(lst)[source]¶ Join a list of strings according to English grammar.
Parameters: lst (list of str) – A list of strings to join. Returns: A string which describes the list of elements, e.g., “apples, pears, and bananas”. Return type: str
-
indra.assemblers.english.assembler.statement_base_verb(stmt_type)[source]¶ Return the base verb form of a statement type.
Parameters: stmt_type (str) – The lower case string form of a statement type, for instance, ‘phosphorylation’. Returns: The base verb form of a statement type, for instance, ‘phosphorylate’. Return type: str
-
indra.assemblers.english.assembler.statement_passive_verb(stmt_type)[source]¶ Return the passive / state verb form of a statement type.
Parameters: stmt_type (str) – The lower case string form of a statement type, for instance, ‘phosphorylation’. Returns: The passive/state verb form of a statement type, for instance, ‘phosphorylated’. Return type: str
-
indra.assemblers.english.assembler.statement_present_verb(stmt_type)[source]¶ Return the present verb form of a statement type.
Parameters: stmt_type (str) – The lower case string form of a statement type, for instance, ‘phosphorylation’. Returns: The present verb form of a statement type, for instance, ‘phosphorylates’. Return type: str