Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bee-san
Created July 23, 2022 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bee-san/dc91da3e78d32ba42f88148ec3d6857e to your computer and use it in GitHub Desktop.
Save bee-san/dc91da3e78d32ba42f88148ec3d6857e to your computer and use it in GitHub Desktop.
line 36 is the problem
use log::{debug, info, trace};
use crate::checkers::checker_type::{CheckerType, Check};
impl EnglishChecker {
pub fn new() -> Self {
Self {
checker_type: CheckerType {
name: "English Checker",
description: "This checker checks if the text is english looping over a dictionary",
link: "https://en.wikipedia.org/wiki/English_language",
tags: vec!["english", "dictionary"],
/// Expected runtime is higher as this is a O(n) checker
expected_runtime: 0.01,
/// Popularity is max because English is the most popular
/// Plaintext language in the world.
popularity: 1.0,
..Default::default()
}
}
}
}
/// given an input, check every item in the array and return true if any of them match
impl Check for EnglishChecker {
fn check(&self, input: &str) -> CheckResult {
if let Some(result) = storage::DICTIONARIES
.iter()
.find(|(_, words)| words.contains(input))
{
// result.0 is filename
return CheckResult {
is_identified: true,
text: input,
checker: EnglishChecker::new(),
};
}
None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment