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


Java TypedNamedEntity.getLength方法代码示例

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


在下文中一共展示了TypedNamedEntity.getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: test

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入方法依赖的package包/类
@Test
    public void test() {
        Map<NamedEntity, List<ExtendedTypedNamedEntity>> result = EXTRACTOR.extractTypeSurfaceForms(nifDocument);
        List<ExtendedTypedNamedEntity> resultTypes;
        ExtendedTypedNamedEntity matchingEntity;
        int expectedStartPos, expectedEndPos, startPos, endPos;
        for (NamedEntity ne : nifDocument.getMarkings(NamedEntity.class)) {
            Assert.assertTrue(result.containsKey(ne));
            resultTypes = result.get(ne);
            for (TypedNamedEntity expectedType : expectedTypes) {
                matchingEntity = null;
                expectedStartPos = expectedType.getStartPosition();
                expectedEndPos = expectedStartPos + expectedType.getLength();
                // search for a matching entity
                for (ExtendedTypedNamedEntity type : resultTypes) {
                    startPos = type.getStartPosition();
                    endPos = startPos + type.getLength();
                    if ((expectedStartPos >= startPos) && (expectedEndPos <= endPos)) {
                        matchingEntity = type;
                    }
                }
                Assert.assertNotNull("Couldn't find " + expectedType + " inside the list of expected types.",
                        matchingEntity);
            }
//            if (resultTypes.size() > 0) {
//                LOGGER.warn("Got more types than expected: " + Arrays.toString(resultTypes.toArray()));
//            }
        }
    }
 
开发者ID:dice-group,项目名称:Cetus,代码行数:30,代码来源:ExtendedCetusSurfaceFormExtractorTest.java

示例4: extractNamedEntity

import org.aksw.gerbil.transfer.nif.data.TypedNamedEntity; //导入方法依赖的package包/类
public static NamedEntity extractNamedEntity(Document document) {
    MarkingFilter<TypedNamedEntity> filter = new TypeBasedMarkingFilter<TypedNamedEntity>(false,
            RDFS.Class.getURI(), OWL.Class.getURI());
    List<TypedNamedEntity> namedEntities = document.getMarkings(TypedNamedEntity.class);
    for (TypedNamedEntity tne : namedEntities) {
        if (filter.isMarkingGood(tne)) {
            return new NamedEntity(tne.getStartPosition(), tne.getLength(), tne.getUris());
        }
    }
    return null;
}
 
开发者ID:dice-group,项目名称:Cetus,代码行数:12,代码来源:ExtendedYagoBasedTypeSearcherTest.java


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