Hash_Dictionary is a web application made with react. It's core javascript module for English to Bangla translation implements Perfect hashing. I have made it as a part of my Algo-2 course assignment.
Watch live : https://rahathossain690.github.io/Hash-Dictionary/
Above code is explained in Bangla in youtube as a part of my assignment.
Explanation url: https://www.youtube.com/watch?v=q1lk1bU9DO0
- Clone the repo locally.
- Run command
npm install
- To run the application
npm start
- Locate the core module at /src/Hash_dictionary path.
Core module is located at /src/Hash_dictionary path.
- Takes on average 503 miliseconds time to hash 130084 words.
- Each search takes O(1) time because of using Perfect hashing.
const Hash_dictionary = require('./Hash_dictionary')
const hash_dictionary = new Hash_dictionary({
'A': 'একটি',
'Apple': 'আপেল' ,
'Rahat': 'খুব ভালো ছেলে'
}, 10)
hash_dictionary.start_process().then(result => {
console.log( hash_dictionary.search('Rahat') )
// output: খুব ভালো ছেলে
})
const hash_dictionary = new Hash_dictionary(DATA, SLOT_SIZE)
// format of DATA (Object)
// DATA {
// word_1: meaning_1,
// word_2: meaning_2,
// word_3: meaning_3,
// ... ...
// }
// SLOT_SIZE should be an Integer. Default value is 2^20 + 7 (If not speficied)
This asyncronus function provokes the hashing process of words. Returns a promise. Return value is an object containing the information of time to execute the operation and number of words stored.
// using callback
hash_dictionary.start_process().then(result => {
console.log( result )
// do something else
})
// using async
(async () => {
const result = await hash_dictionary.start_process()
// do something else
})()
Searches into the dictionary in O(1) time. Works after hashing process is finished.
console.log( hash_dictionary.search('cheese') ) // output: পনির
After processing hash table, this function saves the local hash-data to a file to reduce further processing time.
hash_dictionary.dump()
Loads hash-data from file and saves processing time.
hash_dictionary.load()
Returns a boolean indiciting weather hash processing is completed.
console.log( hash_dictionary.is_processed() ) // true / false
Dataset collected and combined from this repo.