This repository has been archived by the owner on Nov 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Akshara Gana identification using trie
- Loading branch information
1 parent
b75bee6
commit 360718e
Showing
6 changed files
with
1,616 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
Oops, something went wrong.