コード例 #1
0
ファイル: FuzzyMatchAll.java プロジェクト: NCIP/cadsr-cgmdr
 public Sequence evalQuery(NodeSet nodes, List terms) throws XPathException {
   if (terms == null || terms.size() == 0) return Sequence.EMPTY_SEQUENCE; // no search terms
   double threshold = 0.65;
   if (getArgumentCount() == 3) {
     Sequence thresOpt = getArgument(2).eval(nodes);
     // TODO : get rid of getLength()
     if (!thresOpt.hasOne())
       throw new XPathException(
           getASTNode(), "third argument to " + getName() + "should be a single double value");
     threshold = ((DoubleValue) thresOpt.convertTo(Type.DOUBLE)).getDouble();
   }
   NodeSet hits[] = new NodeSet[terms.size()];
   String term;
   TermMatcher matcher;
   for (int k = 0; k < terms.size(); k++) {
     term = (String) terms.get(k);
     if (term.length() == 0) hits[k] = null;
     else {
       matcher = new FuzzyMatcher(term, threshold);
       hits[k] =
           context
               .getBroker()
               .getTextEngine()
               .getNodes(
                   context,
                   nodes.getDocumentSet(),
                   nodes,
                   NodeSet.ANCESTOR,
                   null,
                   matcher,
                   term.substring(0, 1));
     }
   }
   return mergeResults(hits);
 }
コード例 #2
0
ファイル: Atomize.java プロジェクト: NCIP/cadsr-cgmdr-nci-uk
 public static Sequence atomize(Sequence input) throws XPathException {
   if (input.hasOne()) return input.itemAt(0).atomize();
   Item next;
   ValueSequence result = new ValueSequence();
   for (SequenceIterator i = input.iterate(); i.hasNext(); ) {
     next = i.nextItem();
     result.add(next.atomize());
   }
   return result;
 }