use of org.eol.globi.taxon.TaxonCacheService in project eol-globi-data by jhpoelen.
the class Normalizer method resolveAndLinkTaxa.
private void resolveAndLinkTaxa(CommandLine cmdLine, GraphDatabaseService graphService) {
if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_RESOLVE_CITATIONS)) {
LOG.info("resolving citations to DOIs ...");
new LinkerDOI(graphService, new DOIResolverCache()).link();
new LinkerDOI(graphService).link();
} else {
LOG.info("skipping citation resolving ...");
}
if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_TAXON_CACHE)) {
LOG.info("resolving names with taxon cache ...");
final TaxonCacheService taxonCacheService = new TaxonCacheService("/taxa/taxonCache.tsv.gz", "/taxa/taxonMap.tsv.gz");
try {
ResolvingTaxonIndex index = new ResolvingTaxonIndex(taxonCacheService, graphService);
index.setIndexResolvedTaxaOnly(true);
TaxonFilter taxonCacheFilter = new TaxonFilter() {
private KnownBadNameFilter knownBadNameFilter = new KnownBadNameFilter();
@Override
public boolean shouldInclude(Taxon taxon) {
return taxon != null && knownBadNameFilter.shouldInclude(taxon);
}
};
new NameResolver(graphService, index, taxonCacheFilter).resolve();
LOG.info("adding same and similar terms for resolved taxa...");
List<Linker> linkers = new ArrayList<>();
linkers.add(new LinkerTermMatcher(graphService, taxonCacheService));
appendOpenTreeTaxonLinker(graphService, linkers);
linkers.forEach(LinkUtil::doTimedLink);
LOG.info("adding same and similar terms for resolved taxa done.");
} finally {
taxonCacheService.shutdown();
}
LOG.info("resolving names with taxon cache done.");
} else {
LOG.info("skipping taxon cache ...");
}
if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_RESOLVE)) {
new NameResolver(graphService, new NonResolvingTaxonIndex(graphService)).resolve();
new TaxonInteractionIndexer(graphService).index();
} else {
LOG.info("skipping taxa resolving ...");
}
if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_LINK)) {
List<Linker> linkers = new ArrayList<>();
linkers.add(new LinkerTaxonIndex(graphService));
linkers.forEach(LinkUtil::doTimedLink);
} else {
LOG.info("skipping linking ...");
}
if (cmdLine == null || !cmdLine.hasOption(OPTION_SKIP_LINK_THUMBNAILS)) {
LinkUtil.doTimedLink(new ImageLinker(graphService, null));
} else {
LOG.info("skipping linking of taxa to thumbnails ...");
}
}
use of org.eol.globi.taxon.TaxonCacheService in project eol-globi-data by jhpoelen.
the class LinkerTermMatcherTest method homoSapiensCachedTaxa.
@Test
public void homoSapiensCachedTaxa() throws NodeFactoryException, PropertyEnricherException {
taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null));
TaxonCacheService taxonCacheService = new TaxonCacheService("classpath:/org/eol/globi/taxon/taxonCache.tsv", "classpath:/org/eol/globi/taxon/taxonMap.tsv");
new LinkerTermMatcher(getGraphDb(), taxonCacheService).link();
LinkerTestUtil.assertHasOther("Homo sapiens", 2, taxonIndex, RelTypes.SAME_AS);
}
Aggregations