Skip to main content
Version: 2.0

Meaning

Video

What is meaning?

The categorization of words is a central element of textual analysis. When a token is a word that has several possible senses, it’s the disambiguation that makes it possible to indicate which is the correct meaning.

If you are looking for more about meaning check out our documentation 👨🏻‍💻

Importing the library & your personal API key

After you've installed the Lettria package on Python you'll need to import the library.

import lettria

Next you are going to need to include your personal API key which can be found via the Lettria platform in the dashboard.

api_key = 'your personal API key'
nlp = lettria.NLP(api_key)

Adding data

Next I am going to add data to be analyzed. You can also upload a saved document using the ‘with open’ command.

data = ‘example text’

Next add the data to the NLP.

nlp.add_document(data)

Extracting the meaning

In order to extract the meaning from your document use the following command:

for t in nlp.documents[0].tokens:
print(t.token, t.meaning)

In the return you will find a list of category objects or meanings with the complete path from the broadest category to the finest category. Something to note, if there is no disambiguation, several possible meanings can be displayed.

Saving your results

In order to save your results you can use the following command.

nlp.save_results(‘example_results')

And a json file with your results that can be used for further analysis will be saved.

Code set

import lettria

api_key = 'your personal API key'
nlp = lettria.NLP(api_key)

data = ‘example text’

nlp.add_document(data)

for t in nlp.documents[0].tokens:
print(t.token, t.meaning)

nlp.save_results(‘example_results')