本文整理了Java中org.apache.uima.jcas.tcas.DocumentAnnotation.getDocType()方法的一些代码示例,展示了
本文整理了Java中org.apache.uima.jcas.tcas.DocumentAnnotation.getDocType()
方法的一些代码示例,展示了DocumentAnnotation.getDocType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DocumentAnnotation.getDocType()
方法的具体详情如下:
包路径:org.apache.uima.jcas.tcas.DocumentAnnotation
类名称:DocumentAnnotation
方法名:getDocType
DocumentAnnotation.getDocType介绍
[英]getter for docType - gets The document type
[中]docType的getter-获取文档类型
代码示例
代码示例来源:origin: dstl/baleen
private File getDestinationFolder(DocumentAnnotation da) {
File dest = new File(destination);
if (splitByType) {
String type = da.getDocType();
if (!Strings.isNullOrEmpty(type)) {
dest = new File(dest, type);
}
}
return dest;
}
}
代码示例来源:origin: dstl/baleen
private void addDocumentAnnotationToProperties(
final Map properties, final DocumentAnnotation da) {
properties.put(AnalysisConstants.DOCUMENT_TYPE, da.getDocType());
properties.put(AnalysisConstants.CAVEATS, UimaTypesUtils.toList(da.getDocumentCaveats()));
properties.put(AnalysisConstants.CLASSIFICATION, da.getDocumentClassification());
properties.put(
AnalysisConstants.RELEASABILITY, UimaTypesUtils.toList(da.getDocumentReleasability()));
properties.put(AnalysisConstants.LANGUAGE, da.getLanguage());
properties.put(AnalysisConstants.HASH, da.getHash());
properties.put(AnalysisConstants.SOURCE, da.getSourceUri());
properties.put(AnalysisConstants.TIMESTAMP, new Date(da.getTimestamp()));
}
代码示例来源:origin: dstl/baleen
private Map serialiseDocumentAnnotation(final DocumentAnnotation da) {
final Map map = new HashMap<>();
map.put(JsonJCas.DA_DOCUMENT_TYPE, da.getDocType());
map.put(JsonJCas.DA_LANGUAGE, da.getLanguage());
map.put(JsonJCas.DA_SOURCE_URI, da.getSourceUri());
map.put(JsonJCas.DA_CLASSIFICATION, da.getDocumentClassification());
final String[] caveats =
da.getDocumentCaveats() != null ? da.getDocumentCaveats().toArray() : new String[0];
map.put(JsonJCas.DA_CAVEATS, caveats);
final String[] rels =
da.getDocumentReleasability() != null
? da.getDocumentReleasability().toArray()
: new String[0];
map.put(JsonJCas.DA_RELEASABILITY, rels);
return map;
}
代码示例来源:origin: dstl/baleen
@Test
public void testBaseDirectoryOneLayers() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri(tmp.getAbsolutePath());
processJCas(BASE_DIRECTORY, parentDir.getAbsolutePath());
String relative =
tmp.getAbsolutePath()
.substring(
parentDir.getAbsolutePath().length() + 1,
tmp.getAbsolutePath().length() - tmp.getName().length() - 1);
assertEquals(relative, da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testBaseDirectoryTwoLayers() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri(tmp.getAbsolutePath());
processJCas(BASE_DIRECTORY, topDir.getAbsolutePath());
String relative =
tmp.getAbsolutePath()
.substring(
topDir.getAbsolutePath().length() + 1,
tmp.getAbsolutePath().length() - tmp.getName().length() - 1);
assertEquals(relative, da.getDocType());
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testBadParameters() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri(tmp.getAbsolutePath());
processJCas(BASE_DIRECTORY, null);
String relative =
tmp.getAbsolutePath()
.substring(
parentDir.getAbsolutePath().length() + 1,
tmp.getAbsolutePath().length() - tmp.getName().length() - 1);
assertNotEquals(relative, da.getDocType());
processJCas(BASE_DIRECTORY, "/not/the/path");
assertNotEquals(relative, da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testThrehold() throws Exception {
jCas.setDocumentText("This text isn't going to score above the threshold.");
processJCas(
DocumentType.PARAM_MODEL,
getClass().getResource(DOCUMENTTYPE_BIN).getPath(),
DocumentType.PARAM_CONFIDENCE_THRESHOLD,
"0.99"); // Model trained on IOM and BBC reporting, and is OFFICIAL
DocumentAnnotation da = getDocumentAnnotation();
assertEquals(null, da.getDocType());
}
}
代码示例来源:origin: dstl/baleen
@Test
public void test() throws Exception {
try {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri(tmp.getAbsolutePath());
processJCas();
// Remove slash (requried for unix paths)
String absolutePath = childDir.getAbsolutePath();
if (absolutePath.startsWith(File.separator)) {
absolutePath = absolutePath.substring(1);
}
assertEquals(absolutePath, da.getDocType());
} finally {
tmp.delete();
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testBaseDirectory() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri(tmp.getAbsolutePath());
processJCas(BASE_DIRECTORY, childDir.getAbsolutePath());
assertEquals("", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testType() throws AnalysisEngineProcessException, ResourceInitializationException {
processJCas(DocumentTypeByParameter.PARAM_TYPE, "test");
assertEquals("test", getDocumentAnnotation().getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testNullType()
throws AnalysisEngineProcessException, ResourceInitializationException {
processJCas(DocumentTypeByParameter.PARAM_TYPE, null);
assertNull(getDocumentAnnotation().getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testEmptyType()
throws AnalysisEngineProcessException, ResourceInitializationException {
processJCas(DocumentTypeByParameter.PARAM_TYPE, "");
assertNull(getDocumentAnnotation().getDocType());
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testPatternCaseSensitiveFalse() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(
DocumentTypeByFilename.PARAM_PATTERN,
"\\d{8}-([a-z]).*",
DocumentTypeByFilename.PARAM_DEFAULT,
"unknown");
assertEquals("t", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testDefault() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas();
assertEquals("docx", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testPrefix() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(DocumentTypeByFilename.PARAM_PREFIX, "filetype_");
assertEquals("filetype_docx", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testPattern() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(DocumentTypeByFilename.PARAM_PATTERN, "(\\d{4}).*");
assertEquals("2017", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testLowerCase() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(
DocumentTypeByFilename.PARAM_PATTERN,
"\\d{8}-([a-z]).*",
DocumentTypeByFilename.PARAM_LOWER_CASE,
false);
assertEquals("T", da.getDocType());
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testGroup() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(
DocumentTypeByFilename.PARAM_PATTERN,
"(\\d{4})(\\d{2})(\\d{2}).*",
DocumentTypeByFilename.PARAM_GROUP,
2);
assertEquals("01", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testPatternNoMatch() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(
DocumentTypeByFilename.PARAM_PATTERN,
"([a-z]{2}).*",
DocumentTypeByFilename.PARAM_DEFAULT,
"unknown");
assertEquals("unknown", da.getDocType());
}
代码示例来源:origin: dstl/baleen
@Test
public void testPatternCaseSensitiveTrue() throws Exception {
DocumentAnnotation da = getDocumentAnnotation();
da.setSourceUri("20170127-Test_Document.docx");
processJCas(
DocumentTypeByFilename.PARAM_PATTERN,
"\\d{8}-([a-z]).*",
DocumentTypeByFilename.PARAM_DEFAULT,
"unknown",
DocumentTypeByFilename.PARAM_CASE_SENSITIVE,
true);
assertEquals("unknown", da.getDocType());
}