本文整理汇总了Java中org.apache.uima.util.Level类的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Level类属于org.apache.uima.util包,在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.uima.util.Level; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
long start = System.currentTimeMillis();
long now = 0;
String modelDirectory = "src/test/resources/model/";
String language = "en";
File nerTrain = new File("src/main/resources/ner/ner_eng.train");
File nerTest = new File("src/main/resources/ner/ner_eng.dev");
new File(modelDirectory).mkdirs();
now = System.currentTimeMillis();
UIMAFramework.getLogger().log(Level.INFO, "Starting 'writing model' Time: " + (now - start) + "ms");
writeModel(nerTrain, modelDirectory, language);
now = System.currentTimeMillis();
UIMAFramework.getLogger().log(Level.INFO, "Starting 'training model' Time: " + (now - start) + "ms");
trainModel(modelDirectory);
now = System.currentTimeMillis();
UIMAFramework.getLogger().log(Level.INFO, "Starting 'classifying model' Time: " + (now - start) + "ms");
classifyTestFile(modelDirectory, nerTest, language);
now = System.currentTimeMillis();
UIMAFramework.getLogger().log(Level.INFO, "All done! Time: " + (now - start) + "ms");
}
示例2: process
import org.apache.uima.util.Level; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
String docText = jcas.getDocumentText();
Metadata metadata = (Metadata) jcas.getAnnotationIndex(Metadata.type).iterator().next();
XContentBuilder builder;
try {
builder = XContentFactory.jsonBuilder()
.startObject()
.field("text", docText)
.field("date", new Date())
.field("id", metadata.getDocId())
.endObject();
IndexResponse response = client.prepareIndex(esResource.getIndex(), "document", metadata.getDocId())
.setSource(builder).get();
// client.listedNodes().get(0).
logger.log(Level.INFO, response.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: initialize
import org.apache.uima.util.Level; //导入依赖的package包/类
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
throws ResourceInitializationException {
if (!super.initialize(aSpecifier, aAdditionalParams)) {
return false;
}
this.logger = this.getLogger();
// init db
try {
if (createDb) {
createDb(dbUrl, dbName, dbUser, dbPass);
logger.log(Level.INFO, "DB " + dbName + " created");
} else {
initDb(dbUrl, dbName, dbUser, dbPass);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
prepareStatements();
return true;
}
示例4: collectionProcessComplete
import org.apache.uima.util.Level; //导入依赖的package包/类
@Override
public void collectionProcessComplete() throws AnalysisEngineProcessException {
super.collectionProcessComplete();
File tmpFile = new File(documentLanguagesFile);
HashMap<String, String> mergedDocumentLanguages;
try {
if (tmpFile.exists()) {
FileInputStream fis = new FileInputStream(tmpFile);
ObjectInputStream ois = new ObjectInputStream(fis);
mergedDocumentLanguages = (HashMap<String, String>) ois.readObject();
ois.close();
} else {
mergedDocumentLanguages = new HashMap<String, String>();
}
mergedDocumentLanguages.putAll(documentLanguages);
FileOutputStream fos = new FileOutputStream(tmpFile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(mergedDocumentLanguages);
oos.close();
log.log(Level.INFO, "Written language metadata of " + mergedDocumentLanguages.size() + " to " + documentLanguagesFile);
}
catch (Exception e) {
e.printStackTrace();
}
}
示例5: main
import org.apache.uima.util.Level; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
InformationExtraction2Postgres np = new InformationExtraction2Postgres();
np.getConfiguration(args);
// run language detection
np.pipelineLanguageDetection();
// extract information (per language)
np.pipelineAnnotation();
// import metadata.csv
np.initDb(np.dbName, np.dbUrl, np.dbUser, np.dbPass);
np.metadataToPostgres();
// create postgres indices
String indexSql = FileUtils.readFileToString(new File(np.dbIndices)).replace("\n", "");
try {
st.executeUpdate(indexSql);
np.logger.log(Level.INFO, "Index created");
} catch (Exception e) {
e.printStackTrace();
}
conn.close();
}
示例6: initialize
import org.apache.uima.util.Level; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
// classToSlotNamesToRemoveMap = new HashMap<String, Set<String>>();
// /* read in input parameters, and initialize a list of slots to remove */
// for (String classSlotPair : classSlotPairsToRemove) {
//
// if (classSlotPair.equals(REMOVE_ALL)) {
// removeAllSlots = true;
// break;
// }
// String[] classSlotName = classSlotPair.split("\\|");
// if (classSlotName.length != 2) {
// throw new ResourceInitializationException(new
// IllegalArgumentException("Invalid class/slot pairing: "
// + classSlotPair));
// }
// String classNameRegex = classSlotName[0];
// String slotName = classSlotName[1];
// CollectionsUtil.addToOne2ManyUniqueMap(classNameRegex, slotName,
// classToSlotNamesToRemoveMap);
// }
logger = context.getLogger();
logger.log(Level.INFO, "SlotRemovalFilter_AE initialized. Will remove slots defined by: " + removeOption);
}
示例7: getStreamFromFile
import org.apache.uima.util.Level; //导入依赖的package包/类
/**
* @param documentId
* @param xmiPathBase
* @param xmiStream
* @return
* @throws AnalysisEngineProcessException
*/
private InputStream getStreamFromFile(String documentId, String xmiPathBase) throws AnalysisEngineProcessException {
InputStream xmiStream = null;
File xmiDirectory = new File(xmiPathBase);
String xmiFileName = XmiPrinterAE.getXmiFileName(documentId);
if (xmiFileCompressionType.equals(XmiFileCompressionType.GZ)) {
xmiFileName = xmiFileName + ".gz";
}
File xmiFile = new File(xmiDirectory, xmiFileName);
if (!xmiFile.exists()) {
logger.log(Level.WARNING, "Expected XMI file does not exist: " + xmiFile.getAbsolutePath());
} else {
try {
xmiStream = StreamUtil.getEncodingSafeInputStream(xmiFile, CharacterEncoding.UTF_8);
} catch (FileNotFoundException e) {
throw new AnalysisEngineProcessException(e);
}
}
return xmiStream;
}
示例8: doLog
import org.apache.uima.util.Level; //导入依赖的package包/类
private static void doLog(org.slf4j.Logger logger, Level level, String msg) {
switch (level.toInteger()) {
case Level.OFF_INT:
break;
case Level.SEVERE_INT:
logger.error(msg);
break;
case Level.WARNING_INT:
logger.warn(msg);
break;
case Level.INFO_INT:
case Level.CONFIG_INT:
logger.info(msg);
break;
case Level.FINE_INT:
logger.debug(msg);
break;
default:
logger.trace(msg);
}
}
示例9: isLoggable
import org.apache.uima.util.Level; //导入依赖的package包/类
public boolean isLoggable(Level level) {
switch (level.toInteger()) {
case Level.OFF_INT:
return false;
case Level.SEVERE_INT:
return logger.isErrorEnabled();
case Level.WARNING_INT:
return logger.isWarnEnabled();
case Level.INFO_INT:
case Level.CONFIG_INT:
return logger.isInfoEnabled();
case Level.FINE_INT:
return logger.isDebugEnabled();
default:
return logger.isTraceEnabled();
}
}
示例10: CrfSuiteWrapper
import org.apache.uima.util.Level; //导入依赖的package包/类
public CrfSuiteWrapper() {
Executables exec = new Executables();
if (exec.isInstalled()) {
logger.log(Level.FINE, "The CRFSuite is installed on the system");
executable = new File(exec.getExecutableName());
} else {
this.executable = exec.getExecutable();
if (!exec.isInstalled(this.executable.getAbsolutePath())) {
logger.log(
Level.WARNING,
"The CRFSuite binary is not available for the current operation system, please install it!");
} else {
logger.log(Level.FINE, "The CRFSuite binary is successfully extracted");
}
}
}
示例11: getExecutable
import org.apache.uima.util.Level; //导入依赖的package包/类
public File getExecutable() {
String loc = getExecutablePath() + getExecutableName();
URL crfExecUrl = getClass().getResource(loc);
crfExecUrl = ClassLoader.getSystemResource(loc);
logger.log(Level.FINE, "CrfSuite Location " + loc);
logger.log(Level.FINE, "CrfSuite Url: " + crfExecUrl);
File f;
try {
if (crfExecUrl != null) {
f = new File(ResourceUtils.getUrlAsFile(crfExecUrl, true).toURI().getPath());
if (!f.exists()) {
f = new File(URLDecoder.decode(f.getAbsolutePath(), ("UTF-8")));
}
f.setExecutable(true);
return f;
}
logger.log(Level.WARNING, "The executable could not be found at " + loc);
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
示例12: initialize
import org.apache.uima.util.Level; //导入依赖的package包/类
/**
* @see org.apache.uima.collection.CollectionReader_ImplBase#initialize()
*/
public void initialize() throws ResourceInitializationException {
logger = getUimaContext().getLogger();
logger.log(Level.INFO, "initialize() - Initializing ACETern-Reader...");
annotateDCT = (Boolean) getConfigParameterValue(PARAM_DCT);
File directory = new File(((String) getConfigParameterValue(PARAM_INPUTDIR)).trim());
currentIndex = 0;
// if input directory does not exist or is not a directory, throw exception
if (!directory.exists() || !directory.isDirectory()) {
throw new ResourceInitializationException(ResourceConfigurationException.DIRECTORY_NOT_FOUND,
new Object[] { PARAM_INPUTDIR, this.getMetaData().getName(), directory.getPath() });
}
// get list of files (without subdirectories) in the specified directory
mFiles = new ArrayList<File>();
File[] files = directory.listFiles();
for (int i = 0; i < files.length; i++) {
if (!files[i].isDirectory()) {
mFiles.add(files[i]);
}
}
}
示例13: getFilesFromInputDirectory
import org.apache.uima.util.Level; //导入依赖的package包/类
private List<File> getFilesFromInputDirectory() {
// get directory and save
File directory = new File(((String) getConfigParameterValue(PARAM_INPUTDIR)).trim());
List<File> documentFiles = new ArrayList<File>();
// if input directory does not exist or is not a directory, throw exception
if (!directory.exists() || !directory.isDirectory()) {
logger.log(Level.WARNING, "getFilesFromInputDirectory() " + directory
+ " does not exist. Client has to set configuration parameter '" + PARAM_INPUTDIR + "'.");
return null;
}
// get list of files (not subdirectories) in the specified directory
File[] dirFiles = directory.listFiles();
for (int i = 0; i < dirFiles.length; i++) {
if (!dirFiles[i].isDirectory()) {
documentFiles.add(dirFiles[i]);
}
}
return documentFiles;
}
示例14: getNext
import org.apache.uima.util.Level; //导入依赖的package包/类
/**
* Reads the next file and stores its text in <b>cas</b> as the "TreebankView" SOFA.
*/
public void getNext(JCas jCas) throws IOException, CollectionException {
File treebankFile = files.removeFirst();
getUimaContext().getLogger().log(
Level.FINEST,
"reading treebank file: " + treebankFile.getPath());
ViewUriUtil.setURI(jCas, treebankFile.toURI());
try {
JCas treebankView = ViewCreatorAnnotator.createViewSafely(
jCas,
TREEBANK_VIEW);
treebankView.setSofaDataString(FileUtils.file2String(treebankFile), "text/plain");
} catch (AnalysisEngineProcessException aepe) {
throw new CollectionException(aepe);
}
}
示例15: trainClassifier
import org.apache.uima.util.Level; //导入依赖的package包/类
public void trainClassifier(File dir, File trainingDataFile, String... args) throws Exception {
String executable = "svm_learn";
if (args.length > 0 && args[0].equals(COMMAND_ARGUMENT)) {
executable = args[1];
String[] tempArgs = new String[args.length - 2];
System.arraycopy(args, 2, tempArgs, 0, tempArgs.length);
args = tempArgs;
}
String[] command = new String[args.length + 3];
command[0] = executable;
System.arraycopy(args, 0, command, 1, args.length);
command[command.length - 2] = trainingDataFile.getPath();
command[command.length - 1] = trainingDataFile.getPath() + ".model";
logger.log(
Level.FINE,
"training svmlight using the following command: " + Joiner.on(" ").join(command));
Process process = Runtime.getRuntime().exec(command);
process.getOutputStream().close();
ByteStreams.copy(process.getInputStream(), System.out);
ByteStreams.copy(process.getErrorStream(), System.err);
process.waitFor();
}