parattice 0.2.2

Recursive paraphrase lattice generator
Documentation
  • Coverage
  • 16.67%
    10 out of 60 items documented7 out of 42 items with examples
  • Size
  • Source code size: 77.75 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.11 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • chrovis/parattice
    1 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vbkaisetsu

parattice: Recursive paraphrase lattice generator 🔄

This library takes a sentence and a paraphrase corpus, recursively finds paraphrases based on the corpus, expands the given sentence, and generates a paraphrase lattice.

This library also provides a method to search a phrase in the paraphrase lattice.

Example

This example generates a paraphrase lattice and searches a phrase in the generated lattice.

use parattice::Lattice;
use parattice::LatticeKMP;
use parattice::PaRattice;

// initialization
let paradict = vec![
    vec![
        vec!["blood", "stem", "cell"],
        vec!["造血", "", "細胞"],
        vec!["hematopoietic", "stem", "cell"],
    ],
    vec![
        vec!["造血", "", "細胞", "移植"],
        vec!["hematopoietic", "stem", "cell", "transplantation"],
    ],
    vec![vec!["stem", "cell"], vec!["", "細胞"]],
    vec![
        vec!["", "細胞", "移植"],
        vec!["rescue", "transplant"],
        vec!["stem", "cell", "rescue"],
    ],
    vec![vec!["rescue"], vec!["救命"]],
    vec![vec!["blood"], vec!["血液"]],
];
let parattice = PaRattice::new(paradict);

// lattice generation
let words = vec!["造血", "", "細胞", "移植"];
let lattice = parattice.get_lattice(&words, true, 2);

// dump a generated lattice
println!(lattice.dump_dot(true));

// serialization & deserialization
let bytes = lattice.to_bytes();
let new_lattice = Lattice::new_from_bytes(&bytes);

// search
let kmp = LatticeKMP::new(vec!["", "細胞"]);
let results = kmp.search(&new_lattice);
for result in &results {
    for edge in result {
        print!("({}, {}) ", edge.0, edge.1);
    }
    println!();
    let s = lattice.get_trunk_span(result.clone());
    for edge in &s {
        print!("({}, {}) ", edge.0, edge.1);
    }
    println!("\n===========");
}

Patents

License

Copyright 2020 Xcoo, Inc.

Licensed under the Apache License, Version 2.0.