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


Java TypedNamedEntity类代码示例

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


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

示例1: addTypeIfOverlapping

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
private void addTypeIfOverlapping(TypedNamedEntity ne, int begin, int length, String[] types) {
    int neStart = ne.getStartPosition();
    int neEnd = neStart + ne.getLength();
    int end = begin + length;
    // FIXME We should also check the overlapping with extracted type
    // strings
    if (((neStart <= begin) && (neEnd > begin)) || ((neStart < end) && (neEnd >= end))
            || ((neStart <= begin) && (neEnd >= end)) || ((neStart < end) && (neEnd > begin))) {
        for (int i = 0; i < types.length; ++i) {
            switch (types[i]) {
            case PERSON_TYPE_URI: {
                ne.getTypes().add(DOLCE_PERSON_TYPE_URI);
                break;
            }
            case LOCATION_TYPE_URI: {
                ne.getTypes().add(DOLCE_LOCATION_TYPE_URI);
                break;
            }
            case ORGANIZATION_TYPE_URI: {
                ne.getTypes().add(DOLCE_ORGANIZATION_TYPE_URI);
                break;
            }
            }
        }
    }
}
 
开发者ID:dice-group,项目名称:Cetus,代码行数:27,代码来源:FoxBasedTypeSearcher.java

示例2: extractMarkings

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
public static List<ExtendedTypedNamedEntity> extractMarkings(Document document) {
    MarkingFilter<TypedNamedEntity> filter = new TypeBasedMarkingFilter<TypedNamedEntity>(true, RDFS.Class.getURI(),
            OWL.Class.getURI());
    List<TypedNamedEntity> namedEntities = document.getMarkings(TypedNamedEntity.class);
    List<ExtendedTypedNamedEntity> extendedMarkings = new ArrayList<ExtendedTypedNamedEntity>();
    int start, length, end;
    for (TypedNamedEntity tne : namedEntities) {
        if (filter.isMarkingGood(tne)) {
            start = tne.getStartPosition();
            length = tne.getLength();
            end = start + length;
            extendedMarkings.add(new ExtendedTypedNamedEntity(start, length, tne.getUris(), new HashSet<String>(),
                    document.getText().substring(start, end)));
        }
    }
    return extendedMarkings;
}
 
开发者ID:dice-group,项目名称:Cetus,代码行数:18,代码来源:ExtendedYagoBasedTypeSearcherTest.java

