Examples of CTTree


Examples of com.clearnlp.constituent.CTTree

 
  void splitTrees(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    PrintStream[] fout = new PrintStream[4];
    CTTree tree;
    int i, j;
   
    fout[0] = UTOutput.createPrintBufferedFileStream(args[0]+".trn.parse");
    fout[1] = UTOutput.createPrintBufferedFileStream(args[0]+".trn.raw");
    fout[2] = UTOutput.createPrintBufferedFileStream(args[0]+".tst.parse");
    fout[3] = UTOutput.createPrintBufferedFileStream(args[0]+".tst.raw");
   
    for (i=0; (tree = reader.nextTree()) != null; i++)
    {
      j = (i%6 == 0) ? 2 : 0;
     
      fout[j.println(tree.toString()+"\n");
      fout[j+1].println(tree.toForms());
    }
   
    for (PrintStream f : foutf.close();
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

    String treeDir = args[0];
    String treeFile = args[1];
    int treeId = Integer.parseInt(args[2]);
   
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(treeDir+File.separator+treeFile));
    CTTree tree = null;
    int i;
   
    for (i=0; i<=treeId; i++)
      tree = reader.nextTree();
   
    System.out.println(tree.toString(true,true));
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

 
  void printTreesForCKY(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    CTTree tree;
    CTNode root;
    int count;
   
    while ((tree = reader.nextTree()) != null)
    {
      root = tree.getRoot();
     
      if (root.getChildrenSize() == 1)
      {
        count = stripPunct(tree);
       
        if (root.getChildrenSize() > 0 && tree.getTokens().size()-count >= 4 && !containsEmptyCategories(tree) && isCKYTree(root.getChild(0)))
          fout.println(tree+"\n");
      }
    }
   
    reader.close();
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

  }
 
  void traverse(String inputFile)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(inputFile));
    CTTree tree;
   
    while ((tree = reader.nextTree()) != null)
      traverseAux(tree.getRoot());
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

      }
      catch (Exception e) {e.printStackTrace();}
     
      PrintStream fout = UTOutput.createPrintBufferedFileStream(UTFile.replaceExtension(inputPath, outputExt));
      CTReader reader = new CTReader(UTInput.createBufferedFileReader(inputPath));
      CTTree cTree; DEPTree dTree; int n;
      List<PBInstance> instances = null;
     
      for (n=0; (cTree = reader.nextTree()) != null; n++)
      {
        if (language.equals(AbstractReader.LANG_EN))
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

 
  protected int convert(AbstractC2DConverter c2d, AbstractComponent morph, String language, String inputFile, String outputFile, boolean normalize)
  {
    CTReader  reader = new CTReader(UTInput.createBufferedFileReader(inputFile));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(outputFile);
    CTTree  cTree;
    DEPTree dTree;
    int n;
   
    for (n=0; (cTree = reader.nextTree()) != null; n++)
    {
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

  public void postProcess(String propFile, String postFile, String treeDir, boolean norm, String language)
  {
    List<PBInstance> instances = PBLib.getPBInstanceList(propFile, treeDir, norm);
    List<PBInstance> remove = new ArrayList<PBInstance>();
    mergeLightVerbs(instances);
    CTTree tree;
    PBArg  aDSP;
   
    for (PBInstance instance : instances)
    {
      System.out.println(instance.getKey());
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

  }
 
  /** Returns {@code true} if the specific instance includes arguments misaligned to the constituent tree. */
  private boolean findMisalignedArgs(PBInstance instance)
  {
    CTTree tree  = instance.getTree();
    String label = null;
   
    if (!tree.isRange(instance.predId, 0) ||
      (instance.isVerbPredicate() && !tree.getTerminal(instance.predId).pTag.startsWith("VB")) ||
      (instance.isNounPredicate() && !tree.getTerminal(instance.predId).pTag.startsWith("NN")))
    {
      label = PBLib.PB_REL;
    }
    else
    {
      outer: for (PBArg arg : instance.getArgs())
      {
        for (PBLoc loc : arg.getLocs())
        {
          if (!tree.isRange(loc))
          {
            label = arg.label;
            break outer;
          }
         
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

   * PRE: {@link PBInstance#sortArgs()} is called.
   */
  private void joinConcatenations(PBInstance instance)
  {
    SortedIntArrayList ids = new SortedIntArrayList();
    CTTree tree = instance.getTree();
    int terminalId, height;
    CTNode node, parent;
    List<PBLoc> lNew;
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
      ids.clear();
     
      for (PBLoc loc : arg.getLocs())
      {
        if (!loc.isType("") && !loc.isType(","))  return;
        if (loc.height > 0)              return;
        ids.add(loc.terminalId);
      }
     
      lNew = new ArrayList<PBLoc>();
     
      while (!ids.isEmpty())
      {
        terminalId = ids.get(0);
        height     = 0;
        node       = tree.getNode(terminalId, height);
       
        while ((parent = node.getParent()) != null && !parent.isPTag(CTLib.PTAG_TOP) && UTHppc.isSubset(ids, parent.getSubTerminalIdSet()))
        {
          node = parent;
          height++;
View Full Code Here

Examples of com.clearnlp.constituent.CTTree

   * Fixes locations cyclic to its predicate.
   * PRE: {@link PBInstance#sortArgs()} is called.
   */
  private void fixCyclicLocs(PBInstance instance)
  {
    CTTree  tree  = instance.getTree();
    int    predId = instance.predId;
    boolean isCyc = false;
    CTNode  node, tmp;
   
    StringBuilder build = new StringBuilder();
    build.append(ERR_CYCLIC);
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
     
      for (PBLoc loc : arg.getLocs())
      {
        if ((node = tree.getNode(loc)).getSubTerminalIdSet().contains(predId))
        {
          if (arg.isLabel(PBLib.PB_ARGM_MOD))
            loc.height = 0;
          else if (arg.isLabel(PBLib.PB_LINK_SLC) && node.isPTag(CTLibEn.PTAG_SBAR) && (tmp = node.getFirstChild("+WH.*")) != null)
            loc.set(tmp.getPBLoc(), loc.type);
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.