Skip to content

Commit

Permalink
feat: compress data at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed May 20, 2024
1 parent b39957e commit e9f801c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ required-features = ["tfidf", "textrank"]
cedarwood = "0.4"
derive_builder = { version = "0.20.0", optional = true }
fxhash = "0.2.1"
include-flate = "0.3.0"
lazy_static = "1.0"
ordered-float = { version = "4.0", optional = true }
phf = "0.11"
Expand All @@ -45,8 +46,4 @@ tfidf = ["dep:ordered-float", "dep:derive_builder"]
textrank = ["dep:ordered-float", "dep:derive_builder"]

[workspace]
members = [
".",
"capi",
"examples/weicheng"
]
members = [".", "capi", "examples/weicheng"]
3 changes: 2 additions & 1 deletion src/keywords/tfidf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ use std::cmp::Ordering;
use std::collections::{BTreeSet, BinaryHeap};
use std::io::{self, BufRead, BufReader};

use include_flate::flate;
use ordered_float::OrderedFloat;

use super::{Keyword, KeywordExtract, KeywordExtractConfig, KeywordExtractConfigBuilder};
use crate::FxHashMap as HashMap;
use crate::Jieba;

static DEFAULT_IDF: &str = include_str!("../data/idf.txt");
flate!(static DEFAULT_IDF: str from "src/data/idf.txt");

#[derive(Debug, Clone, Eq, PartialEq)]
struct HeapNode<'a> {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
//! ```
//!
use include_flate::flate;
use lazy_static::lazy_static;

use std::cmp::Ordering;
Expand All @@ -97,7 +98,7 @@ mod keywords;
mod sparse_dag;

#[cfg(feature = "default-dict")]
static DEFAULT_DICT: &str = include_str!("data/dict.txt");
flate!(static DEFAULT_DICT: str from "src/data/dict.txt");

use sparse_dag::StaticSparseDAG;

Expand Down

0 comments on commit e9f801c

Please sign in to comment.