HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

Get Ontology Tags from Statements

📘

General Note

This guide follows along with the Layar API Software Developers Kit (SDK). We recommend you have the Github reference documentation open in a separate tab while working through this guide.

Instantiate Paragraph and Ontology Term APIs

The first thing to do is instantiate the API classes you'll be using. In this case, we'll use the Paragraph API to parse our text for queryable terms, and then use the Ontology Term API to search our ontologies for those terms.

ontologies = layar_api.OntologyTermApi(client)
paragraphs = layar_api.ParagraphApi(client)

Parse Text For Queryable Terms

First, we will use the part_of_speech_parse_text_post endpoint in our ParagraphApi to retrieve a list of queryable terms

terms = paragraphs.part_of_speech_parse_text_post(body=layar_api.PartOfSpeechCommand('***TEXT BLOCK***'))['queryableTermCandidates']

Query Terms for Ontology Tags

Now we are ready to get our ontology terms via the ontology_terms_search_post method in the OntologyTermApi.

ontologies.ontology_term_search_post(body=layar_api.OntologySearchCommand(document_ids=['ONTOLOGY_IDS'], terms=terms))

This will return a list of ontology term objects with details for each term found directly or semantically in the queryable terms from your text.

Great job!