API#

malaya_graph#

malaya_graph.text_to_kg.e2e#

malaya_graph.text_to_kg.e2e.available_huggingface()[source]#

List available huggingface models.

malaya_graph.text_to_kg.e2e.huggingface(model='mesolitica/finetune-ttkg-t5-small-standard-bahasa-cased', **kwargs)[source]#

Load HuggingFace model to End-to-End text to knowledge graph.

Parameters

model (str, optional (default='mesolitica/finetune-ttkg-t5-small-standard-bahasa-cased')) – Check available models at malaya_graph.text_to_kg.e2e.available_huggingface().

Returns

result

Return type

malaya_graph.model.text_to_kg.TexttoKG

malaya_graph.text_to_kg.parser#

malaya_graph.text_to_kg.parser.from_dependency(tagging, indexing, subjects=[['flat', 'subj', 'nsubj', 'csubj']], relations=[['acl', 'xcomp', 'ccomp', 'obj', 'conj', 'advcl'], ['obj']], objects=[['obj', 'compound', 'flat', 'nmod', 'obl']], got_networkx=True)[source]#

Generate knowledge graphs from dependency parsing model. This function been properly curated on top of malaya.dependency.transformer(version = ‘v1’).

Parameters
  • tagging (List[Tuple(str, str)]) – tagging result from dependency model.

  • indexing (List[Tuple(str, str)]) – indexing result from dependency model.

  • subjects (List[List[str]], optional) – List of dependency labels for subjects.

  • relations (List[List[str]], optional) – List of dependency labels for relations.

  • objects (List[List[str]], optional) – List of dependency labels for objects.

  • got_networkx (bool, optional (default=True)) – If True, will generate networkx.MultiDiGraph.

Returns

result

Return type

Dict[result, G]

malaya_graph.kg_to_text#

malaya_graph.kg_to_text.available_huggingface()[source]#

List available huggingface models.

malaya_graph.kg_to_text.huggingface(model='mesolitica/finetune-ttkg-t5-small-standard-bahasa-cased', **kwargs)[source]#

Load HuggingFace model to knowledge graph to text.

Parameters

model (str, optional (default='mesolitica/finetune-ttkg-t5-small-standard-bahasa-cased')) – Check available models at malaya_graph.kg_to_text.available_huggingface().

Returns

result

Return type

malaya_graph.model.text_to_kg.KGtoText

malaya_graph.model.text_to_kg#

class malaya_graph.model.text_to_kg.TexttoKG[source]#
generate(strings, got_networkx=True, **kwargs)[source]#

Generate list of knowledge graphs from the input.

Parameters
Returns

result

Return type

List[List[Dict]]

class malaya_graph.model.text_to_kg.KGtoText[source]#
generate(kgs, **kwargs)[source]#

Generate a text from list of knowledge graph dictionary.

Parameters
Returns

result

Return type

List[str]