Package opennlp.ccg.parse

Examples of opennlp.ccg.parse.Parser


        Grammar grammar = new Grammar(grammarURL);
        Tokenizer tokenizer = grammar.lexicon.tokenizer;
        System.out.println();
       
        // set up parser
        Parser parser = new Parser(grammar);
        // instantiate scorer
        try {
            System.out.println("Instantiating parsing sign scorer from class: " + parseScorerClass);
            SignScorer parseScorer = (SignScorer) Class.forName(parseScorerClass).newInstance();
            parser.setSignScorer(parseScorer);
            System.out.println();
        } catch (Exception exc) {
            throw (RuntimeException) new RuntimeException().initCause(exc);
        }
        // instantiate supertagger
        try {
          Supertagger supertagger;
          if (supertaggerClass != null) {
                System.out.println("Instantiating supertagger from class: " + supertaggerClass);
                supertagger = (Supertagger) Class.forName(supertaggerClass).newInstance();
          }
          else {
            System.out.println("Instantiating supertagger from config file: " + stconfig);
            supertagger = WordAndPOSDictionaryLabellingStrategy.supertaggerFactory(stconfig);
          }
            parser.setSupertagger(supertagger);
            System.out.println();
        } catch (Exception exc) {
            throw (RuntimeException) new RuntimeException().initCause(exc);
        }
       
        // loop through input
        BufferedReader in = new BufferedReader(new FileReader(inputfile));
        String line;
        Map<String,String> predInfoMap = new HashMap<String,String>();
        System.out.println("Parsing " + inputfile);
        System.out.println();
        int count = 1;
        while ((line = in.readLine()) != null) {
          String id = "s" + count;
          try {
            // parse it
            System.out.println(line);
      parser.parse(line);
      int numParses = Math.min(nbestListSize, parser.getResult().size());
      for (int i=0; i < numParses; i++) {
          Sign thisParse = parser.getResult().get(i);
          // convert lf
          Category cat = thisParse.getCategory();
          LF convertedLF = null;
          String predInfo = null;
          if (cat.getLF() != null) {
View Full Code Here


     * first parse, or an empty list, if it cannot be parsed.
     */
    // NB: Could try to extend this to find the parse with the intended LF.
    public List<Word> getParsedWords(String s) {
        // ensure parser instantiated
        if (parser == null) parser = new Parser(this);
        // get parses
        try {
            parser.parse(s);
        }
        catch (ParseException pe) {
View Full Code Here

            System.exit(0);
        }
       
        // setup parser
        if (tester.doParsing) {
            tester.parser = new Parser(tester.grammar);
            // instantiate scorer, if any
            if (parseScorerClass != null) {
                try {
                    System.out.println("Instantiating parsing sign scorer from class: " + parseScorerClass);
                    tester.parseScorer = (SignScorer) Class.forName(parseScorerClass).newInstance();
View Full Code Here

TOP

Related Classes of opennlp.ccg.parse.Parser

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.