当前位置: 首页>>代码示例>>Java>>正文


Java MeaningSpan类代码示例

本文整理汇总了Java中org.aksw.gerbil.transfer.nif.MeaningSpan的典型用法代码示例。如果您正苦于以下问题:Java MeaningSpan类的具体用法?Java MeaningSpan怎么用?Java MeaningSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MeaningSpan类属于org.aksw.gerbil.transfer.nif包,在下文中一共展示了MeaningSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseJsonStream

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
private List<MeaningSpan> parseJsonStream(InputStream in) throws IOException, ParseException {
    List<MeaningSpan> annotations = new ArrayList<>();

    JSONArray namedEntities = (JSONArray) this.jsonParser.parse(new InputStreamReader(in, "UTF-8"));
    JSONObject namedEntity;
    String url;
    long start, length;
    for (Object obj : namedEntities) {
        namedEntity = (JSONObject) obj;

        start = (long) namedEntity.get("start");
        length = (long) namedEntity.get("offset");

        url = (String) namedEntity.get("disambiguatedURL");
        if (url == null) {
            annotations.add(new NamedEntity((int) start, (int) length, new HashSet<String>()));
        } else {
            annotations.add(new NamedEntity((int) start, (int) length, URLDecoder.decode(url, "UTF-8")));
        }
    }

    return annotations;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:24,代码来源:AgdistisAnnotator.java

示例2: performD2KBTask

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performD2KBTask(SingleInstanceSecuringAnnotatorDecorator decorator,
        Document document) throws GerbilException {
    List<MeaningSpan> result = null;
    try {
        decorator.semaphore.acquire();
    } catch (InterruptedException e) {
        LOGGER.error("Interrupted while waiting for the Annotator's semaphore.", e);
        throw new GerbilException("Interrupted while waiting for the Annotator's semaphore.", e,
                ErrorTypes.UNEXPECTED_EXCEPTION);
    }
    try {
        result = ((D2KBAnnotator) decorator.getDecoratedAnnotator()).performD2KBTask(document);
    } finally {
        decorator.semaphore.release();
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:18,代码来源:SingleInstanceSecuringAnnotatorDecorator.java

示例3: performExtraction

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performExtraction(SingleInstanceSecuringAnnotatorDecorator decorator,
        Document document) throws GerbilException {
    List<MeaningSpan> result = null;
    try {
        decorator.semaphore.acquire();
    } catch (InterruptedException e) {
        LOGGER.error("Interrupted while waiting for the Annotator's semaphore.", e);
        throw new GerbilException("Interrupted while waiting for the Annotator's semaphore.", e,
                ErrorTypes.UNEXPECTED_EXCEPTION);
    }
    try {
        result = ((A2KBAnnotator) decorator.getDecoratedAnnotator()).performA2KBTask(document);
    } finally {
        decorator.semaphore.release();
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:18,代码来源:SingleInstanceSecuringAnnotatorDecorator.java

示例4: performD2KBTask

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performD2KBTask(ErrorCountingAnnotatorDecorator errorCounter, Document document)
        throws GerbilException {
    List<MeaningSpan> result = null;
    try {
        result = ((D2KBAnnotator) errorCounter.getDecoratedAnnotator()).performD2KBTask(document);
    } catch (Exception e) {
        if (errorCounter.getErrorCount() == 0) {
            // Log only the first exception completely
            LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + ")", e);
        } else {
            // Log only the Exception message without the stack trace
            LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + "): "
                    + e.getLocalizedMessage());
        }
        errorCounter.increaseErrorCount();
        return new ArrayList<MeaningSpan>(0);
    }
    if (printDebugMsg && LOGGER.isDebugEnabled()) {
        logResult(result, errorCounter.getName(), "MeaningSpan");
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:ErrorCountingAnnotatorDecorator.java

示例5: performExtraction

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performExtraction(ErrorCountingAnnotatorDecorator errorCounter, Document document)
        throws GerbilException {
    List<MeaningSpan> result = null;
    try {
        result = ((A2KBAnnotator) errorCounter.getDecoratedAnnotator()).performA2KBTask(document);
    } catch (Exception e) {
        if (errorCounter.getErrorCount() == 0) {
            // Log only the first exception completely
            LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + ")", e);
        } else {
            // Log only the Exception message without the stack trace
            LOGGER.error("Got an Exception from the annotator (" + errorCounter.getName() + "): "
                    + e.getLocalizedMessage());
        }
        errorCounter.increaseErrorCount();
        return new ArrayList<MeaningSpan>(0);
    }
    if (printDebugMsg && LOGGER.isDebugEnabled()) {
        logResult(result, errorCounter.getName(), "MeaningSpan");
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:ErrorCountingAnnotatorDecorator.java

示例6: searchFirstOccurrence

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
/**
 * Searches the {@link MeaningSpan} that a) occurs first inside the document
 * and b) has the given URI as meaning.
 * 
 * @param uri
 *            the meaning the searched marking should have
 * @param document
 *            the document in which the marking should be searched
 * @return the first occurrence of a meaning with the given URI in the text
 *         or null if such a marking couldn't be found.
 */
public static MeaningSpan searchFirstOccurrence(String uri, Document document) {
	List<MeaningSpan> entities = document.getMarkings(MeaningSpan.class);
	MeaningSpan result = null;
	for (MeaningSpan marking : entities) {
		if (marking.containsUri(uri)) {
			if ((result == null) || (marking.getStartPosition() < result.getStartPosition())) {
				result = marking;
			}
		}
	}
	return result;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:24,代码来源:DocumentHelper.java

示例7: translateAnnotations

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
public List<MeaningSpan> translateAnnotations(Set<it.unipi.di.acube.batframework.data.Annotation> annotations) {
    List<MeaningSpan> markings = new ArrayList<MeaningSpan>();
    if (annotations != null) {
        for (it.unipi.di.acube.batframework.data.Annotation a : annotations) {
            if (a instanceof it.unipi.di.acube.batframework.data.ScoredAnnotation) {
                markings.add(translate((it.unipi.di.acube.batframework.data.ScoredAnnotation) a));
            } else {
                markings.add(translate(a));
            }
        }
    }
    return markings;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:14,代码来源:BAT2NIF_TranslationHelper.java

示例8: performD2KBTask

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performD2KBTask(TimeMeasuringAnnotatorDecorator timeMeasurer, Document document)
        throws GerbilException {
    long startTime = System.currentTimeMillis();
    List<MeaningSpan> result = null;
    result = ((D2KBAnnotator) timeMeasurer.getDecoratedAnnotator()).performD2KBTask(document);
    timeMeasurer.addCallRuntime(System.currentTimeMillis() - startTime);
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:9,代码来源:TimeMeasuringAnnotatorDecorator.java

示例9: performExtraction

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
protected static List<MeaningSpan> performExtraction(TimeMeasuringAnnotatorDecorator timeMeasurer, Document document)
        throws GerbilException {
    long startTime = System.currentTimeMillis();
    List<MeaningSpan> result = null;
    result = ((A2KBAnnotator) timeMeasurer.getDecoratedAnnotator()).performA2KBTask(document);
    timeMeasurer.addCallRuntime(System.currentTimeMillis() - startTime);
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:9,代码来源:TimeMeasuringAnnotatorDecorator.java

示例10: createClassifiedMeaning

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
public static ClassifiedMarking createClassifiedMeaning(Marking marking) {
    if (marking instanceof ScoredNamedEntity) {
        ScoredNamedEntity sne = (ScoredNamedEntity) marking;
        return new ClassifiedScoredNamedEntity(sne.getStartPosition(), sne.getLength(), sne.getUris(),
                sne.getConfidence());
    } else if (marking instanceof MeaningSpan) {
        MeaningSpan ne = (MeaningSpan) marking;
        return new ClassifiedNamedEntity(ne.getStartPosition(), ne.getLength(), ne.getUris());
    } else if (marking instanceof Meaning) {
        return new ClassifiedAnnotation(((Meaning) marking).getUris());
    }
    return null;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:14,代码来源:ClassifiedMarkingFactory.java

示例11: printDatasetUris

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
private static void printDatasetUris(Dataset dataset, PrintStream pout) {
    for (Document document : dataset.getInstances()) {
        String text = document.getText();
        for (MeaningSpan meaning : document.getMarkings(MeaningSpan.class)) {
            for (String uri : meaning.getUris()) {
                pout.print(uri);
                pout.print('\t');
                pout.print(text.substring(meaning.getStartPosition(),
                        meaning.getStartPosition() + meaning.getLength()));
                pout.println();
            }
        }
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:15,代码来源:UriExport.java

示例12: createEvaluator

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
public Evaluator createEvaluator(ExperimentType type, ExperimentTaskConfiguration configuration, Dataset dataset,
        UriKBClassifier globalClassifier, SubClassInferencer inferencer) {
    switch (type) {
    case D2KB: {
        return new SearcherBasedNotMatchingMarkingFilter<MeaningSpan>(
                new StrongSpanMatchingsSearcher<MeaningSpan>(),
                new ClassifyingEvaluatorDecorator<MeaningSpan, ClassifiedSpanMeaning>(
                        new GSInKBClassifyingEvaluatorDecorator<ClassifiedSpanMeaning>(
                                new ClassConsideringFMeasureCalculator<ClassifiedSpanMeaning>(
                                        new MatchingsCounterImpl<ClassifiedSpanMeaning>(
                                                new CompoundMatchingsSearcher<ClassifiedSpanMeaning>(
                                                        (MatchingsSearcher<ClassifiedSpanMeaning>) MatchingsSearcherFactory
                                                                .createSpanMatchingsSearcher(
                                                                        configuration.matching),
                                                        new ClassifiedMeaningMatchingsSearcher<ClassifiedSpanMeaning>())),
                                        MarkingClasses.IN_KB, MarkingClasses.EE, MarkingClasses.GS_IN_KB),
                                new StrongSpanMatchingsSearcher<ClassifiedSpanMeaning>()),
                        new UriBasedMeaningClassifier<ClassifiedSpanMeaning>(globalClassifier, MarkingClasses.IN_KB),
                        new EmergingEntityMeaningClassifier<ClassifiedSpanMeaning>()),
                true);
    }
    case Sa2KB:
    case A2KB:
    case C2KB:
    case ERec:
    case ETyping:
    case OKE_Task1:
    case OKE_Task2:
    default: {
        throw new IllegalArgumentException("Got an unknown Experiment Type.");
    }
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:36,代码来源:SimpleSingleD2KBRun.java

示例13: test

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test() {
    Evaluator<MeaningSpan> evaluator = new ClassifyingEvaluatorDecorator<MeaningSpan, ClassifiedSpanMeaning>(this,
            new UriBasedMeaningClassifier<ClassifiedSpanMeaning>(CLASSIFIER, MarkingClasses.IN_KB));
    evaluator.evaluate(Arrays.asList(Arrays.asList(annotatorResponse)), Arrays.asList(Arrays.asList(goldStandard)),
            null);
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:9,代码来源:InKBClassifyingEvaluatorDecoratorTest.java

示例14: test

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test() {
    Evaluator<MeaningSpan> evaluator = new ClassifyingEvaluatorDecorator<MeaningSpan, ClassifiedSpanMeaning>(
            new GSInKBClassifyingEvaluatorDecorator<ClassifiedSpanMeaning>(this,
                    new StrongSpanMatchingsSearcher<ClassifiedSpanMeaning>()),
            new UriBasedMeaningClassifier<ClassifiedSpanMeaning>(CLASSIFIER, MarkingClasses.IN_KB),
            new EmergingEntityMeaningClassifier<ClassifiedSpanMeaning>());
    evaluator.evaluate(Arrays.asList(Arrays.asList(annotatorResponse)), Arrays.asList(Arrays.asList(goldStandard)),
            null);
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:12,代码来源:GSInKBClassifyingEvaluatorDecoratorTest.java

示例15: test

import org.aksw.gerbil.transfer.nif.MeaningSpan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test() {
    Evaluator<MeaningSpan> evaluator = new ClassifyingEvaluatorDecorator<MeaningSpan, ClassifiedSpanMeaning>(this,
            new UriBasedMeaningClassifier<ClassifiedSpanMeaning>(CLASSIFIER, MarkingClasses.IN_KB),
            new EmergingEntityMeaningClassifier<ClassifiedSpanMeaning>());
    evaluator.evaluate(Arrays.asList(Arrays.asList(annotatorResponse)), Arrays.asList(Arrays.asList(goldStandard)),
            null);
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:10,代码来源:EEClassifyingEvaluatorDecoratorTest.java


注:本文中的org.aksw.gerbil.transfer.nif.MeaningSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。