Package opennlp.tools.dictionary

Examples of opennlp.tools.dictionary.Dictionary


      System.exit(1);
    }
    ParserEventTypeEnum etype = null;
    boolean fun = false;
    int ai = 0;
    Dictionary dict = null;
    AbstractModel model = null;

    while (ai < args.length && args[ai].startsWith("-")) {
      if (args[ai].equals("-build")) {
        etype = ParserEventTypeEnum.BUILD;
      }
      else if (args[ai].equals("-attach")) {
        etype = ParserEventTypeEnum.ATTACH;
      }
      else if (args[ai].equals("-chunk")) {
        etype = ParserEventTypeEnum.CHUNK;
      }
      else if (args[ai].equals("-check")) {
        etype = ParserEventTypeEnum.CHECK;
      }
      else if (args[ai].equals("-tag")) {
        etype = ParserEventTypeEnum.TAG;
      }
      else if (args[ai].equals("-fun")) {
        fun = true;
      }
      else if (args[ai].equals("-dict")) {
        ai++;
        dict = new Dictionary(new FileInputStream(args[ai]));
      }
      else if (args[ai].equals("-model")) {
        ai++;
        model = (new SuffixSensitiveGISModelReader(new File(args[ai]))).getModel();
      }
View Full Code Here


    return new BinaryGISModelReader(new DataInputStream(new GZIPInputStream(
        new FileInputStream(fileName)))).getModel();
  }

  private static Dictionary readNames(String nameFile) throws IOException {
    Dictionary names = new Dictionary();

    BufferedReader nameReader = new BufferedReader(new FileReader(nameFile));
    for (String line = nameReader.readLine(); line != null; line = nameReader.readLine()) {
      names.put(new StringList(line));
    }

    return names;
  }
View Full Code Here

class DictionarySerializer implements ArtifactSerializer<Dictionary> {

  public Dictionary create(InputStream in) throws IOException,
      InvalidFormatException {
    return new Dictionary(in);
  }
View Full Code Here

  public static ParserModel train(String languageCode, ObjectStream<Parse> parseSamples, HeadRules rules, TrainingParameters mlParams)
          throws IOException {
   
    System.err.println("Building dictionary");
   
    Dictionary mdict = buildDictionary(parseSamples, rules, mlParams);
   
    parseSamples.reset();
   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
   
View Full Code Here

  throws IOException {
   
    Map<String, String> manifestInfoEntries = new HashMap<String, String>();
   
    System.err.println("Building dictionary");
    Dictionary mdict = buildDictionary(parseSamples, rules, mlParams);
   
    parseSamples.reset();
   
    // tag
    POSModel posModel = POSTaggerME.train(languageCode, new PosSampleStream(
View Full Code Here

   *
   * @return a dictionary of the ngrams
   */
  public Dictionary toDictionary(boolean caseSensitive) {

    Dictionary dict = new Dictionary(caseSensitive);

    for (StringList stringList : this) {
      dict.put(stringList);
    }

    return dict;
  }
View Full Code Here

  @Override
  protected ParserModel trainAndUpdate(ParserModel originalModel,
      ObjectStream<Parse> parseSamples, ModelUpdaterParams parameters)
      throws IOException {
   
      Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), parameters.getCutoff());
     
      parseSamples.reset();
     
      // TODO: training individual models should be in the chunking parser, not here
      // Training build
View Full Code Here

  }
 
  static Dictionary buildDictionary(ObjectStream<Parse> parseSamples, HeadRules headRules, int cutoff) {
    System.err.print("Building dictionary ...");
   
    Dictionary mdict;
    try {
      mdict = Parser.
          buildDictionary(parseSamples, headRules, cutoff);
    } catch (IOException e) {
      System.err.println("Error while building dictionary: " + e.getMessage());
View Full Code Here

class DictionarySerializer implements ArtifactSerializer<Dictionary> {

  public Dictionary create(InputStream in) throws IOException,
      InvalidFormatException {
    return new Dictionary(in);
  }
View Full Code Here

  @Override
  protected ParserModel trainAndUpdate(ParserModel originalModel,
      ObjectStream<Parse> parseSamples, ModelUpdaterParams parameters)
      throws IOException {
   
      Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), parameters.getCutoff());
     
      parseSamples.reset();
     
      // TODO: Maybe that should be part of the ChunkingParser ...
      // Training build
View Full Code Here

TOP

Related Classes of opennlp.tools.dictionary.Dictionary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.