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


Java Level类代码示例

本文整理汇总了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");
    }
 
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:22,代码来源:ExecuteNER.java

示例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();
	}
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:24,代码来源:ElasticsearchAnnotationWriter.java

示例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;
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:26,代码来源:PostgresResource.java

示例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();
	}
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:26,代码来源:LanguageDetector.java

示例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();
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:27,代码来源:InformationExtraction2Postgres.java

示例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);
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:26,代码来源:SlotRemovalFilter_AE.java

示例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;
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:27,代码来源:XmiLoaderAE.java

示例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);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:Slf4jLoggerImpl.java

示例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();
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:18,代码来源:Slf4jLoggerImpl.java

示例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");
    }
  }
}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:18,代码来源:CrfSuiteWrapper.java

示例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;
  }

}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:26,代码来源:CrfSuiteWrapper.java

示例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]);
		}
	}
}
 
开发者ID:HeidelTime,项目名称:heideltime,代码行数:29,代码来源:ACETernReader.java

示例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;
}
 
开发者ID:HeidelTime,项目名称:heideltime,代码行数:23,代码来源:Tempeval2Reader.java

示例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);
  }
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:19,代码来源:PennTreebankReader.java

示例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();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:25,代码来源:SvmLightClassifierBuilder_ImplBase.java


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