Skip to content

Commit

Permalink
Improve DOI fetcher accuracy even more as long as we don't have a LaT…
Browse files Browse the repository at this point in the history
…eX-free version #1424
  • Loading branch information
stefan-kolb committed May 31, 2016
1 parent fa51c7f commit 1e7be49
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/main/java/net/sf/jabref/importer/fetcher/CrossRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Optional;

import net.sf.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter;
import net.sf.jabref.logic.layout.format.LatexToUnicodeFormatter;
import net.sf.jabref.logic.util.DOI;
import net.sf.jabref.model.entry.BibEntry;

Expand Down Expand Up @@ -81,7 +82,8 @@ private static String enhanceQuery(String query, BibEntry entry) {
}

private static boolean checkValidity(BibEntry entry, JSONArray result) {
final String entryTitle = new RemoveBracesFormatter().format(entry.getField("title"));
// TODO: use latex-free version instead in the future
final String entryTitle = removeLaTeX(entry.getField("title"));

// currently only title-based
// title: [ "How the Mind Hurts and Heals the Body." ]
Expand Down Expand Up @@ -109,7 +111,18 @@ private static boolean checkValidity(BibEntry entry, JSONArray result) {
}
}

private static String removeLaTeX(String text) {
String result;
// remove braces
result = new RemoveBracesFormatter().format(text);
// convert to unicode
result = new LatexToUnicodeFormatter().format(result);

return result;
}

private static double editDistanceIgnoreCase(String a, String b) {
// TODO: locale is dependent on the language of the strings?!
return METRIC_DISTANCE.distance(a.toLowerCase(Locale.ENGLISH), b.toLowerCase(Locale.ENGLISH));
}
}

0 comments on commit 1e7be49

Please sign in to comment.