fn extract_sequences(phrases: &[Phrase]) -> Vec<RepeatedSequence> {
    let max_words_per_phrase = phrases
        .iter()
        .map(|phrase| phrase.words().len())
        .max()
        .unwrap();

    (1..=max_words_per_phrase)
        .flat_map(|length| extract_sequences_with_length(phrases, length))
        .sorted_by_key(|sequence| {
            let letters_per_instance: usize = sequence.words.iter().map(|tag| tag.len()).sum();
            let total_letters = letters_per_instance * sequence.instances.len();
            Reverse((sequence.words.len(), total_letters))
        })
        .collect_vec()
}
/// Extract all sequences of one or more words that repeat at least twice in the phrases.
/// The sequences are sorted by descending word length first and then total number of letters in all
/// instances.
Extract all sequences of one or more words that repeat at least twice in the phrases.
The sequences are sorted by descending word length first and then total number of letters in all
instances.
Extract all sequences of one or more words that repeat at least twice in the phrases . The sequences are sorted by descending word length first and then total number of letters in all instances .
fn extract_sequences(phrases: &[Phrase]) -> Vec<RepeatedSequence> {
    let max_words_per_phrase = phrases
        .iter()
        .map(|phrase| phrase.words().len())
        .max()
        .unwrap();
    (1..=max_words_per_phrase)
        .flat_map(|length| extract_sequences_with_length(phrases, length))
        .sorted_by_key(|sequence| {
            let letters_per_instance: usize = sequence.words.iter().map(|tag| tag.len()).sum();
            let total_letters = letters_per_instance * sequence.instances.len();
            Reverse((sequence.words.len(), total_letters))
        })
        .collect_vec()
}
fn extract_sequences ( phrases : & [ Phrase ] ) -> Vec < RepeatedSequence > { let max_words_per_phrase = phrases . iter ( ) . map ( | phrase | phrase . words ( ) . len ( ) ) . max ( ) . unwrap ( ) ; ( 1 ..= max_words_per_phrase ) . flat_map ( | length | extract_sequences_with_length ( phrases , length ) ) . sorted_by_key ( | sequence | { let letters_per_instance : usize = sequence . words . iter ( ) . map ( | tag | tag . len ( ) ) . sum ( ) ; let total_letters = letters_per_instance * sequence . instances . len ( ) ; Reverse ( ( sequence . words . len ( ) , total_letters ) ) } ) . collect_vec ( ) }
Extract all sequences of one or more words that repeat at least twice in the phrases.
Extract all sequences of one or more words that repeat at least twice in the phrases .
phrases
&[Phrase]
phrases
&[Phrase]