aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 5275321..3cae322 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,8 +27,14 @@ fn generate_index(input_path : &str, index_path : &str) {
let mut nof_handle : Option<_> = Some(s.spawn(|| filecount(input_path)));
for entry in WalkDir::new(input_path).into_iter().filter_map(|e| e.ok()) {
+ counter += 1;
if entry.path().is_file() {
let content : String = text::extract_text(entry.path().to_str().unwrap());
+
+ if content.is_empty() {
+ continue
+ }
+
let words : Vec<String> = splitter::split_to_words(content);
for word in words.iter() {
@@ -38,8 +44,6 @@ fn generate_index(input_path : &str, index_path : &str) {
let fv = dict.vectorize_word_list(words.clone());
writeln!(index_file, "{}, {}", entry.path().to_str().unwrap().replace(",", "\0"), fv.to_hex()).ok();
- counter += 1;
-
match nof_handle {
Some(t) => {
@@ -47,14 +51,14 @@ fn generate_index(input_path : &str, index_path : &str) {
nof_handle = None;
}
None => {
- print!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof);
+ eprint!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof);
std::io::stdout().flush().ok();
}
}
}
}
- println!("\r\x1b[2K{} of {} files indexed ({}%)", counter, nof, (counter * 100) / nof);
+ eprintln!("\r\x1b[2Kall files indexed (100%)");
let dict_list : Vec<String> = dict.to_list();
writeln!(index_file, "#{}", dict_list.join(",")).ok();
@@ -105,6 +109,6 @@ fn search(index_path : &str, search_args : Vec<&str>) {
fn main() {
println!("Generating Index...");
generate_index("/home/n8", "index.idxs");
- //println!("Searching...");
- //search("index.idxs", vec!["one", "difficult", "under", "linux"]);
+ println!("Searching...");
+ search("index.idxs", vec!["welt"]);
}