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


Java PropertiesUtils.get方法代码示例

本文整理汇总了Java中edu.stanford.nlp.util.PropertiesUtils.get方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesUtils.get方法的具体用法?Java PropertiesUtils.get怎么用?Java PropertiesUtils.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.util.PropertiesUtils的用法示例。


在下文中一共展示了PropertiesUtils.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import edu.stanford.nlp.util.PropertiesUtils; //导入方法依赖的package包/类
public static void main(String[] args) {

    Properties options = StringUtils.argsToProperties(args, optionArgDefs());
    String annotations = PropertiesUtils.get(options, "annotations", null, String.class);
    
    boolean changepreps = PropertiesUtils.getBool(options, "changepreps", false);
    
    int sentenceCount = CoreNLPCache.loadSerialized(annotations);
   
    
    CoreMap sentence;
    for (int i = 0; i < sentenceCount; i++) {
      try {  
        sentence = CoreNLPCache.get(i);
        if (sentence == null) {
          System.out.println();
          System.err.println("Empty sentence #" + i);
          continue;
        }
        printDependencies(sentence, changepreps);
        //System.err.println("---------------------------");
      } catch (Exception e) {
        System.err.println("SourceSentence #" + i);
        e.printStackTrace();
        return;
      }
    }
  }
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:29,代码来源:SerializedDependencyToCoNLL.java

示例2: main

import edu.stanford.nlp.util.PropertiesUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  String sourceTokens = PropertiesUtils.get(options, "input", null, String.class);
  String outdirPath = PropertiesUtils.get(options, "outdir", ".", String.class);
  String leftDepLMFilename = outdirPath + File.separator + "left.deplm";
  String rightDepLMFilename = outdirPath + File.separator + "right.deplm";
  String headDepLMFilename = outdirPath + File.separator + "head.deplm";


  File leftDepLMFile = new File(leftDepLMFilename);
  if (!leftDepLMFile.exists())
    leftDepLMFile.createNewFile();

  
  File rightDepLMFile = new File(rightDepLMFilename);
  if (!rightDepLMFile.exists())
    rightDepLMFile.createNewFile();
  
  File headDepLMFile = new File(headDepLMFilename);
  if (!headDepLMFile.exists())
    headDepLMFile.createNewFile();

  FileWriter leftFW = new FileWriter(leftDepLMFile.getAbsoluteFile());
  FileWriter rightFW = new FileWriter(rightDepLMFile.getAbsoluteFile());
  FileWriter headFW = new FileWriter(headDepLMFile.getAbsoluteFile());

  leftDepLMWriter = new BufferedWriter(leftFW);
  rightDepLMWriter = new BufferedWriter(rightFW);
  headDepLMWriter = new BufferedWriter(headFW);

  File sourceSentences = new File(sourceTokens);
  BufferedReader sourceReader = new BufferedReader(new FileReader(sourceSentences));
  String sourceSentence;
  Map<Integer, NavigableSet<Integer>> dependencies = new HashMap<>();
  List<String> tokens = new LinkedList<>();
  while (true) {
    sourceSentence = sourceReader.readLine();
    if (sourceSentence == null || sourceSentence.equals("")) {
      printLeftAndRightDependencies(dependencies, new ArraySequence<String>(tokens));
      dependencies = new HashMap<>();
      tokens = new LinkedList<>();
      if (sourceSentence == null) {
        break;
      } else {
        continue;
      }
    }
   
    String fields[] = sourceSentence.split("\t");
    int id = Integer.parseInt(fields[0]) - 1;
    int head = fields[7].equals("frag") ? -2 : Integer.parseInt(fields[6]) - 1;
   
    String token = fields[1];
    tokens.add(token);
    if (!isWord(token))
      continue;
    if (!dependencies.containsKey(head)) 
      dependencies.put(head, new TreeSet<Integer>());
    if (!dependencies.containsKey(id))
      dependencies.put(id, new TreeSet<Integer>());
    dependencies.get(head).add(id);
  }

  
  sourceReader.close();

  leftDepLMWriter.close();
  rightDepLMWriter.close();
  headDepLMWriter.close();
  
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:72,代码来源:BuildDependencyLMData.java

示例3: main

import edu.stanford.nlp.util.PropertiesUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  String dependenciesFilename = PropertiesUtils.get(options, "input", null, String.class);
  String outdirPath = PropertiesUtils.get(options, "outdir", ".", String.class);
  String alignmentFilename = PropertiesUtils.get(options, "alignment", null, String.class);
  String sourceTokensFilename = PropertiesUtils.get(options, "sourceTokens", null, String.class);
  String targetTokensFilename = PropertiesUtils.get(options, "targetTokens", null, String.class);
  String rightDepLMFilename = outdirPath + File.separator + "deplm.nonevents";
  String leftDepLMFilename = outdirPath + File.separator + "deplm.data";
  String classMapFilename = PropertiesUtils.get(options, "classMap", null, String.class);
  
  useHeadClasses = PropertiesUtils.getBool(options, "headClasses", false);
  
  
  if (classMapFilename != null) {
    System.err.println("Loading word class mapping from " + classMapFilename);
    classMap = new LocalWordClassMap();
    classMap.load(classMapFilename);
  } else {
    classMap = null;
  }
  
  /* Include alignment information and generate a "FRAG" tuple for each unaligned word instead of the real one. */
  boolean includeAlignment = (alignmentFilename != null && sourceTokensFilename != null);

  LineNumberReader alignmentReader = null;
  LineNumberReader sourceTokensReader = null;
  LineNumberReader targetTokensReader = null;

  
  if (includeAlignment) {
    alignmentReader = IOTools.getReaderFromFile(alignmentFilename);
    sourceTokensReader = IOTools.getReaderFromFile(sourceTokensFilename);
    targetTokensReader = IOTools.getReaderFromFile(targetTokensFilename);
  }
  
  
  File leftDepLMFile = new File(leftDepLMFilename);
  if (!leftDepLMFile.exists())
    leftDepLMFile.createNewFile();

  
  File rightDepLMFile = new File(rightDepLMFilename);
  if (!rightDepLMFile.exists())
    rightDepLMFile.createNewFile();
  
 
  

  FileWriter leftFW = new FileWriter(leftDepLMFile.getAbsoluteFile());
  FileWriter rightFW = new FileWriter(rightDepLMFile.getAbsoluteFile());
 
  
  lmWriter = new BufferedWriter(leftFW);
  noEventWriter = new BufferedWriter(rightFW);

  LineNumberReader inputReader = IOTools.getReaderFromFile(dependenciesFilename);

  
  HashMap<Integer, Pair<IndexedWord, List<Integer>>>  dependencies =  null;
  while ((dependencies =  DependencyUtils.getDependenciesFromCoNLLFileReader(inputReader, false, true)) != null) {
    
    SymmetricalWordAlignment alignment = null;
    
    if (includeAlignment) {
      alignment = new SymmetricalWordAlignment(sourceTokensReader.readLine(), targetTokensReader.readLine(), alignmentReader.readLine());
    }
    
    updateCounts(dependencies, alignment);
  }
  
  inputReader.close();
  lmWriter.close();
  noEventWriter.close();
  //headLmWriter.close();
  
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:78,代码来源:BuildDependencyLMData2.java


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