Integration Cookbook Semantria
Share!TwitterFacebookLinkedInGoogle+Email

Hey everyone, last week I went over my experience with AlchemyAPI integration. This week, I’ll be covering my experience with Semantria. Once again, I will try to be as objective as possible and highlight all aspects of the integration from my personal experience.

Semantria

Semantria is a relatively young SaaS solution that utilizes Lexalytics’ Salience core engine under the hood, one of the best NLP engines on the market. As the CTO of Semantria, I am obviously biased in thinking that we are the Superman of all sentiment APIs, but I will try to remain as objective as possible and even expose some of our kryptonite.

Semantria offers seven SDKs (https://semantria.com/developer) for almost all modern platform languages including (my personal favorite) .Net. The SDK files are big because of the many types, which are intended for deserialization purposes. What I find to be very useful about Semantria’s SDKs is the Session object exposes several events, which catch raw requests and response data so the user can work with raw JSON/XML instead of native objects if necessary.

using (Session session = Session.CreateSession(consumerKey, consumerSecret, serializer))
{
session.Request += session_Request;
session.Response += session_Response;
}

 

private void session_Request(object sender, RequestEventArgs e)
{
}
private void session_Response(object sender, ResponseEventArgs e)
{
}

Semantria offers three different data delivery methods: polling, auto-response and web hook (callback). In my application, I used the simplest method available – polling, so the application queues and then requests analysis results from the server manually. I think that the asynchronous programming approach imposed by Semantria is a little complex, however the user benefits by improved performance.

Document doc = new Document()
{
Id = Guid.NewGuid().ToString(),
Text = text
};
session.QueueDocument(doc);
Thread.Sleep(2000);
List<DocAnalyticData> results = session.GetProcessedDocuments();

In my opinion, the strongest aspect of Semantria is its support of batched processing. This mode supports 100 documents to be queued in a single batch for faster processing. Again, because of the high performance, it increases the complexity of integration. Therefore, the SemantriaExecutor is one of the most complex among the implemented APIs.

List<Document> docs = new List<Document>();
foreach (string text in initialTexts)
{
    Document doc = new Document()
    {
Id = Guid.NewGuid().ToString(),
Text = text
    };
    docs.Add(doc);
}
session.QueueBatchOfDocuments(docs);

Overall Opinion

Semantria is a well-formed SDK along with two sample applications to make developers’ lives easier and the integration seamless. However, the integration is a little complex because of asynchronous programming model reflected in SDK. The complexity is a result of the best in class performance.

 

Check in next week for my integration experience with Chatterbox.

George Kozlov is a software engineering guru. He specializes in software research, architecture and maintenance. He co-founded Semantria, and is currently their CTO and go-to guy when things need improving.

Share!TwitterFacebookLinkedInGoogle+Email