| Crates.io | arcweight |
| lib.rs | arcweight |
| version | 0.1.0 |
| created_at | 2025-10-16 18:33:05.068788+00 |
| updated_at | 2025-10-16 18:33:05.068788+00 |
| description | A high-performance, modular library for weighted finite state transducers with comprehensive examples and benchmarks |
| homepage | https://github.com/aaronstevenwhite/arcweight |
| repository | https://github.com/aaronstevenwhite/arcweight |
| max_upload_size | |
| id | 1886520 |
| size | 2,036,030 |
A high-performance Rust library for weighted finite-state transducers with comprehensive semiring support.
ArcWeight provides efficient algorithms for constructing, combining, and optimizing weighted finite-state transducers (WFSTs), making it suitable for natural language processing, speech recognition, and computational linguistics applications.
Add ArcWeight to your Cargo.toml:
[dependencies]
arcweight = "0.1"
use arcweight::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a simple FST
let mut fst = VectorFst::<TropicalWeight>::new();
// Add states
let s0 = fst.add_state();
let s1 = fst.add_state();
let s2 = fst.add_state();
// Set start and final states
fst.set_start(s0);
fst.set_final(s2, TropicalWeight::one());
// Add arcs
fst.add_arc(s0, Arc::new(1, 1, TropicalWeight::one(), s1));
fst.add_arc(s1, Arc::new(2, 2, TropicalWeight::one(), s2));
// Perform operations
let minimized = minimize(&fst)?;
println!("Original states: {}", fst.num_states());
println!("Minimized states: {}", minimized.num_states());
Ok(())
}
ArcWeight includes comprehensive examples demonstrating real-world applications:
# String edit distance
cargo run --example edit_distance
# Spell checking and correction
cargo run --example spell_checking
# Morphological analysis
cargo run --example morphological_analyzer
# Phonological rules
cargo run --example phonological_rules
# Text normalization
cargo run --example number_date_normalizer
See the examples/ directory for complete implementations with detailed explanations.
ArcWeight requires Rust 1.85.0 or later.
The MSRV is explicitly tested in CI and will only be increased in minor version updates. When the MSRV is increased, the previous two stable releases will still be supported for six months.
ArcWeight is designed for high performance:
Run benchmarks on your system:
cargo bench
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Quick checklist:
cargo fmt)cargo test)cargo doc)cargo clippy)Licensed under the Apache License, Version 2.0. See LICENSE for details.
If you use ArcWeight in your research, please cite:
@software{arcweight,
author = {White, Aaron Steven},
title = {ArcWeight: A Rust Library for Weighted Finite-State Transducers},
url = {https://github.com/aaronstevenwhite/arcweight},
year = {2025}
}
ArcWeight implements algorithms based on: