Using APIs for developers who need more influence over their text processing

September 16, 2022
Using APIs for developers who need more influence over their text processing

If you love having more control over the text you process, you will enjoy using APILayer’s text processing APIs. The APIs listed below are text processing APIs that developers can use to add text processing capabilities to their applications.

Do you need Text APIs if you are already using a very advanced text editor?

If you use a text editor such as UltraEdit, you will know that much has evolved in what text editors can do. 

The advantages of using a bespoke text editor like UltraEdit compared to mainstream document editors like Microsoft Word are that UltraEdit is faster, has more features, and that it is more customizable through programming scripts and macros.  

UltraEdit also allows users to change keyboard shortcuts, colors, fonts, and layouts. These functions include syntax highlighting, code folding, column mode editing, and advanced search and replace.

Also, UltraEdit has become a text editor of choice for many coders. Some of its advantages include:  

  • A powerful code editor that supports many programming languages and file formats.  
  • Robust and performant features for a variety of tasks.
  • Highly customizable, allowing coders to tailor the coding environment to their needs.  
  • Available on many platforms; use different operating systems without issue.

If you are making manual changes to your own written work or code, Ultra Edit does the job perfectly. You can see firsthand the advantages of UltraEdit for improving and automating text workflow processes.

But what if you wanted to create a software or web app service that can analyze, paraphrase and translate user text on a more regular basis? Maybe even make a web service where users can bulk upload files and have the sentiment analyzed or translated into another language?

UltraEdit supports macros and scripts but if the nature of your work is repetitive with slight variations at each iteration, you may benefit from a more automated solution. For example, APILayer’s text APIs will be a great addition to your work process.

APIs can be used when you want to make a scalable solution for analyzing and changing text. It can be used to work with thousands of text documents sent to a SAAS web service at the same time. And for the quick edits and note-taking, you can use UltraEdit.

You don’t have to be building a complex multi-user SAAS service to benefit from an API that analyzes or changes text. The spell checker or paraphraser in a text editor can be used to check the spelling of text in the text editor. On the other hand, a Spell Checker API or a Paraphraser API can follow simple scripts that can be used to check text in many different programs simultaneously, such as word processors, web browsers, and email clients.

Essentially, text editors and text APIs are two different tools that do two similar jobs. However, you don’t use a paint roller when a tiny tipex brush would suffice (although UltraEdit is far from a tiny brush). You can think of text processing APIs doing the same sort of things that a text editor can do, but their scope of work is different.

If you know the basics of a programming language, the APILayer’s text processing APIs can make your work more efficient. There is simple user documentation for each of the following languages: Javascript, Python, PHP, Go, Java, Ruby, cUrl, C#, Swift, and C.

If you have basic coding skills, it is easy to switch to-and-from the functionality of text editors to having greater control of your text processing requirements using text processing APIs.

Spell Checker API

There are many reasons why you need to spell-check words. A good example of using a spell-check API is when you need to automate a business email campaign with live data pulled online. If you want to proof check data that your software algorithms are extracting from other sources, then a Spell Checker API would be essential for you.

The Spell Checker API from APILayer is all you need to add a spell checker to your Python scripting project or any other software project. 

How to use Spell Checker API

Just use your chosen programming language code to send your text to the API:

“tokk awya the garbase”

And you will get back a JSON-formatted result containing suggested corrections, the best candidate for the correction, and other possible candidates. 

Example result:

{
"corrections": [
{
"text": "tokk",
"best_candidate": "took",
"candidates": [
"took"
]
},
{
"text": "awya",
"best_candidate": "away",
"candidates": [
"away"
]
},
{
"text": "garbase",
"best_candidate": "garbage",
"candidates": [
"garbage"
]
}
],
"original_text": "tokk awya the garbase"
}

The Spell API uses artificial intelligence and machine learning to give accurate results in real-time.

Example code:

import requests
mytext = "tokk awya the garbase"
url = "https://api.apilayer.com/spell/spellchecker?q="+ mytext +""
payload = {}
headers= {
"apikey": "YOUR API KEY"
}
response = requests.request("GET", url, headers=headers, data = payload)
status_code = response.status_code
result = response.text
print(result)

Use more programming to change the misspelled word to the suggested best candidate, or set up your code to review all possible spellings. The APILayer Spell Check API returns results in a simple JSON format, so you can decide how to change your scripting to use the best candidate or suggested candidate words.

Paraphraser API

Some advantages of using the Paraphraser API from APILayer include: 

  • The API is easy to use and integrate into your own Python project
  • The API offers a free plan with limited calls and paid plans with more call limits
  • The API provides support and documentation to help you get started 

Example code

Below is a Python code example that iterates through paragraphs in a word document and uses APILayer’s paraphrase API to paraphrase the paragraphs.

import requests
from docx import Document
document = Document('YOUR_FILENAME.docx')

url = "https://api.apilayer.com/paraphraser"
headers= {
"apikey": "YOUR_API_KEY"
}

def analyze_text(text):
payload = text.encode("utf-8")
response = requests.request("POST", url, headers=headers, data = payload)
status_code = response.status_code
result = response.text
return result


for paragraph in document.paragraphs: # iterate through the word doc
my_dict = eval(analyze_text(paragraph.text)) # convert string to dict
#print(my_dict)
#print(type(my_dict))
print(my_dict["paraphrased"]) # print the paraphrase conversion value

Language translation API

API is the perfect solution. It uses the IBM Watson translation algorithm. With this API, you can translate text from over 47 different languages, with more being added all the time.

The APILayer Language Translation API is easy to use and can be integrated into any application or website with just a few lines of code. As well as detecting what language you have used (requiring no further configuration on your part) and giving you an accurate translation, the API also gives you a score for detected language confidence, as well as word count and character count.

Example results:

{
"translations": [
{
"translation": "Le chat s'assit sur le tapis"
}
],
"word_count": 6,
"character_count": 22,
"detected_language": "en",
"detected_language_confidence": 0.9945724439815723
}

Example code:

import requests

# Use fr at the end for French
url = "https://api.apilayer.com/language_translation/translate?target=fr"

mytext = "The cat sat on the mat"

payload = mytext.encode("utf-8")
headers= {
"apikey": "YOUR API KEY"
}

response = requests.request("POST", url, headers=headers, data = payload)

status_code = response.status_code
result = response.text
print(result)

Business use cases would include:

  • Allow businesses to quickly and easily translate their website content into multiple languages to reach a wider global audience.
  • Allow businesses to communicate with customers or employees who speak different languages by providing an automatic translation of messages.
  • Allow businesses to create multilingual customer support systems by providing an automatic translation of customer inquiries. 
  • Allow businesses to monitor global news and social media conversations by providing an automatic translation of online content.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

Latest News

Subscribe to Our Newsletter