Site icon Python GUI

Build A Python GUI Apps With Powerful Natural Language Processing Capabilities Using TextBlob Library In A Delphi Windows App

pexels panumas nikhomkhai 1148820

Do you want to perform Natural Language Processing tasks like part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, etc. in your GUI app? This post will get you to understand how to use TextBlob Python Library using Python4Delphi (P4D) in the Delphi/C++ Builder application and perform some interesting NLP tasks.

TextBlob is a Python library for processing textual data. It provides a simple and consistent API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, classification, translation, and more.

TextBlob stands on the shoulders of Giants, like NLTK and pattern, and plays nicely with both.

TextBlob powerful features at  a glance:

 

Hands-On

This post will guide you on how to perform Natural Language Processing tasks via Python’s TextBlob  and then display it in the Delphi Windows GUI app.

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

The following code shows a demo for Part-of-Speech Tagging, Noun Phrase Extraction, and Sentiment Analysis capabilities using TextBlob (visit source here):

[crayon-662d61582c0c8330901264/]

Here is the results in Python GUI:

The sentiment property returns a named tuple of the form Sentiment(polarity, subjectivity). The polarity score is a float value within the range [-1.0, 1.0] where -1.0 is very negative and 1.0 is very positive sentiment. The subjectivity is a float value t within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.

Let’s try TextBlob to perform the same operations as above to the excerpt of our articles:

[crayon-662d61582c0d2224849617/]

It runs blazingly-fast, doing all the operations smoothly for even longer text. It also works perfectly even for neutral sentences.

 

Congratulations, now you have learned how to perform Natural Language Processing tasks via Python’s TextBlob  and then display it in the Delphi Windows GUI app

Check out the TextBlob library for Python and use it in your projects: https://pypi.org/project/textblob/ and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi

Exit mobile version