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


Java PropertiesUtils类代码示例

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


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

示例1: main

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

示例2: main

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

示例3: main

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

示例4: main

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

示例5: TargetFunctionWordInsertion

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param args
 */
public TargetFunctionWordInsertion(String...args) {
  Properties options = FeatureUtils.argsToProperties(args);
  if (args.length < 2) {
    throw new RuntimeException("Must specify source and target unigram counts files");
  }
  System.err.println("Loading TargetFunctionWordInsertion template...");
  String sourceFilename = options.getProperty("sourceFile");
  String targetFilename = options.getProperty("targetFile");
  this.rankCutoff = PropertiesUtils.getInt(options, "rankCutoff", DEFAULT_RANK_CUTOFF);
  
  System.err.println("Source words:");
  sourceFunctionWordSet = loadCountsFile(sourceFilename);
  System.err.println("Target words:");
  targetFunctionWordSet = loadCountsFile(targetFilename);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:21,代码来源:TargetFunctionWordInsertion.java

示例6: ArabicLexer

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
public ArabicLexer(Reader r, LexedTokenFactory<?> tf, Properties props) {
  this(r);
  this.tokenFactory = tf;
  
  tokenizeNL = PropertiesUtils.getBool(props, "tokenizeNLs", false);
  useUTF8Ellipsis = PropertiesUtils.getBool(props, "useUTF8Ellipsis", false);
  invertible = PropertiesUtils.getBool(props, "invertible", false);
  normArDigits = PropertiesUtils.getBool(props, "normArDigits", false);
  normArPunc = PropertiesUtils.getBool(props, "normArPunc", false);
  normAlif = PropertiesUtils.getBool(props, "normAlif", false);
  normYa = PropertiesUtils.getBool(props, "normYa", false);
  removeDiacritics = PropertiesUtils.getBool(props, "removeDiacritics", false);
  removeTatweel = PropertiesUtils.getBool(props, "removeTatweel", false);
  removeQuranChars = PropertiesUtils.getBool(props, "removeQuranChars", false);
  removeProMarker = PropertiesUtils.getBool(props, "removeProMarker", false);
  removeSegMarker = PropertiesUtils.getBool(props, "removeSegMarker", false);
  removeMorphMarker = PropertiesUtils.getBool(props, "removeMorphMarker", false);
  atbEscaping = PropertiesUtils.getBool(props, "atbEscaping", false);

  setupNormalizationMap();
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:22,代码来源:ArabicLexer.java

示例7: ChineseSegmenterAnnotator

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
public ChineseSegmenterAnnotator(String name, Properties props) {
  String model = null;
  // Keep only the properties that apply to this annotator
  Properties modelProps = new Properties();
  for (String key : props.stringPropertyNames()) {
    if (key.startsWith(name + ".")) {
      // skip past name and the subsequent "."
      String modelKey = key.substring(name.length() + 1);
      if (modelKey.equals("model")) {
        model = props.getProperty(key);
      } else {
        modelProps.setProperty(modelKey, props.getProperty(key));
      }
    }
  }
  this.VERBOSE = PropertiesUtils.getBool(props, name + ".verbose", true);
  if (model == null) {
    throw new RuntimeException("Expected a property " + name + ".model");
  }
  loadModel(model, modelProps);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:22,代码来源:ChineseSegmenterAnnotator.java

示例8: ArabicSegmentorAnnotator

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
public ArabicSegmentorAnnotator(String name, Properties props) {
    // We are only interested in {name}.* properties
    String prefix = name + '.';
    String model = null;
    Properties segProps = new Properties();
    for (String key : props.stringPropertyNames()) {
        if (key.startsWith(prefix)) {
            // skip past name and the subsequent "."
            String modelKey = key.substring(prefix.length());
            if (modelKey.equals("model")) {
                model = props.getProperty(key);
            } else {
                segProps.setProperty(modelKey, props.getProperty(key));
            }
        }
    }
    this.VERBOSE = PropertiesUtils.getBool(props, name + ".verbose", true);
    init(model, segProps);

}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:21,代码来源:ArabicSegmentorAnnotator.java

示例9: main

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
public static void main (String[] args) {
    // Create the Stanford CoreNLP pipeline
    Properties props = PropertiesUtils.asProperties("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie",
            "parse.model", "edu/stanford/nlp/models/parser/nndep/english_SD.gz",
            "depparse.model", "edu/stanford/nlp/models/parser/nndep/english_SD.gz");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    // Annotate an example document.
    String text = "I went into my bedroom and flipped the light switch. Oh, I see that the ceiling lamp is not turning on." +
            " It must be that the light bulb needs replacement. I go through my closet and find a new light bulb that will fit" +
            " this lamp and place it in my pocket. I also get my stepladder and place it under the lamp. I make sure the light" +
            " switch is in the off position. I climb up the ladder and unscrew the old light bulb. I place the old bulb in my " +
            "pocket and take out the new one. I then screw in the new bulb. I climb down the stepladder and place it back into " +
            "the closet. I then throw out the old bulb into the recycling bin. I go back to my bedroom and turn on the light switch." +
            " I am happy to see that there is again light in my room.";
    Annotation doc = new Annotation(text);
    pipeline.annotate(doc);
    // Loop over sentences in the document
    int sentNo = 0;
    for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
        System.out.println("Sentence #" + ++sentNo + ": " + sentence.get(CoreAnnotations.TextAnnotation.class));
        // Get the OpenIE triples for the sentence
        Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
        // Print the triples
        for (RelationTriple triple : triples) {
            System.out.println(triple.confidence + "\t" + triple.subjectLemmaGloss() + "\t" + triple.relationLemmaGloss() + "\t" + triple.objectLemmaGloss());
        }
        System.out.println("\n");
    }

}
 
开发者ID:IsaacChanghau,项目名称:Word2VecfJava,代码行数:31,代码来源:StanfordOpenIEExample.java

示例10: JMWEAnnotator

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
/**
 * Annotator to capture Multi-Word Expressions (MWE).
 * @param name
 *            annotator name
 * @param props
 *            the properties
 */
public JMWEAnnotator(String name, Properties props) {
    // set verbosity
    this.verbose = PropertiesUtils.getBool(props, "customAnnotatorClass.jmwe.verbose", false);
    // set underscoreSpaceReplacement
    if (!PropertiesUtils.hasProperty(props, "customAnnotatorClass.jmwe.underscoreReplacement")) {
        throw new RuntimeException("No customAnnotatorClass.jmwe.underscoreReplacement key in properties found");
    }
    underscoreSpaceReplacement = (String) props.get("customAnnotatorClass.jmwe.underscoreReplacement");
    if (underscoreSpaceReplacement.contains("_")) {
        throw new RuntimeException("The underscoreReplacement contains an underscore character");
    }
    // set index
    if (!PropertiesUtils.hasProperty(props, "customAnnotatorClass.jmwe.indexData")) {
        throw new RuntimeException("No customAnnotatorClass.jmwe.indexData key in properties found");
    }
    File indexFile = new File((String) props.get("customAnnotatorClass.jmwe.indexData"));
    if (!indexFile.exists()) {
        throw new RuntimeException("index file " + indexFile.getAbsoluteFile() + " does not exist");
    }

    this.index = new MWEIndex(indexFile);
    // set detector
    if (!PropertiesUtils.hasProperty(props, "customAnnotatorClass.jmwe.detector")) {
        throw new RuntimeException("No customAnnotatorClass.jmwe.detector key in properties found");
    }
    this.detectorName = (String) props.get("customAnnotatorClass.jmwe.detector");

    if (this.verbose) {
        System.out.println("verbose: " + this.verbose);
        System.out.println("underscoreReplacement: " + this.underscoreSpaceReplacement);
        System.out.println("indexData: " + this.index);
        System.out.println("detectorName: " + this.detectorName);
    }
}
 
开发者ID:toliwa,项目名称:CoreNLP-jMWE,代码行数:42,代码来源:JMWEAnnotator.java

示例11: main

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

示例12: 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

示例13: main

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的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());
  int ngramOrder = PropertiesUtils.getInt(options, "order", BLEUMetric.DEFAULT_MAX_NGRAM_ORDER);
  boolean disableTokenization = PropertiesUtils.getBool(options, "no-nist", false);
  String metric = options.getProperty("metric", "bleu");

  String[] refs = options.getProperty("").split("\\s+");
  List<List<Sequence<IString>>> referencesList = MetricUtils.readReferences(refs, ! disableTokenization);
  System.err.printf("Metric: %s with %d references%n", metric, referencesList.get(0).size());
  
  LineNumberReader reader = new LineNumberReader(new InputStreamReader(
      System.in));
  int sourceInputId = 0;
  for (String line; (line = reader.readLine()) != null; ++sourceInputId) {
    line = disableTokenization ? line : NISTTokenizer.tokenize(line);
    Sequence<IString> translation = IStrings.tokenize(line);
    double score = getScore(translation, referencesList.get(sourceInputId), ngramOrder, metric);
    System.out.printf("%.4f%n", score);
  }
  System.err.printf("Scored %d input segments%n", sourceInputId);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:32,代码来源:SentenceLevelEvaluation.java

示例14: NGramLanguageModelFeaturizer

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
/**
 * Constructor called by Phrasal when NGramLanguageModelFeaturizer appears in
 * <code>Phrasal.LANGUAGE_MODEL_OPT</code>.
 * 
 * The first argument is always the language model filename and the second
 * argument is always the feature name.
 * 
 * Additional arguments are named parameters.
 */
public NGramLanguageModelFeaturizer(String...args) throws IOException {
  if (args.length < 2) {
    throw new RuntimeException(
        "At least two arguments are needed: LM file name and LM feature name");
  }
  // Load the LM
  this.lm = LanguageModelFactory.load(args[0]);
  this.startToken = lm.getStartToken();
  this.endToken = lm.getEndToken();

  // Set the feature name
  this.featureName = args[1];

  // Named parameters
  Properties options = FeatureUtils.argsToProperties(args);
  this.isClassBased = PropertiesUtils.getBool(options, "classBased", false);
  if (isClassBased && options.containsKey("classMap")) {
    // A local class map that differs from the one specified by Phrasal.TARGET_CLASS_MAP
    this.targetClassMap = new LocalTargetMap();
    this.targetClassMap.load(options.getProperty("classMap"));
  } else if (isClassBased) {
    this.targetClassMap = TargetClassMap.getInstance();
  } else {
    this.targetClassMap = null;
  }    
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:36,代码来源:NGramLanguageModelFeaturizer.java

示例15: LexicalReorderingFeaturizer

import edu.stanford.nlp.util.PropertiesUtils; //导入依赖的package包/类
/**
 * Constructor for reflection loading discriminative lexicalized reordering.
 * 
 * @param args
 */
public LexicalReorderingFeaturizer(String...args) {
  Properties options = FeatureUtils.argsToProperties(args);
  this.dynamic = PropertiesUtils.getBool(options, "dynamic", false);
  if (dynamic) {
    this.discriminativeSet = null;
    this.mlrt = null;
    this.featureTags = Arrays.stream(LexicalReorderingTable.msdBidirectionalPositionMapping).map(m -> 
    String.format("%s:%s", FEATURE_PREFIX, m)).toArray(String[]::new);
    this.useAlignmentConstellations = false;
    this.useClasses = false;
    this.countFeatureIndex = -1;
    this.lexicalCutoff = 0;

  } else {
    this.discriminativeSet = new ArrayList<>(Arrays.asList(LexicalReorderingTable.ReorderingTypes.values()));
    this.useAlignmentConstellations = options.containsKey("conditionOnConstellations");
    this.countFeatureIndex = PropertiesUtils.getInt(options, "countFeatureIndex", -1);
    // Which reordering classes to extract
    if (options.containsKey("classes")) {
      String[] typeStrings = options.getProperty("classes").split("-");
      discriminativeSet = new ArrayList<>();
      for (String type : typeStrings) {
        discriminativeSet.add(LexicalReorderingTable.ReorderingTypes.valueOf(type));
      }
    }
    // Use class-based feature representations
    this.useClasses = options.containsKey("useClasses");
    if (useClasses) {
      sourceMap = SourceClassMap.getInstance();
      targetMap = TargetClassMap.getInstance();
    }
    this.mlrt = null;
    this.featureTags = null;
    this.lexicalCutoff = PropertiesUtils.getInt(options, "lexicalCutoff", 0);
  }
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:42,代码来源:LexicalReorderingFeaturizer.java


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