Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
Implement Akshara Gana identification using trie
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayakakv committed Apr 3, 2020
1 parent b75bee6 commit 360718e
Show file tree
Hide file tree
Showing 6 changed files with 1,616 additions and 13 deletions.
47 changes: 47 additions & 0 deletions aksharagana.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Trie } from './trie.js'
import 'https://code.jquery.com/jquery-3.4.1.js';
import { AksharaTokenizerKannada } from 'https://cdn.jsdelivr.net/gh/vinayakakv/[email protected]/akshara_tokenizer.js'

class AksharaGanaIdentifier {
constructor(chandas_file_path) {
this.trie = new Trie();
this.tokenizer = new AksharaTokenizerKannada();
$.getJSON(chandas_file_path).then(data => {
data.forEach(chandas => {
let pattern = this.tokenizer.tokenize(chandas['pattern']).map(
token => {
if (token['vyamjana'] == 'ಲ')
return '0';
else if (token['vyamjana'] == 'ಗ')
return '1';
else
return [
'ನ',
'ಸ',
'ಜ',
'ಯ',
'ಭ',
'ರ',
'ತ',
'ಮ'].indexOf(token['vyamjana']).toString(2).padStart(3, 0);
}
).join('');
this.trie.insert(pattern, {
name: chandas["child_chandas"],
parent: chandas["parent_chandas"],
pattern: chandas["pattern"],
matraCount: chandas["characters"],
yatiPosition: chandas["yati"],
mention: chandas["chandombudi_source"]
});
});
})
}


identify(pattern) {
return this.trie.get(pattern);
}
}

export { AksharaGanaIdentifier }
Loading

0 comments on commit 360718e

Please sign in to comment.