endrcn / word2number_turkish

A word2number library for numbers written in Turkish

Home Page:https://endrcn.dev/word2number_turkish/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

word2number_turkish

NPM version

It is a Javascript library that converts numbers written with words to digits.

Installation

npm install --save word2number_turkish

Usage in Backend

const word2Number = require("word2number_turkish");
console.log(word2Number.convert("yüzaltmışyedi"));

You can extract numbers' indexes from sentences.

const word2Number = require("word2number_turkish");
let words = word2Number.splitSentenceToWords("sekizyüz on iki milyar üç yüz kırk dört milyon beşyüz yetmişikibin dörtyüz bir lira otuz iki kuruş");
console.log(word2Number.findNumbersIndexes(words));
// Output: [ { startIndex: 0, endIndex: 17 }, { startIndex: 19, endIndex: 20 } ]

Usage in Frontend

Put the script(client/word2number_turkish.js) between the head tags in your website. After that you can use the library.

<script src="./client/word2number_turkish.js"></script>
<script>
    const word2Number = new Word2Number();
    console.log(word2Number.convert("yüzyetmişiki lira on iki nokta üç kuruş"));
</script>

The word2number_turkish library was developed using ES6 classes.

Test

https://endrcn.github.io/word2number_turkish/

To Do

  • Handling all written numbers.
  • Handling phone numbers.
  • Handling zero number.
  • Handling numbers that next to each other.
  • Handling both numeric and written numbers.
  • Handling Dates.
  • Handling Decimal numbers.
  • Fuzzy matching.
  • Handling half numbers.

Unit Test Status

Total: 54

52 success, 2 fail

96%

Known Issues

  • "26FZ6A" is changed to "0 26fz 6 a"
  • "2bin60" is changed to "2 bin60"

Author

Ender CAN

License

Open sourced under the MIT license.

About

A word2number library for numbers written in Turkish

https://endrcn.dev/word2number_turkish/

License:MIT License


Languages

Language:JavaScript 91.7%Language:HTML 8.3%