Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find all common substrings

crates.io version

A method for finding all common strings. Check it on Crates.io.

The algorithm uses a two-dimensional trie to find the fragments. The vertical dimension is a standard suffix trie; nodes at the end of each suffix are also linked horizontally.

Usage

Use get_substrings to get the common substrings in a list of strings.

Example

use common_substrings::get_substrings;
let input_strings = vec!["java", "javascript", "typescript", "coffeescript", "coffee"];
let result_substrings = get_substrings(input_strings, 2, 3);

This produces results such as:

Substring(sources: {2, 3}, name: escript, weight: 14)
Substring(sources: {1, 0}, name: java, weight: 8)
Substring(sources: {4, 3}, name: coffee, weight: 12)

Arguments

  • input — The input strings.
  • min_occurrences — The minimum number of input strings containing a result.
  • min_length — The minimum result length, measured in Unicode scalar values.

Both thresholds must be positive. When min_occurrences exceeds the input size, the result is empty.

The minimum supported Rust version is 1.86.

Algorithm

Explanation here

Other implementations

License

Apache-2.0

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages