Examples of HeadRules


Examples of opennlp.tools.parser.HeadRules

        System.err.println("Invalid option " + args[ai]);
        System.exit(1);
      }
      ai++;
    }
    HeadRules rules = new opennlp.tools.parser.lang.en.HeadRules(args[ai++]);
    if (fun) {
      Parse.useFunctionTags(true);
    }
    ObjectStream<Event> es = new ParserEventStream(new ParseSampleStream(new PlainTextByLineStream(new java.io.InputStreamReader(System.in))), rules, etype, dict);
    Event e;
View Full Code Here

Examples of opennlp.tools.parser.HeadRules

        System.err.println("Invalid option " + args[ai]);
        System.exit(1);
      }
      ai++;
    }
    HeadRules rules = new opennlp.tools.parser.lang.en.HeadRules(args[ai++]);
    Dictionary dict = null;
    if (ai < args.length) {
      dict = new Dictionary(new FileInputStream(args[ai++]),true);
    }
    if (fun) {
View Full Code Here

Examples of opennlp.tools.parser.HeadRules

    File modelOutFile = params.getModel();
    CmdLineUtil.checkOutputFile("parser model", modelOutFile);

    ParserModel model;
    try {
      HeadRules rules = creaeHeadRules(params);

      ParserType type = parseParserType(params.getParserType());
      if(params.getFun()){
        Parse.useFunctionTags(true);
      }
View Full Code Here

Examples of opennlp.tools.parser.HeadRules

      }
      argIndex++;
    }
    java.io.File inFile = new java.io.File(args[argIndex++]);
    String modelDirectory = args[argIndex++];
    HeadRules rules = new opennlp.tools.parser.lang.en.HeadRules(modelDirectory+"/head_rules");
    java.io.File tagFile = new java.io.File(modelDirectory+"/tag.bin.gz");
    java.io.File chunkFile = new java.io.File(modelDirectory+"/chunk.bin.gz");
    java.io.File buildFile = new java.io.File(modelDirectory+"/build.bin.gz");
    java.io.File attachFile = new java.io.File(modelDirectory+"/attach.bin.gz");
    java.io.File checkFile = new java.io.File(modelDirectory+"/check.bin.gz");
View Full Code Here

Examples of opennlp.tools.parser.HeadRules

    CmdLineUtil.checkOutputFile("parser model", modelOutFile);
   
    ParserModel model;
    try {
     
      HeadRules rules = new opennlp.tools.parser.lang.en.HeadRules(
          new InputStreamReader(new FileInputStream(new File(CmdLineUtil.getParameter("-head-rules", args))),
          parameters.getEncoding()));
     
      if (ParserType.CHUNKING.equals(parameters.getParserType())) {
        model = opennlp.tools.parser.chunking.Parser.train(
View Full Code Here

Examples of opennlp.tools.parser.lang.en.HeadRules

   public static HeadRules createTestHeadRules() throws IOException {
     InputStream headRulesIn =
       ParserTestUtil.class.getResourceAsStream("/opennlp/tools/parser/en_head_rules");
  
     HeadRules headRules = new HeadRules(new BufferedReader(
         new InputStreamReader(headRulesIn, "UTF-8")));
    
     headRulesIn.close();
    
     return headRules;
View Full Code Here

Examples of opennlp.tools.parser.lang.en.HeadRules

   public static HeadRules createTestHeadRules() throws IOException {
     InputStream headRulesIn =
       ParserTestUtil.class.getResourceAsStream("/opennlp/tools/parser/en_head_rules");

     HeadRules headRules = new HeadRules(new BufferedReader(
         new InputStreamReader(headRulesIn, "UTF-8")));

     headRulesIn.close();

     return headRules;
View Full Code Here

Examples of opennlp.tools.parser.lang.en.HeadRules

     
      MaxentModel buildModel = null;
      MaxentModel checkModel = null;
      POSTagger posTagger = null;
      Chunker chunker = null;
      HeadRules headRules = null;

      if (!d.isDirectory()) {
        FileInputStream fis = new FileInputStream(d);
        ParserModel model = new ParserModel(fis);
        parser = new Parser(model, AbstractBottomUpParser.defaultBeamSize, AbstractBottomUpParser.defaultAdvancePercentage);
      } else {
        // This branch is for handling models built with OpenNLp 1.4
        // Once the models are rebuilt using OpenNLP 1.5 this code should be removed
        // @see TreebankParser.java in OpenNLP 1.4
        {
          File f = new File(d, "build.bin.gz"); // TODO consider moving these literals to an XML file or properties file
          buildModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
        }
       
        {
          File f = new File(d, "check.bin.gz");
          checkModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
        }
       
        {
          File f = new File(d, "pos.model.bin");
          //File f = new File(d, "tag.bin.gz");
          MaxentModel posModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
          if (useTagDictionary) {
            File td = new File(d, "tagdict");
            TagDictionary tagDictionary = new POSDictionary(td.getAbsolutePath()); //null;
            posTagger = new POSTaggerME((AbstractModel) posModel, tagDictionary);
          } else {
            // f = new File(d, "dict.bin.gz");
            Dictionary dictionary = null; // new Dictionary();
            posTagger = new POSTaggerME((AbstractModel) posModel, dictionary);

          }
        }
       
       
        {
          File f = new File(d, "chunk.bin.gz");
          MaxentModel chunkModel = new opennlp.maxent.io.SuffixSensitiveGISModelReader(f).getModel();
          chunker = new ChunkerME(chunkModel);
        }
     
        {
          FileReader fr = new FileReader(new File(d, "head_rules"));
          headRules = new HeadRules(fr);
        }

        parser = new Parser(buildModel, checkModel, posTagger, chunker, headRules); //TreebankParser.getParser(modelFileOrDirname, useTagDictionary, useCaseSensitiveTagDictionary, AbstractBottomUpParser.defaultBeamSize, AbstractBottomUpParser.defaultAdvancePercentage);
      }
     
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.headrules.HeadRules

    this.headRules = headRules;
  }
 
  public void setHeadRules(String headRulesURL) throws MaltChainedException {
    if (headRulesURL != null && headRulesURL.length() > 0 && !headRulesURL.equals("*")) {
      headRules = new HeadRules(SystemLogger.logger(), phraseStructuretDataFormatInstance);
      headRules.parseHeadRules(headRulesURL);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.