Search in sources :

Example 1 with ResolvingTaxonIndex

use of org.eol.globi.taxon.ResolvingTaxonIndex 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 ...");
    }
}
Also used : TaxonCacheService(org.eol.globi.taxon.TaxonCacheService) DOIResolverCache(org.eol.globi.service.DOIResolverCache) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) Taxon(org.eol.globi.domain.Taxon) ArrayList(java.util.ArrayList) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) ResolvingTaxonIndex(org.eol.globi.taxon.ResolvingTaxonIndex)

Aggregations

ArrayList (java.util.ArrayList)1 Taxon (org.eol.globi.domain.Taxon)1 DOIResolverCache (org.eol.globi.service.DOIResolverCache)1 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)1 ResolvingTaxonIndex (org.eol.globi.taxon.ResolvingTaxonIndex)1 TaxonCacheService (org.eol.globi.taxon.TaxonCacheService)1