Initial implementation of fuzzy search (fuzzywuzzy library)
This commit is contained in:
parent
c76ad989f9
commit
4eda79211e
@ -34,5 +34,6 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: me.xdrop:fuzzywuzzy:1.3.1" level="project" />
|
||||
</component>
|
||||
</module>
|
5
pom.xml
5
pom.xml
@ -131,5 +131,10 @@
|
||||
<artifactId>unirest-java</artifactId>
|
||||
<version>3.1.02</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.xdrop</groupId>
|
||||
<artifactId>fuzzywuzzy</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -20,6 +20,8 @@ import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import kong.unirest.HttpResponse;
|
||||
import kong.unirest.Unirest;
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch;
|
||||
import me.xdrop.fuzzywuzzy.model.BoundExtractedResult;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@ -32,10 +34,7 @@ import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SteamAppsListCache {
|
||||
@ -94,7 +93,17 @@ public class SteamAppsListCache {
|
||||
}
|
||||
|
||||
public App findGame(String name) {
|
||||
for (App app : list.getSteamAppsList()) {
|
||||
List<BoundExtractedResult<App>> match = FuzzySearch.extractTop(name, list.getSteamAppsList(), app ->
|
||||
app.getName().toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", ""), 25);
|
||||
System.out.println("\n\n\n==== Top 25 results for \"" + name + "\": ====");
|
||||
for (BoundExtractedResult<App> result : match) {
|
||||
System.out.println(result.getReferent().getName() + " - " +
|
||||
result.getIndex() + " - " +
|
||||
result.getScore());
|
||||
}
|
||||
System.out.println("\n\n\n");
|
||||
return match.get(0).getReferent();
|
||||
/*for (App app : list.getSteamAppsList()) {
|
||||
if (app.getName().toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", "")
|
||||
.startsWith(name.toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", ""))) {
|
||||
return app;
|
||||
@ -105,8 +114,8 @@ public class SteamAppsListCache {
|
||||
.contains(name.toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", ""))) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
//return null;
|
||||
}
|
||||
|
||||
private void getListFromApi() {
|
||||
|
Loading…
Reference in New Issue
Block a user