Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.21 KB

README.md

File metadata and controls

44 lines (31 loc) · 1.21 KB

Simplified Fuzzy Phrase Matching Library

Powered by second String Project(SoftTFIDF)

Example

package com.github.kayr.phrasematcher;

import java.util.Arrays;
import java.util.List;
import com.github.kayr.phrasematcher.PhraseMatcher;

public class XX {
   
    public static void main(String[] args) {
        List<String> strings = Arrays.asList(
                "This is a dog",
                "Dog this is",
                "This is a cat",
                "Some other phrase",
                "And another phrase"
        );

        PhraseMatcher matcher = PhraseMatcher.train(strings);


        //Hits above 50%
        PhraseMatcher.MatchResult result = matcher.bestHit("Ths is a dig", 0.5);
        System.out.println(result);
        //Output 
        //MatchResult{phrase='This is a dog', score=0.5023550489416228}


        //Get hits about 35%
        List<PhraseMatcher.MatchResult> results = matcher.bestHitList("Ths is a dig", 0.35);
        System.out.println(results);
        //Output
        //[MatchResult{phrase='This is a dog', score=0.5023550489416228}, MatchResult{phrase='Dog this is', score=0.35163044073961364}, MatchResult{phrase='This is a cat', score=0.374913839423641}]

    }
}