feat(codegen): collected video duration samples

This commit is contained in:
ThetaDev 2023-05-06 21:12:49 +02:00
parent 19781eab36
commit 800073df48
14 changed files with 7325 additions and 1449 deletions

View file

@ -1,13 +1,13 @@
use std::fmt::Write;
use std::path::Path;
use once_cell::sync::Lazy;
use path_macro::path;
use regex::Regex;
use rustypipe::timeago::TimeUnit;
use crate::util;
const TARGET_PATH: &str = "src/util/dictionary.rs";
use crate::{
model::TimeUnit,
util::{self, SRC_DIR},
};
fn parse_tu(tu: &str) -> (u8, Option<TimeUnit>) {
static TU_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(\d*)(\w?)$").unwrap());
@ -30,8 +30,8 @@ fn parse_tu(tu: &str) -> (u8, Option<TimeUnit>) {
}
}
pub fn generate_dictionary(project_root: &Path) {
let dict = util::read_dict(project_root);
pub fn generate_dictionary() {
let dict = util::read_dict();
let code_head = r#"// This file is automatically generated. DO NOT EDIT.
// See codegen/gen_dictionary.rs for the generation code.
@ -169,7 +169,6 @@ pub(crate) fn entry(lang: Language) -> Entry {
let code = format!("{code_head}\n{code_timeago_tokens}");
let mut target_path = project_root.to_path_buf();
target_path.push(TARGET_PATH);
let target_path = path!(*SRC_DIR / "util" / "dictionary.rs");
std::fs::write(target_path, code).unwrap();
}