All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.monnetproject.label.impl.LabelExtractorFactoryImpl Maven / Gradle / Ivy

Go to download

com.github.monnetproject.ontology.label OSGi Bundle from the Monnet Project's ontology.project project.

The newest version!
package eu.monnetproject.label.impl;

import aQute.bnd.annotation.component.*;
import eu.monnetproject.label.*;
import eu.monnetproject.label.custom.*;
import eu.monnetproject.label.rdf.*;
import eu.monnetproject.label.skos.*;
import eu.monnetproject.label.textcat.*;
import eu.monnetproject.label.uri.*;
import eu.monnetproject.label.xbrl.XBRLLabelExtractionPolicy;
import eu.monnetproject.lang.*;
import eu.monnetproject.ontology.*;

import java.net.*;
import java.util.*;

@Component(provide = LabelExtractorFactory.class)
public class LabelExtractorFactoryImpl implements LabelExtractorFactory {


    @Override
    public LabelExtractor getExtractor(Collection extraURIs, boolean fallback, boolean inferLang) {
        List extractors = new LinkedList();
        if (extraURIs != null) {
            for (URI uri : extraURIs) {
                extractors.add(new CustomLabelExtractionPolicy(uri));
            }
        }
        extractors.add(new RDFLabelExtractionPolicy());
        extractors.add(new SKOSLabelExtractionPolicy());
        extractors.add(new XBRLLabelExtractionPolicy());
        final TextCatInferrer inferrer = inferLang ? new TextCatInferrer() : null;
        if (fallback) {
            return new AggregateLabelExtractor(Arrays.asList(new AggregateLabelExtractor(extractors, inferrer, true), new URILabelExtractionPolicy()), inferrer);
        } else {
            return new AggregateLabelExtractor(extractors, inferrer, true);
        }
    }

    @Override
    public LabelExtractor getExtractor(List extractors, LanguageInferrer inferrer) {
        return new AggregateLabelExtractor(extractors, inferrer);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy