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


Java StringUtils.argsToProperties方法代码示例

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


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

示例1: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * A debugging method to try relation extraction from the console.
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  Properties props = StringUtils.argsToProperties(args);
  props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,regexner,parse,mention,coref,kbp");
  props.setProperty("regexner.mapping", "ignorecase=true,validpospattern=^(NN|JJ).*,edu/stanford/nlp/models/kbp/regexner_caseless.tab;edu/stanford/nlp/models/kbp/regexner_cased.tab");

  StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
  IOUtils.console("sentence> ", line -> {
    Annotation ann = new Annotation(line);
    pipeline.annotate(ann);
    for (CoreMap sentence : ann.get(CoreAnnotations.SentencesAnnotation.class)) {
      sentence.get(CoreAnnotations.KBPTriplesAnnotation.class).forEach(System.err::println);
      System.out.println(sentence);
    }
  });
}
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:20,代码来源:KBPTest.java

示例2: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args){
    try{
      Properties props = StringUtils.argsToProperties(args);
//      props.setProperty("annotators", "tokenize,ssplit,lemma,pos,parse,ner");
      StanfordCoreNLP pipeline = new StanfordCoreNLP();
      String sentence = "John Gerspach was named Chief Financial Officer of Citi in July 2009.";
      Annotation doc = new Annotation(sentence);
      pipeline.annotate(doc);
      RelationExtractorAnnotator r = new RelationExtractorAnnotator(props);
      r.annotate(doc);

      for(CoreMap s: doc.get(CoreAnnotations.SentencesAnnotation.class)){
        System.out.println("For sentence " + s.get(CoreAnnotations.TextAnnotation.class));
        List<RelationMention> rls  = s.get(RelationMentionsAnnotation.class);
        for(RelationMention rl: rls){
          System.out.println(rl.toString());
        }
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:23,代码来源:JavaReExTest.java

示例3: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    Properties props = StringUtils.argsToProperties(args);
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,regexner,parse,mention,coref,kbp");
    props.setProperty("regexner.mapping", "ignorecase=true,validpospattern=^(NN|JJ).*,edu/stanford/nlp/models/kbp/regexner_caseless.tab;edu/stanford/nlp/models/kbp/regexner_cased.tab");
    Set<String> interested = Stream.of("per:title", "per:employee_of", "org:top_members/employees").collect(Collectors.toSet());
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    IOUtils.console("sentence> ", line -> {
        Annotation ann = new Annotation(line);
        pipeline.annotate(ann);
        for (CoreMap sentence : ann.get(CoreAnnotations.SentencesAnnotation.class)) {
            sentence.get(CoreAnnotations.KBPTriplesAnnotation.class).forEach(r -> {
                 String relation = r.relationGloss();
                if(interested.contains(relation)) {
                    System.err.println(r);
                }
            });
        }
    });
}
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:20,代码来源:InteractiveDriver.java

示例4: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Run Phrasal from the command line.
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  final Properties options = StringUtils.argsToProperties(args);
  final String configFile = options.containsKey("") ? (String) options.get("") : null;
  options.remove("");
  if ((options.size() == 0 && configFile == null) || options.containsKey("help") || options.containsKey("h")) {
    System.err.println(usage());
    System.exit(-1);
  }

  // by default, exit on uncaught exception
  Thread.setDefaultUncaughtExceptionHandler((t, ex) -> {
    logger.fatal("Uncaught top-level exception", ex);
    System.exit(-1);
  });

  final Map<String, List<String>> configuration = getConfigurationFrom(configFile, options);
  final Phrasal p = Phrasal.loadDecoder(configuration);
  
  if (options.containsKey("text")) p.decode(new FileInputStream(new File(options.getProperty("text"))), true);
  else p.decode(System.in, true);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:28,代码来源:Phrasal.java

示例5: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * A main method for training and evaluating the postprocessor.
 * 
 * @param args
 */
public static void main(String[] args) {
  // Strips off hyphens
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  if (options.containsKey("help") || args.length == 0) {
    System.err.println(usage(GermanPostprocessor.class.getName()));
    System.exit(-1);
  }

  int nThreads = PropertiesUtils.getInt(options, "nthreads", 1);
  GermanPreprocessor preProcessor = new GermanPreprocessor();
  GermanPostprocessor postProcessor = new GermanPostprocessor(options);
  
  CRFPostprocessor.setup(postProcessor, preProcessor, options);
  CRFPostprocessor.execute(nThreads, preProcessor, postProcessor);    
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:21,代码来源:GermanPostprocessor.java

示例6: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * A main method for training and evaluating the postprocessor.
 * 
 * @param args
 */
public static void main(String[] args) {
  // Strips off hyphens
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  if (options.containsKey("help") || args.length == 0) {
    System.err.println(usage(FrenchPostprocessor.class.getName()));
    System.exit(-1);
  }

  int nThreads = PropertiesUtils.getInt(options, "nthreads", 1);
  FrenchPreprocessor preProcessor = new FrenchPreprocessor();
  FrenchPostprocessor postProcessor = new FrenchPostprocessor(options);
  
  CRFPostprocessor.setup(postProcessor, preProcessor, options);
  CRFPostprocessor.execute(nThreads, preProcessor, postProcessor);    
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:21,代码来源:FrenchPostprocessor.java

示例7: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * A main method for training and evaluating the postprocessor.
 * 
 * @param args
 */
public static void main(String[] args) {
  // Strips off hyphens
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  if (options.containsKey("help") || args.length == 0) {
    System.err.println(usage(EnglishPostprocessor.class.getName()));
    System.exit(-1);
  }

  int nThreads = PropertiesUtils.getInt(options, "nthreads", 1);
  EnglishPreprocessor preProcessor = new EnglishPreprocessor();
  EnglishPostprocessor postProcessor = new EnglishPostprocessor(options);
  
  CRFPostprocessor.setup(postProcessor, preProcessor, options);
  CRFPostprocessor.execute(nThreads, preProcessor, postProcessor);    
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:21,代码来源:EnglishPostprocessor.java

示例8: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * A main method for training and evaluating the postprocessor.
 * 
 * @param args
 */
public static void main(String[] args) {
  // Strips off hyphens
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  if (options.containsKey("help") || args.length == 0) {
    System.err.println(usage(SpanishPostprocessor.class.getName()));
    System.exit(-1);
  }

  int nThreads = PropertiesUtils.getInt(options, "nthreads", 1);
  SpanishPreprocessor preProcessor = new SpanishPreprocessor();
  SpanishPostprocessor postProcessor = new SpanishPostprocessor(options);
  
  CRFPostprocessor.setup(postProcessor, preProcessor, options);
  CRFPostprocessor.execute(nThreads, preProcessor, postProcessor);    
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:21,代码来源:SpanishPostprocessor.java

示例9: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    Properties props = null;
    
    int server_port = 4567;  // This is SparkJava's default

    if (args.length > 0) {
        props = StringUtils.argsToProperties(args);
        
        final String portString = props.getProperty("port");
        if (portString != null) {
            server_port = Integer.parseInt(portString);
        }
    }
    System.out.println("Processed args");
    runServer(props, server_port);
}
 
开发者ID:mdda,项目名称:corenlp-java-server,代码行数:17,代码来源:Main.java

示例10: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  Properties props = StringUtils.argsToProperties(args);
  boolean verbose = Boolean.parseBoolean(props.getProperty("v", "False"));
  String goldFilename = props.getProperty("g");
  String systemFilename = props.getProperty("s");
  if (goldFilename == null || systemFilename == null) {
    System.err.println("Usage:\n\tjava ...DependencyScoring [-v True/False] -g goldFile -s systemFile\n");
    System.err.println("\nOptions:\n\t-v verbose output");
    System.exit(-1);
  }

  DependencyScoring goldScorer = new DependencyScoring(goldFilename);
  List<Collection<TypedDependency>> systemDeps = DependencyScoring.readDeps(systemFilename);
  Score score = goldScorer.score(systemDeps);
  System.out.println(score.toString(verbose));
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:17,代码来源:DependencyScoring.java

示例11: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  StringUtils.printErrInvocationString("CRFFeatureExporter", args);
  Properties props = StringUtils.argsToProperties(args);
  CRFClassifier crf = new CRFClassifier(props);
  String inputFile = crf.flags.trainFile;
  if (inputFile == null) {
    System.err.println("Please provide input file using -trainFile");
    System.exit(-1);
  }
  String outputFile = crf.flags.exportFeatures;
  if (outputFile == null) {
    System.err.println("Please provide output file using -exportFeatures");
    System.exit(-1);
  }
  CRFFeatureExporter featureExporter = new CRFFeatureExporter(crf);
  Collection<List<CoreLabel>> docs =
    crf.makeObjectBankFromFile(inputFile, crf.makeReaderAndWriter());
  crf.makeAnswerArraysAndTagIndex(docs);
  featureExporter.printFeatures(outputFile, docs);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:21,代码来源:CRFFeatureExporter.java

示例12: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
  Properties options = StringUtils.argsToProperties(args, optionArgDefs());
  String[] filenames = options.getProperty("","").split("\\s+");
  if (filenames.length < 1 || filenames[0].length() == 0 || options.containsKey("h")
      || options.containsKey("help")) {
    System.err.println(usage());
    System.exit(-1);
  }
  MakeWordClasses mkWordCls = new MakeWordClasses(options);
  mkWordCls.run(filenames);
  mkWordCls.writeResults(System.out);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:16,代码来源:MakeWordClasses.java

示例13: loadClassifier

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static CRFClassifier<CoreLabel> loadClassifier(String options) throws IllegalArgumentException {
  String[] inputFlags = options.split(" ");
  Properties props = StringUtils.argsToProperties(inputFlags);
  SeqClassifierFlags flags = new SeqClassifierFlags(props);
  CRFClassifier<CoreLabel> crfSegmenter = new CRFClassifier<>(flags);
  if(flags.loadClassifier == null) {
    throw new IllegalArgumentException("missing -loadClassifier flag for CRF preprocessor.");
  }
  crfSegmenter.loadClassifierNoExceptions(flags.loadClassifier, props);
  crfSegmenter.loadTagIndex();
  return crfSegmenter;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:13,代码来源:CRFPreprocessor.java

示例14: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
  if (args.length < 1) {
    System.err.print(usage());
    System.exit(-1);
  }

  Properties options = StringUtils.argsToProperties(args, argDefs());
  final double scale = PropertiesUtils.getDouble(options, "s", DEFAULT_SCALE);
  final String orientation = options.getProperty("o", "utility");
  final boolean risk = "risk".equals(orientation);
  final String metricName = options.getProperty("m", DEFAULT_METRIC);

  final String filename = options.getProperty("");
  BasicNBestList nbestlists = new BasicNBestList(filename);
  MulticoreWrapper<List<BasicNBestEntry>, List<Pair<Double, String>>> wrapper = 
    new MulticoreWrapper<List<BasicNBestEntry>, List<Pair<Double, String>>>(0, new Processor(metricName, risk, scale), true);
  for (List<BasicNBestEntry> nbestlist : nbestlists) {
    wrapper.put(nbestlist);
    while (wrapper.peek()) {
      DumpRescored(wrapper.poll());
    }
  }
  wrapper.join();
  while (wrapper.peek()) {
    DumpRescored(wrapper.poll());
  }
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:33,代码来源:MinimumBayesRisk.java

示例15: main

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的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


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