Giter Site home page Giter Site logo

riti's People

Contributors

gulshan avatar mominul avatar nabilsnigdho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

riti's Issues

Use sqlite crate for database handling.

Rust currently has this two sqlite crates: rusqlite & sqlite.

This is the relevant C++ code before we started using json files.

This is the Rust code that I used to generate dictionary.json and suffix.json files with rusqlite crate:

extern crate rusqlite;
extern crate serde_json;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use rusqlite::Connection;

fn main() {
    let table = vec!("A", "AA", "B", "BH",
                       "C", "CH", "D", "Dd", "Ddh", "Dh",
                       "E", "G", "Gh", "H", "I", "II",
                       "J", "JH", "K", "KH", "Khandatta",
                       "L", "M", "N", "NGA", "NN", "NYA",
                       "O","OI", "OU", "P", "PH",
                       "R", "RR", "RRH", "RRI",
                       "S", "SH", "SS",
                       "T", "TH", "TT", "TTH",
                       "U", "UU", "Y", "Z");

    let conn = Connection::open("/home/mominul/src/OpenBangla-Keyboard/data/database.db3").unwrap();
    // Dictionary
    let mut dict = HashMap::new();
    let mut count = 1;

    for name in table {
        let mut stmt = conn.prepare(&format!("SELECT * FROM {}", name)).unwrap();
        let mut rows = stmt.query(&[]).unwrap();
        let mut items: Vec<String> = Vec::new();

        while let Some(res_row) = rows.next() {
            let row = res_row.unwrap();
            items.push(row.get(0));
            count += 1;
        }
        dict.insert(name.to_ascii_lowercase(), items);
    }

    // Suffix dictionary
    let mut suffix: HashMap<String, String> = HashMap::new();

    let mut stmt = conn.prepare("SELECT * FROM Suffix").unwrap();
    let mut rows = stmt.query(&[]).unwrap();

    while let Some(res_row) = rows.next() {
        let row = res_row.unwrap();
        suffix.insert(row.get(0), row.get(1));
    }

    let serialized = serde_json::to_string_pretty(&dict).unwrap();
    println!("Words entried in total {}", count);
    let mut file = File::create("/home/mominul/src/Rust/dictionary2.json").unwrap();
    file.write_all(serialized.as_bytes()).unwrap();

    let serialized = serde_json::to_string(&suffix).unwrap();
    let mut file = File::create("/home/mominul/src/Rust/suffix.json").unwrap();
    file.write_all(serialized.as_bytes()).unwrap();
}

Use json crate

We currently use the serde-json crate to parse the json files, but it is a heavy weight crate & we don't use it's main serialization feature. So we can use the json crate which is enough and fast for our needs.

Suggest to have a riti_context_set_option API

Right now all the options are passed from environment variable which is kinda weird in practice. So I think if would be better to have API like:

RitiOptions* riti_options_new()
riti_options_set_optiona(RitiOptions *, bool value)
riti_options_set_optionb(RitiOptions *, const char* value)
riti_options_set_optionc(RitiOptions *, bool value)
....
riti_option_free(RitiOptions *)

void riti_context_set_options(RitiContext* context, RitiOptions* options);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.