elaenka
v2.3.0
Published
A Nodejs client for the ELAENKA NLP API
Downloads
27
Maintainers
Keywords
Readme
node-elaenka
Node-elaenka is a Nodejs client for the ELAENKA NLP API: https://rapidapi.com/nwatson/api/elaenka-nlp
Setup Instructions
Install
Run npm install node-elaenka
Set up a RapidAPI key
Go to the ELAENKA NLP API's page within RapidAPI specified above. You can sign up as a user there and get an API key.
Getting Started
Here is a sample use of node-elaenka, useful for making sure you have set up everything:
"use strict";
const Elaenka = require('../node-elaenka/node-elaenka.js');
const client = Elaenka.makeClient('YOUR API KEY HERE');
client['rus'].bgn_pcgn('Екатерина Петро́вна Замоло́дчикова', function(err, data){
console.log(err);
console.log(data);
});
//This should print null, followed by Yekaterina Petróvna Zamolódchikova.
Structure
The object returned by require
ing node-elaenka has the following:
- A function named makeClient, which returns an object with the actual functions for interacting with the ELAENKA NLP API. The object's keys are strings, where each key is a 3-letter language or script code. Each value within said object is an object which consists of methods for test transformation and manipulation.
- Each function within the makeClient object follows the same specification. They take 2 parameters: a string to be manipulated and a callback. The callback takes 2 parameters: an error which may or may not be null and a result string which may or may not be null.
- A function called makePromiseClient, which takes a function from the returned object from makeClient, and returns a promisified equivalent.
Reference
- makePromiseClient : This takes a parameter of a function which takes a text and error/response callback, and returns an equivalent promise.
"use strict";
const Elaenka = require('../node-elaenka/node-elaenka.js');
const client = Elaenka.makeClient('YOUR API KEY HERE');
const toBeTransformed = client['ukr'].ukrainian_passport_2010;
const p = Elaenka.makePromiseClient(toBeTransformed);
p.then(function(text){
console.log(text);
}).catch(function(err){
console.err(err);
});
- makeClient : Takes a RapidAPI API key, and returns an object of the following structure:
{
'bel':{
belarus_geo_2007: function(text, callback(err, result))//Latinizes Cyrillic text in the Belarusian language to the 2007 Belarusian government standard for locations.
},
'bul':{
bulgarian_government_romanization: function(text, callback(err, result))//Latinizes Cyrillic text in the Bulgarian language to the Bulgarian government standard.
},
'kaz':{
cyrillic_to_latin_2018: function(text, callback(err, result))//Latinizes Cyrillic text in the Kazakh language to the 2018 Kazakhstan government standard.
},
'hbs':{
cyrillicToLatin: function(text, callback(err, result)), //Latinizes Cyrillic text in the Bosnian/Croatian/Montenegrin/Serbian language family
latinToCyrillic: function(text, callback(err, result)) //Cyrillicizes Latin-alphabet text in the Bosnian/Croatian/Montenegrin/Serbian language family
},
'rus':{
passport2013: function(text, callback(err, result)), //Romanizes Russian to the 2013 Passport standard
bgn_pcgn: function(text, callback(err, result)) //Romanizes Russian to the BGN/PCGN standard
},
'ukr':{
ukrainian_passport_2010: function(text, callback(err, result)) //Romanizes Ukrainian to the 2010 government standard for Passports.
},
'mkd':{
icao_9303: function(text, callback(err, result)) //Romanizes Macedonian to the ICAO 9303 standard.
},
'jpn':{
variant_kana_normalization: function(text, callback(err, result)) //Takes Japanese text; converts the enclosed characters, half-width characters, and hentaigana; and converts them into standardized Hiragana and Katakana.
},
'kor':{
hanyangToUnicode: function(text, callback(err, result)) //Takes Korean text and replaces any Hanyang private characters with their Unicode equivalents.
},
'mon':{
mongolianGovernmentRomanization: function(text, callback(err, result)), //Romanizes Cyrillic Mongolian text to the Mongolilan government standard.
menksoftToUnicode: function(text, callback(err, result)), //Converts from Menksoft private characters to standard Unicode
unicodeToMenksoft: function(text, callback(err, result)) //Converts from standard Unicode to Menksoft private characters
},
'jje':{},//see kor
'okm':{},//see kor
'oko':{},//see kor
'mac':{},//see mkd
'scr':{},//See hbs
'scc':{},//See hbs
'bos':{},//See hbs
'cnr':{},//See hbs
'hrv':{},//See hbs
'kjv':{},//See hbs
'srp':{},//See hbs
'khk':{},//See mon
'mvf':{},//See mon
'svm':{}//See hbs
}