Exemplo n.º 1
0
 public FeatureFileIndexingResult retrieve(FeatureVector v, int condition, int parameter) {
   int level = 0;
   /* Check if the tree is there */
   if (tree == null) {
     throw new RuntimeException(
         "Can't retrieve candidate units if a tree has not been built."
             + " (Run this.deepSort(int[]) or this.deepFill(MaryNode) first.)");
   }
   //      /**/
   //      /* TODO: Do we want the warning below? */
   //      /*if ( (condition == MAXLEVEL) && (featureSequence != null) && (parameter >
   // featureSequence.length) ) {
   //          System.out.println( "WARNING: you asked for more levels [" + maxLevel
   //                  + "] than the length of the underlying feature sequence[" +
   // featureSequence.length + "]. Proceeding anyways." );
   //      }*/
   /* Walk down the tree */
   MaryNode n = tree;
   MaryNode next = null;
   while (!n.isLeaf()) {
     next = n.getChild(v.getFeatureAsInt(n.getFeatureIndex()));
     /* Check for the number of units in the next node */
     if ((condition == MINUNITS) && ((next.to - next.from) < parameter)) break;
     /* Check if the next node is a dead branch */
     if (next != null) {
       n = next;
       level++;
     } else break;
     /* Check for the current level */
     if ((condition == MAXLEVEL) && (level == parameter)) break;
   }
   /* Dereference the reached node or leaf */
   FeatureFileIndexingResult qr =
       new FeatureFileIndexingResult(getFeatureVectors(n.from, n.to), level);
   return (qr);
 }
Exemplo n.º 2
0
 /**
  * Retrieve an array of unit features which complies with a specific target specification,
  * according to an underlying tree.
  *
  * @param v A feature vector for which to send back an array of complying unit indexes.
  * @return A query result, comprising an array of feature vectors and the depth level which was
  *     actually reached.
  * @see FeatureArrayIndexer#deepSort(int[])
  * @see FeatureArrayIndexer#deepFill(MaryNode)
  */
 public FeatureFileIndexingResult retrieve(FeatureVector v) {
   int level = 0;
   /* Check if the tree is there */
   if (tree == null) {
     throw new RuntimeException(
         "Can't retrieve candidate units if a tree has not been built."
             + " (Run this.deepSort(int[]) or this.deepFill(MaryNode) first.)");
   }
   /* Walk down the tree */
   MaryNode n = tree;
   MaryNode next = null;
   while (!n.isLeaf()) {
     next = n.getChild(v.getFeatureAsInt(n.getFeatureIndex()));
     /* Check if the next node is a dead branch */
     if (next != null) {
       n = next;
       level++;
     } else break;
   }
   /* Dereference the reached node or leaf */
   FeatureFileIndexingResult qr =
       new FeatureFileIndexingResult(getFeatureVectors(n.from, n.to), level);
   return (qr);
 }