Partial dictionary rewrite
This commit is contained in:
1 parent
1509947cb0
commit
f2035ca749
12 files changed
+304
-363
No files matched your search
+10
-51
@@ -6,9 +6,9 @@ use chrono::{DateTime, NaiveDate, Utc};
|
||||
use fsrs::MemoryState;
|
||||
use litemap::LiteMap;
|
||||
use log::info;
|
||||
use rayon::prelude::*;
|
||||
use rhai::{Engine, Scope};
|
||||
use rhai::Engine;
|
||||
use std::cmp::Ordering;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -77,8 +77,6 @@ pub struct DeckSettings {
|
||||
pub forward: String,
|
||||
pub backward: String,
|
||||
pub filter: String,
|
||||
pub count: Option<usize>,
|
||||
pub open_mode: OrderMode,
|
||||
}
|
||||
|
||||
impl EntityData for DeckSettings {
|
||||
@@ -99,8 +97,6 @@ impl DeckSettings {
|
||||
forward: "".to_string(),
|
||||
backward: "".to_string(),
|
||||
filter: "true".to_string(),
|
||||
count: None,
|
||||
open_mode: OrderMode::Default,
|
||||
}
|
||||
}
|
||||
pub fn check_filter(&self) -> bool {
|
||||
@@ -110,50 +106,6 @@ impl DeckSettings {
|
||||
info!("Compile time is {:?}", time.elapsed());
|
||||
ast.is_ok()
|
||||
}
|
||||
pub fn get_word_list(&self, state: &AppState) -> Vec<usize> {
|
||||
todo!()
|
||||
// let time = Instant::now();
|
||||
// let mut list = vec![];
|
||||
// let engine = Engine::new();
|
||||
//
|
||||
// let ast = engine.compile(&self.filter);
|
||||
// if let Ok(ast) = ast {
|
||||
// let groups = state.word_groups.read();
|
||||
// let query = state
|
||||
// .dictionary.read().query_par(| word: &WordData|{
|
||||
// let mut more = rhai::Map::new();
|
||||
// for iced in &word.additional {
|
||||
// more.insert(iced.0.clone().into(), iced.1.clone().into());
|
||||
// }
|
||||
// let mut scope = Scope::new();
|
||||
// let group_name = groups.get_ref(&mut groups.handle_by_id(word.group_id)).unwrap().name;
|
||||
//
|
||||
// scope
|
||||
// .push_constant("id", word.id.0 as i64)
|
||||
// .push_constant("key", word.key.clone())
|
||||
// .push_constant("value", word.value.clone())
|
||||
// .push_constant("tags", word.tags.clone())
|
||||
// .push_constant("more", more)
|
||||
// .push_constant(
|
||||
// "group",
|
||||
// group_name,
|
||||
// );
|
||||
//
|
||||
// let result = engine.eval_ast_with_scope::<bool>(&mut scope, &ast);
|
||||
// if let Ok(result) = result {
|
||||
// return result;
|
||||
// }
|
||||
// false
|
||||
// });
|
||||
//
|
||||
//
|
||||
// info!("Collecting available words is {:?}", time.elapsed());
|
||||
//
|
||||
// list
|
||||
// } else {
|
||||
// list
|
||||
// }
|
||||
}
|
||||
pub fn require_speech(&self) -> bool {
|
||||
self.forward == "speech" || self.backward == "speech"
|
||||
}
|
||||
@@ -213,7 +165,6 @@ pub struct CustomField {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Copy)]
|
||||
pub struct EntityHandle<E> {
|
||||
pub(crate) id: Id,
|
||||
index: u32,
|
||||
@@ -229,6 +180,7 @@ impl<T> Clone for EntityHandle<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<T> Copy for EntityHandle<T> {}
|
||||
impl<T> EntityHandle<T> {
|
||||
pub fn new(id: Id, index: usize, real: bool) -> Self {
|
||||
Self {
|
||||
@@ -280,6 +232,13 @@ impl<T> Ord for EntityHandle<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Hash for EntityHandle<T> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.id.hash(state);
|
||||
self.real().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait EntityData {
|
||||
fn id(&self) -> Id;
|
||||
fn set_id(&mut self, id: Id);
|
||||
|
||||
Reference in new issue
Block a user