示例3: findMarkings

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
protected static List<Marking> findMarkings(Set<String> lines, String text) {
	List<Marking> markings = new ArrayList<Marking>();

	for (String line : lines) {
		String[] annotation = line.split("\t");

		int start = Integer.parseInt(annotation[1]);
		int end = Integer.parseInt(annotation[2]);
		int length = end - start;
		String uri = annotation[3];
		if (uri.startsWith("NIL")) {
			uri = "";
		}
		Set<String> types = new HashSet<String>();
		types.add(getTypeURI(annotation[typeIndex]));

		markings.add(new TypedNamedEntity(start, length, uri, types));

	}

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

示例4: findMarkings

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
public static List<Marking> findMarkings(String tweet) {
	int start = 0;
	List<Marking> markings = new ArrayList<Marking>();
	realTweet = new StringBuilder();
	String[] line = tweet.split("\n");
	int i = 0;
	for (String tokenFull : line) {
		String[] token = tokenFull.split("\t+");
		realTweet.append(token[0] + " ");
		token[1] = token[1].trim();
		if (token.length>2&&token[2].startsWith("B-")) {
			String[] marking = getWholeMarking(line, i);
			Set<String> types = new HashSet<String>();
			types.add(marking[2]);
			markings.add(new TypedNamedEntity(start, marking[0].length(),
					marking[1], types));

		}
		start += token[0].length() + 1;
		i++;
	}

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

示例5: findMarkings

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
public static List<Marking> findMarkings(String tweet){
	int start=0;
	List<Marking> markings = new ArrayList<Marking>();
	realTweet = new StringBuilder();
	String[] line = tweet.split("\n");
	int i=0;
	for(String tokenFull : line){
		String[] token = tokenFull.split("\t+");
		realTweet.append(token[0]+" ");
		token[1]=token[1].trim();
		if(token[1].startsWith("B-")){
			String[] marking = getWholeMarking(line, i);
			Set<String> types = new HashSet<String>();
			types.add(marking[1]);
			markings.add(new TypedNamedEntity(start, marking[0].length(), "", types));
			
		}
		start+=token[0].length()+1;
		i++;
	}
	
	return markings;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:24,代码来源:RitterDataset.java

示例6: performOKETask1

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
protected static List<TypedNamedEntity> performOKETask1(SingleInstanceSecuringAnnotatorDecorator decorator,
        Document document) throws GerbilException {
    List<TypedNamedEntity> 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 = ((OKETask1Annotator) decorator.getDecoratedAnnotator()).performTask1(document);
    } finally {
        decorator.semaphore.release();
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:18,代码来源:SingleInstanceSecuringAnnotatorDecorator.java

示例7: performOKETask2

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
protected static List<TypedNamedEntity> performOKETask2(SingleInstanceSecuringAnnotatorDecorator decorator,
        Document document) throws GerbilException {
    List<TypedNamedEntity> 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 = ((OKETask2Annotator) decorator.getDecoratedAnnotator()).performTask2(document);
    } finally {
        decorator.semaphore.release();
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:18,代码来源:SingleInstanceSecuringAnnotatorDecorator.java

示例8: performOKETask1

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
protected static List<TypedNamedEntity> performOKETask1(ErrorCountingAnnotatorDecorator errorCounter,
        Document document) throws GerbilException {
    List<TypedNamedEntity> result = null;
    try {
        result = ((OKETask1Annotator) errorCounter.getDecoratedAnnotator()).performTask1(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<TypedNamedEntity>(0);
    }
    if (printDebugMsg && LOGGER.isDebugEnabled()) {
        logResult(result, errorCounter.getName(), "TypedNamedEntity");
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:ErrorCountingAnnotatorDecorator.java

示例9: performOKETask2

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
protected static List<TypedNamedEntity> performOKETask2(ErrorCountingAnnotatorDecorator errorCounter,
        Document document) throws GerbilException {
    List<TypedNamedEntity> result = null;
    try {
        result = ((OKETask2Annotator) errorCounter.getDecoratedAnnotator()).performTask2(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<TypedNamedEntity>(0);
    }
    if (printDebugMsg && LOGGER.isDebugEnabled()) {
        logResult(result, errorCounter.getName(), "TypedNamedEntity");
    }
    return result;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:ErrorCountingAnnotatorDecorator.java

示例10: test

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Test
public void test() {
    Set<String> lines = new HashSet<String>();
    for(String m : mentions){
    	lines.add(m);
    }
    List<Marking> markings = Microposts2015Dataset.findMarkings(lines, tweet); 
    Assert.assertNotNull(markings);
    Assert.assertTrue(markings.size() > 0);
    int i =0;
    for(Marking marking : markings){
    	Assert.assertTrue(marking instanceof TypedNamedEntity);
    	TypedNamedEntity ne = (TypedNamedEntity) marking;
    	
    	String mention = tweet.substring(ne.getStartPosition(), ne.getStartPosition() + ne.getLength());
    	Assert.assertEquals(expectedMentions[i], mention);
    	
    	String type = ne.getTypes().iterator().next();
    	Assert.assertEquals(expectedTypes[i], type);
    	i++;
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:Microposts2015DatasetMentionSearchTest.java

示例11: test

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Test
public void test() {
    Set<String> lines = new HashSet<String>();
    for(String m : mentions){
    	lines.add(m);
    }
    List<Marking> markings = Microposts2016Dataset.findMarkings(lines, tweet); 
    Assert.assertNotNull(markings);
    Assert.assertTrue(markings.size() > 0);
    int i =0;
    for(Marking marking : markings){
    	Assert.assertTrue(marking instanceof TypedNamedEntity);
    	TypedNamedEntity ne = (TypedNamedEntity) marking;
    	
    	String mention = tweet.substring(ne.getStartPosition(), ne.getStartPosition() + ne.getLength());
    	Assert.assertEquals(expectedMentions[i], mention);
    	
    	String type = ne.getTypes().iterator().next();
    	Assert.assertEquals(expectedTypes[i], type);
    	i++;
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:23,代码来源:Microposts2016DatasetMentionSearchTest.java

示例12: testAccepting

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Test
public void testAccepting() {
    MarkingFilter<TypedMarking> filter = new TypeBasedMarkingFilter<>(true, ACCEPTED_TYPES);

    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Class",
                    "http://www.w3.org/2000/01/rdf-schema#Class")))));
    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Class")))));
    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2000/01/rdf-schema#Class")))));

    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(0, 20,
            "http://dbpedia.org/resource/Florence_May_Harding", new HashSet<String>(Arrays.asList(
                    "http://www.w3.org/2002/07/owl#Individual",
                    "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Person")))));
    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(44, 6, "http://dbpedia.org/resource/Sydney",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Individual",
                    "http://ontologydesignpatterns.org/ont/wikipedia/d0.owl#Location")))));
    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(61, 21,
            "http://www.ontologydesignpatterns.org/data/oke-challenge/task-1/Douglas_Robert_Dundas",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Individual",
                    "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Person")))));
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:25,代码来源:TypeBasedMarkingFilterTest.java

