This commit is contained in:
ldlda committed 2025-01-08 03:59:41 +07:00
1 parent fbe0743d27
commit 726104fd54
3 files changed
+4 -5

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
[package] [package]
name = "lda_levenshtein" name = "lda_strdist"
version = "0.0.1" version = "0.0.1"
edition = "2021" edition = "2021"
+2 -2
View File
@@ -167,7 +167,7 @@ pub fn levenshtein_with_operations(
(dp[len1][len2].cost, dp) (dp[len1][len2].cost, dp)
} }
pub fn edit_sequence(dp: &Vec<Vec<CostOperation>>, str1: &str, str2: &str) -> Vec<EditOperation> { pub fn edit_sequence(dp: &[Vec<CostOperation>], str1: &str, str2: &str) -> Vec<EditOperation> {
let mut i = str1.len(); let mut i = str1.len();
let mut j = str2.len(); let mut j = str2.len();
let mut funny = vec![]; let mut funny = vec![];
@@ -202,7 +202,7 @@ pub fn edit_sequence(dp: &Vec<Vec<CostOperation>>, str1: &str, str2: &str) -> Ve
pub fn generate_alignment( pub fn generate_alignment(
str1: &str, str1: &str,
str2: &str, str2: &str,
operations: &Vec<Vec<CostOperation>>, operations: &[Vec<CostOperation>],
) -> (String, String) { ) -> (String, String) {
let mut aligned_str1 = String::new(); let mut aligned_str1 = String::new();
let mut aligned_str2 = String::new(); let mut aligned_str2 = String::new();
+1 -2
View File
@@ -1,6 +1,6 @@
use std::fmt::Display; use std::fmt::Display;
use lda_levenshtein::*; use lda_strdist::*;
struct EditOperationVec<'e>(&'e Vec<EditOperation>); struct EditOperationVec<'e>(&'e Vec<EditOperation>);
@@ -29,7 +29,6 @@ fn main() {
reconstruct_to(&reconstructed) reconstruct_to(&reconstructed)
); );
let (d2, dp) = levenshtein_with_operations(str1, str2, &EditCost::default()); let (d2, dp) = levenshtein_with_operations(str1, str2, &EditCost::default());
assert!(d2 == distance); assert!(d2 == distance);
let (al1, al2) = generate_alignment(str1, str2, &dp); let (al1, al2) = generate_alignment(str1, str2, &dp);