tigrina
v2.0.0
Published
Tigrina alphabet processing, which helps to write Tigrina by Tigrina alphabets and other functionalities for manipulation of tigrina words.
Downloads
7
Maintainers
Readme
Tigrina alphabets processing library
This application is designed to facilitate the use of Tigrina alphabets for writing and linguistic analysis on computers and mobile devices. It provides a comprehensive set of functions to make working with the Tigrina language more efficient and accessible, whether you are a native speaker, language learner, or researcher.
Key Features
Tigrina Alphabet Input and Conversion:
- The application allows developers to type and manipulate text using the Tigrina script. It includes features for converting text written in Tigrina alphabets into numeric codes and vice versa, and many more others. Encoding and decoding text in Tigrina is particularly useful for encoding sensitive information or integrating Tigrina text into systems that require numeric data.
Transliteration Support:
- Users can easily convert Tigrina words written in the English alphabet into the proper Tigrina script. This feature helps bridge the gap for users more familiar with English keyboards but who want to write in Tigrina. So this kind of functionality can developers integrate on their projects for extra Tigrina words functionality to their end users.
Linguistic Tools for Verb, Noun, and Adjective Management:
- The library includes advanced functions for creating and analyzing verbs, nouns, and adjectives in the Tigrina language. It can generate conjugated verbs from their stems, extract stems from fully conjugated verbs, create noun stems, and manage adjective forms. These functions are invaluable for language learning, grammatical analysis, and content creation in Tigrina.This is also one use of this library that helps developers to integrate such functionality on their projects adds extra further advantages to their end users.
Text Processing and Sentence Management:
- For ease of translation and text manipulation, the library provides features to break down long sentences into smaller, manageable chunks. This functionality is crucial for accurately translating or processing complex text, making the application versatile for both casual and professional use.
Application Purpose
The primary purpose of this library is to enhance the ability to write, translate, and analyze text in Tigrina using digital devices. By integrating a range of linguistic functions and conversion features, the application supports both everyday communication and more specialized tasks, such as language education, research, and digital content creation. Whether you're composing a message, translating a document, or studying Tigrina grammar, this library offers a streamlined, user-friendly platform for all your needs as a developer to provide your end users.
User Manual: Code Word Functions for Tigrina Language Processing
This manual provides a brief explanation of the functions available in the tigrina_words
modules for processing Tigrina language text. Each function performs a specific task related to translating, encoding, or identifying Tigrina language elements.
1. Convert Tigrina Alphabet to Numeric Code
- Function:
code_translation("ፈተነ","code","")
- Description: Converts a Tigrina word or sentence (e.g., "ፈተነ") into its corresponding numeric code. This is useful for encoding Tigrina text. Keep in mind that this function code_translation("ፈተነ","code","") has three paramters but the third paramter is optional, and can be omited. However the third function is usefull on the decoding a text.
2. Decode Numeric Code to Tigrina Alphabet
- Function:
code_translation(mycode, 'decode', 'yes')
- Description: Decodes a numeric code back into the original Tigrina alphabet. The
mycode
variable contains the numeric code that will be decoded. On decoding a text, the third paramter helps to show a details of a single alphabet. example: code_translation("24501970","decode","yes") will show a details of the each alphabet like its family, position in the family and so on.
3. Convert English-Alphabet Tigrina to Tigrina Alphabet
- Function:
convert_sentence_to_tigrina("ezi natey iyu")
- Description: Converts Tigrina words written using the English alphabet (e.g., "ezi natey iyu") into the Tigrina alphabet. This helps in converting transliterated text back to its original script.
4. Translate Verb to Be in Tigrina
- Function:
verb_to_be_trans()
- Description: Provides translations of the verb "to be" in Tigrina across different forms. This function contains a dictionary or lookup table for verb conjugations.
5. Identify Verb to Be and Other Verbs in a Sentence
- Function:
verb_to_be("ይመጽእ ኣሎ")
- Description: Analyzes a given Tigrina sentence (e.g., "ይመጽእ ኣሎ") to identify and extract the verb "to be" and other verbs present in the sentence. This is useful for linguistic analysis and sentence parsing.
Usage Examples
Each function is designed for specific use cases, such as encoding/decoding text, converting transliterations, or analyzing verbs, nouns, adjectives in Tigrina sentences. For example, if you have a numeric code and need to retrieve the original Tigrina word, use the decoding function with the appropriate parameters. If you want Tigrina sentence investigation, it helps on this too to create a verb, noun, adjective to their stem or vis versa. This liberary includes more rubost functions that can help for developers to integrate on their application for more usability of their application to their end users.
Additional Functions in tigrina_words
Module for Tigrina Language Processing
This section of the manual explains additional functions available in the tigrina_words
module that focus on verb and adjective creation, stem extraction, noun processing, and sentence breaking for easier translation or processing.
const tigrina_words=require('tigrina/tg_main').Tigrina_words
let code=tigrina_words.code_translation("ግደ ሰጊድ",'code')
console.log("code:",code)
let decode=tigrina_words.code_translation(mycode,'decode','yes')
console.log("decode:",decode)
var resultVerb_createVerbFromStemVerb=tigrina_words.verb.create_verb_from_stem_verb("መጽእ",'future','we',"he",'ዘይ',"yes")
console.log("createVerbFromStemVerb:",resultVerb_create_verb_from_stem_verb)//output:
/*
createVerbFromStemVerb: {
text: 'መጽእ',
situation: 'future',
first_person: 'we',
third_person: 'he',
negativitiesOrFrontAdditions: 'ዘይ',
usingLeyLetter: 'yes',
result_text: 'ዘይክንመጽአሉ'
}
*/
var resultVerb_createStemFromVerb=tigrina_words.verb.create_stem_from_verb("ይመጽእ")
console.log("resultVerb_createStemFromVerb:",resultVerb_createStemFromVerb)
/* output
resultVerb_createStemFromVerb: {
mainResult: {
word: 'ይመጽእ',
frontErases1: '',
wordAfterErases1: 'ይመጽእ',
sentenceType: 'present',
frontErases2: 'ይ',
wordAfterErases2: 'መጽእ',
talkingAbout: '',
wordType: 'stem_1',
pronoun: 'he',
endsHerarchyOfWord: [ 'መጸአ', 'መጽአ', 'ማጸአ', 'መጻአ', 'መጾአ', 'ማጽአ' ]
}
}
*/
var resultnoun=tigrina_words.noun("ቦርሳታት")
console.log("resultnoun:",resultnoun)
/*output:
resultnoun: {
possess: '',
singularity: 'plural',
noun: [ 'ቦ', 'ር', 'ሳ' ],
wordChoices: [
'ቦርሰ', 'ቦርሱ',
'ቦርሲ', 'ቦርሳ',
'ቦርሴ', 'ቦርስ',
'ቦርሶ'
]
}
*/
var resultAdjective_makeAdjectiveFromStem=tigrina_words.adjective.make_adjective_from_stem('ብርቱዕ','first','her')
console.log("resultAdjective_makeAdjectiveFromStem:",resultAdjective_makeAdjectiveFromStem)
make_adjective_from_stem(
text:'text to make a new word: ሓዲሽ ቃል ክስራሕ ተደልዩ ዘሎ ቃል',
//degree:indicates if there is comparison like greate-first degree, greater-second degree, greatest-third degree,
//ከም መወዳደሪ ንጥቀመሉ ሓረግ ንኣብነት ዝዓቢ፡ ደግሪ ሓደ ክኸውን ከሎ ካብኡ ንሳ ትዓቢ ከኣ ደግሪ ካላኣይ ይከውን፣ ዝዓበየት ተኮይኑ ከኣ ሳልሳይ ደግሪ,
//toWhome: to whom are you talking about, to him, her, me, us,them, you, ነቲ ዛዕባ ጌርካዮ ዘለኻ ሰብ፣ ነኣብነት ፡ ንዑኡ፣ ንዓኣ፣ ንዓኣቶም
//negativity:ዘይ, ኣይ, እንተዘይ, ከይ
//in_comparison_to: her,him,them,you,it example: ሓይልዋ, ስለዚ መን ሓይልዋ ? , ንሱ, ን መን ንዓኣ
//additions: ኣብ መጀመርያ ቃል ዝርከቡ ፊደላት ግን ኣካል ናይቲ ቀንዲ ቃል ዘይኮኑ፣ ናኣብነት ምስዘይሕይላ ፡ ኢዛ ቃል ምስዘይ ኣብ ይሕይላ ተወሲኻ ኣላ ስለዚ ምስዘይ ከምተወሳኪ ቃል ነእትዎ።
/*output: ብርትዕቲ
resultAdjective_makeAdjectiveFromStem: {
text: 'ብርቱዕ',
degree: '',
toWhom: 'him',
negativity: '',
in_comparison_to: '',
additions: 'እንተዘ',
result_text_tigrina: 'እንተዘበርትዕ',
result_text_english: 'if he'
}
*/
var resultAdjective_makeStemFromAdjective=code_word.adjective.make_stem_from_adjective('ብርትዕቲ')
console.log("resultAdjective_makeStemFromAdjective",resultAdjective_makeStemFromAdjective)//output:ብርቱዕ
let text = "test text here. This is another test.";
let breakingtest=code_word.breakText(text,"")
console.log("breakingtest:",breakingtest)
// out put:breakingtest: [ 'test text here.', ' This is another test.', '' ]
Coding and Decoding
This tool allows you to encode and decode text, making it particularly useful for storing encoded text in a database. The encoded text is converted into a long sequence of numbers, making it a numeric value. Storing these numeric values in a database enhances search efficiency, as databases are optimized for fast retrieval of numeric data.
let mycode=tigrina_words.code_translation("ዘይብርትዕቲ ኔራ",'code')
console.log("mycode:",mycode)
let mydecode=tigrina_words.code_translation(mycode,'decode','yes')
console.log("mydecode:",mydecode)
Convert english alphabetical tigrina sentence to tigrina written words
This conversion allows you to type Tigrinya text using English alphabets, and then convert it back into Tigrinya script vis versa.
let convert=tigrina_words.convert_sentence_to_tigrina("ezi natey iyu")
console.log("convert:",convert)
From tigrina to english alphabets
let convert=tigrina_words.convert_tigrina_to_english_alphabet('ከመይ ኣለኻ')
console.log("convert:",convert)
//kemey aleKa
Verb to be
This shows any verb to be information on the given text. The verbToBeTrans is an array of objects that lists all possible forms of the verb "to be" in Tigrinya. Each object contains fields for id, tigrina, and english. By filtering this array based on these fields, you can easily retrieve the translated form of any Tigrinya verb "to be".
The verbToBe(text) function helps to get a verb to be information in a give text.
let verbtobetrans=code_word.verb_to_be_trans()
console.log("verbtobetrans:",verbtobetrans.find((value)=>value.id=67))
let verbtobeInfo=code_word.verbToBe("ክመጽእ ኢየ")
console.log("verbtobeInfo:",verbtobeInfo)
/* output
verbtobeInfo: [
{
text: 'ኢየ',
pronoun: 'i',
verb: { text: 'ክመጽእ', index: 0 },
verbToBe: 'will',
index: 1,
type: 'verbToBe'
}
]
*/
Convert stem to verb
You can create a verb from stem verb
var resultVerb_createVerbFromStemVerb=tigrina_words.verb.create_verb_from_stem_verb("መጽአ",'future','we',"he",'ዘይ',"yes")
console.log("createVerbFromStemVerb:",resultVerb_createVerbFromStemVerb)
/* output
createVerbFromStemVerb: {
text: 'መጽአ',
situation: 'future',
first_person: 'we',
third_person: 'he',
negativitiesOrFrontAdditions: 'ዘይ',
usingLeyLetter: 'yes',
result_text_tigrina: 'ዘይክንመጽአሉ',
result_text_english: '',
is_negative: 'yes'
}
*/
Convert verb to stem
Just as it's possible to convert a stem into a verb, the reverse is also true—you can create a stem from a verb.
var resultVerb_createStemFromVerb=tigrina_words.verb.create_stem_from_verb("ኣሲራቶም")
console.log("resultVerb_createStemFromVerb:",resultVerb_createStemFromVerb)
/* output
resultVerb_createStemFromVerb: {
mainResult: {
word: 'ኣሲራቶም',
frontErases1: '',
wordAfterErases1: 'ኣሲራቶም',
sentenceType: 'past',
frontErases2: '',
wordAfterErases2: 'ኣሲራቶም',
talkingAbout: [ 'ቶም', 'them', 'to them' ],
wordType: '',
pronoun: 'she',
endsHerarchyOfWord: [
'ተሰረ', 'ተስረ', 'ታሰረ',
'ተሳረ', 'ተሶረ', 'ታስረ',
'አሰረ', 'አስረ', 'ኣሰረ',
'አሳረ', 'አሶረ', 'ኣስረ'
]
}
}
*/
noun identification
You can convert a noun to its plural or singular form
var resultnoun=tigrina_words.noun("ቦርሳታት")
console.log("resultnoun:",resultnoun)
/* output
resultnoun: {
possess: '',
singularity: 'plural',
noun: 'ቦርሳ',
wordChoices: [
'ቦርሰ', 'ቦርሱ',
'ቦርሲ', 'ቦርሳ',
'ቦርሴ', 'ቦርስ',
'ቦርሶ'
]
}
*/
Adjectives
You can create adjectives. Converting adjective to stem adjective or vis versa is also one of the task of this library.
var resultAdjective_makeAdjectiveFromStem=tigrina_words.adjective.make_adjective_from_stem('ብርቱዕ','','her','','','እንተዘይ')
console.log("resultAdjective_makeAdjectiveFromStem:",resultAdjective_makeAdjectiveFromStem)
/* output
resultAdjective_makeAdjectiveFromStem: {
text: 'ብርቱዕ',
degree: '',
toWhom: 'her',
negativity: '',
in_comparison_to: '',
additions: 'እንተዘይ',
result_text_tigrina: 'በርቲዓ',
result_text_english: ''
}*/
var resultAdjective_makeStemFromAdjective=tigrina_words.adjective.make_stem_from_adjective('እንተዘይብርትዓ')
console.log("resultAdjective_make_stem_from_adjective",resultAdjective_makeStemFromAdjective)
//output resultAdjective_makeStemFromAdjective: ብርቱዕ
Breake long sentence into chunks of array items
At the end of the process, sentences need to be broken down into individual chunks, each containing a single sentence. This makes it easier to process, translate, encode, or decode the text. If a sentence contains multiple periods, question marks, or commas, it will be split at these punctuation marks to create an array of sentence chunks. Each chunk in the array can then be processed individually, which simplifies tasks like translation or text encoding and decoding.
let breakingtest=tigrina_words.break_text("test text here. This is another test.","")
console.log("breakingtest:",breakingtest)
//output breakingtest: [ 'test text here.', 'This is another test.' ]
Families and postions of alphabets
You can retrieve the positions and families of any text within the Tigrinya alphabet list. By knowing the position of each character, you can manipulate the text according to your needs. This information is useful for various text processing tasks, such as encoding, decoding, or customizing the text.
let get_family_info=code_word.get_family("ይመጽእ")
console.log("get_family_info:",get_family_info)
// output get_family_info: { families: 'የመጸአ', positions: '6166', text: 'ይመጽእ' }
A package for managing data and sorting tigrinya alphabet strings, with additional SQL query functionalities.
Additional Functionalities
This package has been extended with several new functions that enable SQL-based data management. Below are descriptions and usage examples for each of these functionalities.
1. Tigrinya Alphabetical Ordering
let order_alphabetically = tigrina_words.order_tg(["ግደ",'ጸጋይ','ዝፋን','ሂወት'], "", "asc");
console.log("order_alphabetically:", order_alphabetically);
Description:
Sorts an array or array objects of Tigrinya words in alphabetical order according to the Tigrinya alphabet. The order can be specified as ascending ("asc") or descending ("desc").
Usage:
Use this function to organize data that uses the Tigrinya alphabet in a meaningful sequence, aiding in better data presentation and accessibility.
2. Select Query
async function select() {
const query = "select name, age from tb12 inner join tb2 on tb2.id=tb1.id where name='gide segid'";
let mydata = await tigrina_words.data.select(query);
console.log("selected data:", mydata);
}
Description:
Executes a SQL SELECT query to retrieve specific columns (name, age) from a database. The query filters results where the name matches a specified value.
Usage:
Fetch data from your csv file that meets certain criteria, making it easier to retrieve and analyze information.
3. Insert Query
async function insert() {
const sqlQuery = "insert into tb1 (id, name, age, city) values(12,'gide segidew', 42, 'Nijmegene')";
let resultins = await tigrina_words.data.insert(sqlQuery);
console.log("resultins:", resultins);
}
Description:
Executes a SQL INSERT query to add a new row to a specified table/ csv file. The query inserts values into specified columns of the table.
Usage:
Add new records to your database to expand your data set.
4. Update Query
async function update() {
const sqlQuery_update = "update tb1 set name='gide segid', age=48 where name='gide segid'";
let result = await tigrina_words.data.update(sqlQuery_update);
console.log("result update:", result);
}
Description:
Executes a SQL UPDATE query to modify existing data in a table. The query updates specified columns where a condition is met.
Usage:
Update existing data within your database to keep information current and accurate.
5. Delete Query
async function delete() {
let deleteQuery = "delete * from tb1 where name='gide segid'";
let result = await tigrina_words.data.delete(deleteQuery);
console.log("resut on dele:", result);
}
Description:
Executes a SQL DELETE query to remove rows from a table based on specified conditions.
Usage:
Remove outdated or irrelevant data from your database to maintain its quality.
6. Get Tables
async function get_tables() {
let query = "show tables"
let get_tables = await tigrina_words.data.get_tables(query);
console.log("get_tables:", get_tables);
}
Description:
Executes a SHOW TABLES query to list all tables in the current database.
Usage:
Retrieve a list of all tables within your database to understand the schema or perform specific operations.
7. Get Fields
async function get_fields() {
let query = "describe tb1"
let get_fields = await tigrina_words.data.get_fields(query);
console.log("get_fields:", get_fields);
}
Description:
Executes a DESCRIBE query to get detailed information about the structure of a specified table, including column names, data types, and constraints.
Usage:
Examine the structure of your database tables to better understand the data they contain and how to work with them.
These functions provide robust data management capabilities, making it easy to interact with your database using SQL queries directly within your Node.js environment. Whether you're sorting Tigrinya words or performing some SQL operations, this package simplifies the process, enabling more efficient and effective data handling.
Installation
To use the library, require it in your project as follows: Main Module: main (from tigrina.Tigrinya_alphabet_coder_decoder import Tigrina_info as tigrina_words) The Tigrinya_alphabet_coder_decoder is the main module of this library. It serves as a one-stop solution that integrates all the functionalities provided by the other modules in the package. By importing this Tigrinya_alphabet_coder_decoder, you will have access to all the features and capabilities of the entire library. This makes it the simplest and most convenient option for users who want to utilize the full potential of the library without having to manage individual imports.
Key Points:
All-in-One Access:
When you import tigrina_words=require('./main').Tigrina_words, you automatically gain access to all other modules, functions, and classes in the library. There's no need for additional imports unless you want to work with specific components separately.
Convenient and Efficient:
This file has been designed to streamline your experience by providing a single point of entry to the entire package. You won't need to worry about missing out on any feature or functionality; it's all included!
const tigrina_words = require('./main').Tigrina_words;
Functionality
Get alphabet family information
To get the alphabet family of a specific alphabet:
let get_family_info = tigrina_words.get_family("ይመጽእ");
Encode Text
To get the encoded value of any text:
let mycode = tigrina_words.code_translation("ዘይብርትዕቲ ኔራ", 'code');
Decode Text
To decode the encoded text:
let mydecode = tigrina_words.code_translation(mycode, 'decode', 'yes');
Convert english to tigrina alphabet
To convert English alphabet-written text into Tigrina alphabet-written text:
let convert = tigrina_words.convert_sentence_to_tigrina("ezi natey iyu");
Get Alphabet Information
To get a list of functions that help with alphabet retrievals, positions in a family, or other family information:
let tg_alphabets = tigrina_words.alphabets_info;
Order tigrina words
To order Tigrina words in ascending or descending order. For arrays of objects, provide the column name as an additional parameter. example:
let orderIt = tigrina_words.order_tg(array, '', 'asc');
This is example of ordering array objects, which indicates that the input data is array objects or list of objects in a list or array, then the second paramter will be the field on which the order mechanism will be inplemented. example in this case we need to order de array object by name, hence the second paramter is "name"
var order_alphabetically = tigrina_words.order_tg([{"name":'ግደ',"age":40}, {"name":'ጸጋይ',"age":38}, {"name":'ዝፋን',"age":42}, {"name":'ሂወት',"age":52}], "name", "asc")
Get Verb Translations
To get translations of verbs to Tigrina with filtering options:
let verbtobetrans = tigrina_words.verb_to_be_trans();
Create Verb from Stem
To create a verb from a stem:
let resultVerb_createVerbFromStemVerb = tigrina_words.verb.create_verb_from_stem("መጽአ", 'future', 'we', "he", 'ዘይ', "yes");
Create Stem from Verb
To create a stem from a verb:
let resultVerb_createStemFromVerb = tigrina_words.verb.create_stem_from_verb("ኣሲራቶም");
Create Singular Noun from Plural
To create a singular form of a plural noun:
let resultnoun = tigrina_words.noun("ቦርሳታት");
Create Adjective from Stem
To create an adjective from a stem adjective:
let resultAdjective_makeAdjectiveFromStem = tigrina_words.adjective.make_adjective_from_stem('ብርቱዕ', '', 'her', '', '', 'እንተዘይ');
Create Stem Adjective from Non-Stem Adjective
To create a stem adjective from a non-stem adjective:
let resultAdjective_makeStemFromAdjective = tigrina_words.adjective.make_stem_from_adjective('ሓይላ');
Break Long Text into Chunks
To break long text into chunks of sentences, separated by periods or commas:
let breakingtest = tigrina_words.break_text("test text here. This is another test.", "");
Order Tigrina Words Alphabetically
To order arrays or array objects of Tigrina words alphabetically:
let order_alphabetically = tigrina_words.order_tg(["ግደ", 'ጸጋይ', 'ዝፋን', 'ሂወት'], "", "asc");
If you order array object, then keep in mind that the second paramter will be the column name in the object array to be ordered. example:
let data=[{name:'ግደ',age:40},{name:'',age:40},{name:'ጸጋይ',age:36},{name:'ዝፋን',age:42}]
//when you call the function on ordering the data based on name, then do it like this.
//This tells that the data will be ordered by name in asc order.
let order_alphabetically = tigrina_words.order_tg(data, "name", "asc");
Database Operations
The package includes CSV samples that contain translations of English to Tigrinya. These files come pre-built with the library, so it can also function as a translation tool. However, caution is needed when working with these files. To extract data, it's recommended to use SQL queries. Specifically, there is a collection of tokenized data that is encrypted. If you wish to use this tokenized data, you must encrypt your input to match the search criteria with the file contents. After retrieving the results, you will need to decrypt them to make the output human-readable. Note that input encryption and output decryption are only required when working with tokenized data.
Select Data from a Table:
async function select_test() {
const query = "select name from tb1 inner join tb2 on tb2.id=tb1.id where name='gide segid'";
let mydata = await code_word.data.select(query);
console.log("selected data:", mydata);
}
//select_test();
Select data from encoded table
async function select_test_from_coded_table(){
//first encode the word you want to search on
let code=tigrina_words.code_translation("ሕጽበት","code","")
//query
const query = "SELECT * from tokenized_data where tg_code="+code;
let mydata= await tigrina_words.data.select(query);
//loop through query result if result.length > 0
for(key in mydata){
let get_decoded=tigrina_words.code_translation(mydata[key].en_code,"decode","yes")
console.log("get_decoded:",get_decoded.decode)
}
}
Insert Data into a Table:
async function insert_test() {
const sqlQuery = "insert into tb1 (id, name, age, city) values(12, 'gide segidew', 42, 'Nijmegene')";
let resultins = await code_word.data.insert(sqlQuery);
console.log("resultins:", resultins);
}
// insert_test();
Update Data in a Table:
async function update_test() {
const sqlQuery_update = "update tb1 set name='gide segid', age=48 where name='gide segid'";
let result = await code_word.data.update(sqlQuery_update);
console.log("result update:", result);
}
// update_test();
Delete Data from a Table:
async function delete_test() {
let deletquery = "delete from tb1 where name='gide segid'";
let result = await code_word.data.delete(deletquery);
console.log("result on delete:", result);
}
// delete_test();
Fetch All Tables in a Database:
async function get_tables_test() {
let query = "show tables";
let get_tables = await code_word.data.get_tables(query);
console.log("get_tables:", get_tables);
}
// get_tables_test();
Show All Fields in a Table:
async function get_fields_test() {
let query = "describe tb1";
let get_fields = await code_word.data.get_fields(query);
console.log("get_fields:", get_fields);
}
// get_fields_test();