Package com.clearnlp.constituent

Examples of com.clearnlp.constituent.CTTree


  }
 
  public void traverseCTTrees(String filename, ILambdaUnit1<CTTree> func) throws Exception
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(filename));
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
      func.apply(tree);
   
    reader.close();
View Full Code Here


  public void collectPhrases(String[] args) throws Exception
  {
    Prob1DMap map = new Prob1DMap();
    CTReader reader = new CTReader();
    reader.open(UTInput.createBufferedFileReader(args[0]));
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
      traverse(tree.getRoot(), map, args[2]);

    PrintStream ugram = UTOutput.createPrintBufferedFileStream(args[1]+".1gram");
    PrintStream ngram = UTOutput.createPrintBufferedFileStream(args[1]+".ngram");
    String s;
   
View Full Code Here

    ObjectIntHashMap<String> wcm = new ObjectIntHashMap<>();
    Pattern p = Pattern.compile("/");
    String root = args[1];
    CTReader reader;
    String genre;
    CTTree tree;
    int sc, wc;
   
    for (String id : ids)
    {
      reader = new CTReader(UTInput.createBufferedFileReader(root+"/"+id+".parse"));
      genre  = p.split(id)[0];
      sc = wc = 0;
     
      while ((tree = reader.nextTree()) != null)
      {
        wc += tree.getTokens().size();
        sc ++;
      }
     
      scm.put(genre, scm.get(genre)+sc);
      wcm.put(genre, wcm.get(genre)+wc);
View Full Code Here

    String O5_DIR = args[1];
   
    File root = new File(MY_DIR);
    CTReader myReader, o5Reader;
    String myPath, o5Path;
    CTTree myTree, o5Tree;
   
    for (File genre : root.listFiles())
    {
      if (!genre.isDirectory()) continue;
     
      for (File source : genre.listFiles())
      {
        if (!source.isDirectory()) continue;
       
        for (File section : source.listFiles())
        {
          if (!section.isDirectory())  continue;
         
          for (File myParse : section.listFiles(new FileExtFilter("parse")))
          {
            myPath = myParse.getPath();
            o5Path = O5_DIR + myPath.substring(MY_DIR.length());

            myReader = new CTReader(UTInput.createBufferedFileReader(myPath));
            o5Reader = new CTReader(UTInput.createBufferedFileReader(o5Path));
           
            while ((myTree = myReader.nextTree()) != null)
            {
              o5Tree = o5Reader.nextTree();
//             
              if (!myTree.compareBrackets(o5Tree))
              {
                System.out.println(myPath);
//                System.out.println(">"+myTree.toStringLine());
//                System.out.println("<"+o5Tree.toStringLine());
              }
View Full Code Here

  void checkConstituentTags(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    Set<String> phrases = new TreeSet<String>();
    Set<String> tokens  = new TreeSet<String>();
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
      checkConstituents(tree.getRoot(), phrases, tokens);
   
    reader.close();
   
    for (String s : phrasesSystem.out.println(s);
    System.out.println();
View Full Code Here

    CTReader  pin = new CTReader();
    TOKReader tin = new TOKReader(0);
   
    int i, size = ptbFiles.length;
    List<String> tokens;
    CTTree tree;
   
    for (i=0; i<size; i++)
    {
      pin.open(UTInput.createBufferedFileReader(ptbFiles[i]));
      tin.open(UTInput.createBufferedFileReader(rawFiles[i]));
      System.out.println(rawFiles[i]);
     
      while ((tree = pin.nextTree()) != null)
      {
        tokens = tin.next();
       
        if (tree.getTokens().size() != tokens.size())
          System.out.println(UTArray.join(tokens, " "));
      }
    }
  }
View Full Code Here

 
  void printTreebank(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
      fout.println(tree.toString()+"\n");
   
    reader.close();
    fout.close();
  }
View Full Code Here

    String[] inputFiles = UTFile.getSortedFileList(args[1], "ptb");
    String outputFile;
    PrintStream fout;
    CTReader reader;
    DEPTree dTree;
    CTTree cTree;
   
    for (String inputFile : inputFiles)
    {
      outputFile = UTFile.replaceExtension(inputFile, "dep");
      reader = new CTReader(UTInput.createBufferedFileReader(inputFile));
View Full Code Here

  void extractDEP(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    Set<String> set = new HashSet<String>();
    Pattern delim = Pattern.compile("\\+");
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
    {
      extractDEPAux(tree.getRoot(), set, delim);
    }

    List<String> list = new ArrayList<String>(set);
    Collections.sort(list);
    System.out.println(list);
View Full Code Here

  void extractPos(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    Set<String> set = new HashSet<String>();
    Pattern delim = Pattern.compile("\\+");
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
    {
      for (CTNode node : tree.getTokens())
        for (String pos : delim.split(node.pTag))
          set.add(pos);
    }
   
    List<String> l = new ArrayList<String>(set);
View Full Code Here

TOP

Related Classes of com.clearnlp.constituent.CTTree

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.