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