Package opennlp.tools.lang.english

Examples of opennlp.tools.lang.english.TreebankLinker


    if (args.length != 1) {
      System.out.println(getHelp());
    }
    else {
     
      TreebankLinker treebankLinker;
      try {
        treebankLinker = new TreebankLinker(args[0], LinkerMode.TEST);
      } catch (IOException e) {
        throw new TerminateToolException(-1, "Failed to load all coreferencer models!", e);
      }
     
      ObjectStream<String> lineStream =
          new PlainTextByLineStream(new InputStreamReader(System.in));
     
      PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "parses");
      perfMon.start();
     
      try {
       
        int sentenceNumber = 0;
        List<Mention> document = new ArrayList<Mention>();
        List<Parse> parses = new ArrayList<Parse>();
       
        String line;
        while ((line = lineStream.read()) != null) {

          if (line.equals("")) {
            DiscourseEntity[] entities = treebankLinker.getEntities(document.toArray(new Mention[document.size()]));
            //showEntities(entities);
            new CorefParse(parses,entities).show();
            sentenceNumber=0;
            document.clear();
            parses.clear();
          }
          else {
            Parse p = Parse.parseParse(line);
            parses.add(p);
            Mention[] extents = treebankLinker.getMentionFinder().getMentions(new DefaultParse(p,sentenceNumber));
            //construct new parses for mentions which don't have constituents.
            for (int ei=0,en=extents.length;ei<en;ei++) {
              //System.err.println("PennTreebankLiner.main: "+ei+" "+extents[ei]);

              if (extents[ei].getParse() == null) {
View Full Code Here

TOP

Related Classes of opennlp.tools.lang.english.TreebankLinker

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.