Skip to content

Get text from file

get language of the text

The getLanguageText() function detects the language in which the text is written. The function takes a string of text as an input parameter and returns the language.

1
2
3
4
5
6
7
from blipper import Blipper

blip_obj = Blipper(blipper_api_key="lqqRYOOnSerIOP973hjskR", model="galileo")

text = "Your text goes here..."

result = blip_obj.getLanguageText(text=text)

get language of the text from file

The getLanguageFile() function detects the language of the text content in the file. The function takes a file id as an input parameter and returns the language. It only works on text files.

1
2
3
4
5
from blipper import Blipper

blip_obj = Blipper(blipper_api_key="lqqRYOOnSerIOP973hjskR", model="galileo")

result = blip_obj.getLanguageFile(id='docs/example.txt')

Translate the text

The translateText() function translates a given text to a target language. This function accepts a text and a target language as input and returns the translated text.

1
2
3
4
5
6
7
8
from blipper import Blipper

blip_obj = Blipper(blipper_api_key="lqqRYOOnSerIOP973hjskR", model="galileo")

text = "Your text goes here..."
lang = "spanish"

result = blip_obj.translateText(text=text, target_lang=lang)

This function is useful for applications that require text translation capabilities, such as multilingual chatbots or internationalization of web content. The function logs the translation result in the database and returns the translated text to the caller. For example, translating “Hello, World!” to French would return “Bonjour, le monde!”.

Translate the file

The translateFile() function translates the text contents from a file to a target language. This function accepts a file id and a target language as input and returns the translated text. It only works on text files.

1
2
3
4
5
6
7
from blipper import Blipper

blip_obj = Blipper(blipper_api_key="lqqRYOOnSerIOP973hjskR", model="galileo")

lang = "spanish"

result = blip_obj.translateFile(file_id='docs/example.txt', target_lang=lang)