cyk

Crates.iocyk
lib.rscyk
version0.1.0
sourcesrc
created_at2020-09-13 23:27:33.477145
updated_at2020-09-13 23:27:33.477145
descriptionA modified CYK algorithm to work for Language.
homepage
repository
max_upload_size
id288381
size17,656
gluax (gluax)

documentation

README

** COMMENT Use case :PROPERTIES: :CUSTOM_ID: use-case :END:

#+BEGIN_EXAMPLE struct G {}

impl<'grammar> Grammar<'grammar> for G { fn convert(&self) -> Vec<GrammarRule<'grammar>> { let mut rules = Vec::new(); rules.push(GrammarRule{ left_symbol: "ActionSentence", right_symbol: "Verb NounClause | Verb NounClause PrepClause" }); rules.push(GrammarRule{ left_symbol: "NounClause", right_symbol: "Count ANoun | Adjective Noun" }); rules.push(GrammarRule{ left_symbol: "PrepClause", right_symbol: "Prep NounClause" }); rules.push(GrammarRule{ left_symbol: "ANoun", right_symbol: "Adjective Noun" }); rules.push(GrammarRule{ left_symbol: "Adjective", right_symbol: "adjective" }); rules.push(GrammarRule{ left_symbol: "Prep", right_symbol: "prep" }); rules.push(GrammarRule{ left_symbol: "Verb", right_symbol: "verb" }); rules.push(GrammarRule{ left_symbol: "Noun", right_symbol: "noun" }); rules.push(GrammarRule{ left_symbol: "Count", right_symbol: "definiteArticle | indefiniteArticle | number" }); rules } }

struct WB {}

impl WordBank for WB { fn lookup(&self, word: &str) -> &str { match word { "examine" => "verb", "sword" => "noun", "rusty" => "adjective", _ => "dne" } } }

fn main() { let g = G{}; let wb = WB{}; let input = "examine rusty sword"; let cyk: CYK = CYK::new(g, wb); let res = cyk.memoized_parse(input); println!("{}", res); println!("final_res: {:?}", res.get_final()); } #+END_EXAMPLE

That's more code up front, but now the mod and use process is automatic. Add as many Rust files to =util= as you desire; the =use_glob= method will pick up and import all of them.\ To see an example using this directory structure, see [[https://github.com/Shizcow/proc_use/tree/master/examples/globbing][globbing]].

Commit count: 0

cargo fmt