Skip to content

TETRA: TExtual TRust Analyzer for a Gricean Approach to Social Networks

License

Notifications You must be signed in to change notification settings

simonamazzarino/TETRA

Repository files navigation

TETRA: TExtual TRust Analyzer

This library provides tools for analyzing the trust between two people in a conversation analyzing their messages. The library focuses on evaluating manner, similarity, and quantity for each text. It leverages various NLP libraries and APIs, including Google's Perspective API, Detoxify, NLTK, Presidio, and Sentence Transformers.

Features

  • Manner Analysis: Evaluates the manner of text using either Detoxify or Google's Perspective API, checking for harmful content indicators such as toxicity, profanity, threats, etc.
  • Similarity Analysis: Computes the cosine similarity between two pieces of text using a pre-trained sentence transformer model.
  • Quantity Analysis: Measures the informational density of text, taking into account named entities and coherence with another piece of text.

Installation

You can install TETRA by using pip:

pip install tetra-textual-trust-analyzer

Quickstart

You can import the Trust class using

from tetra.trust_main import Trust

Then, you create a Trust object and set your Perspective API key. If you don't already have a Perspective API key, you can visit this link and create your own key. Otherwise, Tetra will default to Detoxify.

trust_analyzer = Trust('<insert-your-Perspective-API-key>')

To obtain the trust scores between two sentences you need to use the method get_trust() and provide the sentences as parameters in the following way:

scores = trust_analyzer.get_trust(
    "This is the main comment, of which we are analyzing the trust.",
    "And this is the comment it is responding to. For example, it could be a question.")

This method returns as output the trust scores, i.e. manner, similarity and quantity scores.

for maxim, score in zip(['Similarity', 'Quantity', 'Manner'], scores):
    print (maxim, score)

Examples

You can find a notebook example in the notebook folder.

About

TETRA: TExtual TRust Analyzer for a Gricean Approach to Social Networks

Resources

License

Stars

Watchers

Forks

Packages

No packages published