예제 #1
0
 /**
  * Returns a node for the specified term.
  *
  * @param term term
  * @return node
  */
 private ThesNode node(final byte[] term) {
   ThesNode node = nodes.get(term);
   if (node == null) {
     node = new ThesNode();
     node.term = term;
     nodes.put(term, node);
   }
   return node;
 }
예제 #2
0
  /**
   * Builds the thesaurus.
   *
   * @param value input nodes
   * @throws QueryException query exception
   */
  private void build(final Value value) throws QueryException {
    final Value synonyms = nodes("*:synonym", value);
    if (synonyms.isEmpty()) return;

    final ThesNode term = node(text("*:term", value));
    for (final Item synonym : synonyms) {
      final ThesNode sterm = node(text("*:term", synonym));
      final byte[] rs = text("*:relationship", synonym);
      term.add(sterm, rs);

      final byte[] srs = RSHIPS.get(rs);
      if (srs != null) sterm.add(term, srs);
      build(synonyms);
    }
  }