diff --git a/CHANGELOG.md b/CHANGELOG.md index 56b6a72c8..9adf9612d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `unset_input_symbols` and `unset_output_symbols` methods to remove the symbol tables attached to a mutable fst. - Added `emplace_arc` and `emplace_arc_unchecked` as provided methods to the `MutableFst` trait. - Added `set_symts_from_fst` to MutableFst trait to copy the SymbolTable from another `Fst`. +- Added `print_weights` field to `DrawingConfig` to avoid print weights when desired. ### Changed - Make `KDELTA` public outside of the crate diff --git a/rustfst/src/drawing_config.rs b/rustfst/src/drawing_config.rs index 000d8aee5..275112c9f 100644 --- a/rustfst/src/drawing_config.rs +++ b/rustfst/src/drawing_config.rs @@ -19,6 +19,8 @@ pub struct DrawingConfig { pub acceptor: bool, /// Print/draw arc weights and final weights equal to Weight::ONE. pub show_weight_one: bool, + /// Print/draw arc weights and final weights. + pub print_weight: bool, } impl Default for DrawingConfig { @@ -33,6 +35,7 @@ impl Default for DrawingConfig { fontsize: 14, acceptor: false, show_weight_one: true, + print_weight: true, } } } diff --git a/rustfst/src/fst_traits/serializable_fst.rs b/rustfst/src/fst_traits/serializable_fst.rs index 0c635c97c..f6841a5d6 100644 --- a/rustfst/src/fst_traits/serializable_fst.rs +++ b/rustfst/src/fst_traits/serializable_fst.rs @@ -118,7 +118,7 @@ where write!(writer, "{}", state_id)?; write!(writer, " [label = \"{}", state_id)?; if let Some(final_weight) = fst.final_weight(state_id)? { - if config.show_weight_one || !final_weight.is_one() { + if config.print_weight && (config.show_weight_one || !final_weight.is_one()) { write!(writer, "/{}", final_weight)?; } write!(writer, "\", shape = doublecircle,")?; @@ -160,7 +160,7 @@ where write!(writer, ":{}", olabel)?; } - if config.show_weight_one || !arc.weight.is_one() { + if config.print_weight && (config.show_weight_one || !arc.weight.is_one()) { write!(writer, "/{}", arc.weight)?; } writeln!(writer, "\", fontsize = {}];", config.fontsize)?;