本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
示例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.");
}
}
}
示例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);
}
示例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);
}
示例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);
}