示例13: testDeclining

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Test
public void testDeclining() {
    MarkingFilter<TypedMarking> filter = new TypeBasedMarkingFilter<>(false, ACCEPTED_TYPES);

    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(0, 20,
            "http://dbpedia.org/resource/Florence_May_Harding", new HashSet<String>(Arrays.asList(
                    "http://www.w3.org/2002/07/owl#Individual",
                    "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Person")))));
    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(44, 6, "http://dbpedia.org/resource/Sydney",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Individual",
                    "http://ontologydesignpatterns.org/ont/wikipedia/d0.owl#Location")))));
    Assert.assertTrue(filter.isMarkingGood(new TypedNamedEntity(61, 21,
            "http://www.ontologydesignpatterns.org/data/oke-challenge/task-1/Douglas_Robert_Dundas",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Individual",
                    "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Person")))));

    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Class",
                    "http://www.w3.org/2000/01/rdf-schema#Class")))));
    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2002/07/owl#Class")))));
    Assert.assertFalse(filter.isMarkingGood(new TypedNamedEntity(61, 21, "http://www.w3.org/2002/07/owl#Individual",
            new HashSet<String>(Arrays.asList("http://www.w3.org/2000/01/rdf-schema#Class")))));
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:25,代码来源:TypeBasedMarkingFilterTest.java

示例14: test

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Test
public void test() {
    HierarchicalMatchingsCounter<TypedNamedEntity> counter = new HierarchicalMatchingsCounter<TypedNamedEntity>(
            new WeakSpanMatchingsSearcher<TypedNamedEntity>(),
            new SimpleWhiteListBasedUriKBClassifier(KNOWN_KB_URIS),
            SimpleSubClassInferencerFactory.createInferencer(typeHierarchy));

    List<TypedNamedEntity> annotatorResult = new ArrayList<TypedNamedEntity>();
    annotatorResult.add(createTypedNamedEntities(annotatorResults, 0));
    List<TypedNamedEntity> goldStandard = new ArrayList<TypedNamedEntity>();
    goldStandard.add(createTypedNamedEntities(goldStandardTypes, 0));
    List<EvaluationCounts> evalCounts = counter.countMatchings(annotatorResult, goldStandard);

    Assert.assertNotNull(evalCounts);
    Assert.assertTrue(evalCounts.size() > 0);
    Assert.assertEquals("Arrays do not equal exp=" + expectedCounts + " calculated=" + evalCounts.get(0),
            expectedCounts, evalCounts.get(0));
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:19,代码来源:HierarchicalMatchingsCounterTest.java

示例15: getAllTypes

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入依赖的package包/类
@Override
public TypedNamedEntity getAllTypes(Document document, NamedEntity ne, List<ExtendedTypedNamedEntity> surfaceForms) {
    TypedNamedEntity tne = new TypedNamedEntity(ne.getStartPosition(), ne.getLength(), ne.getUris(),
            new HashSet<String>());
    for(ExtendedTypedNamedEntity surfaceForm : surfaceForms) {
        tne.getTypes().addAll(surfaceForm.getUris());
    }

    try {
        // request FOX
        Response response = Request
                .Post(FOX_SERVICE)
                .addHeader("Content-type", "application/json")
                .addHeader("Accept-Charset", "UTF-8")
                .body(new StringEntity(new JSONObject().put("input", document.getText()).put("type", "text")
                        .put("task", "ner").put("output", "JSON-LD").toString(), ContentType.APPLICATION_JSON))
                .execute();

        HttpResponse httpResponse = response.returnResponse();
        HttpEntity entry = httpResponse.getEntity();

        String content = IOUtils.toString(entry.getContent(), "UTF-8");
        EntityUtils.consume(entry);

        // parse results
        JSONObject outObj = new JSONObject(content);
        if (outObj.has("@graph")) {

            JSONArray graph = outObj.getJSONArray("@graph");
            for (int i = 0; i < graph.length(); i++) {
                parseType(graph.getJSONObject(i), tne, surfaceForms);
            }
        } else {
            parseType(outObj, tne, surfaceForms);
        }
    } catch (Exception e) {
        LOGGER.error("Got an exception while communicating with the FOX web service.", e);
    }
    return tne;
}
 
开发者ID:dice-group,项目名称:Cetus,代码行数:41,代码来源:FoxBasedTypeSearcher.java


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