コード例 #1
0
ファイル: Thesaurus.java プロジェクト: phspaelti/basex
 /**
  * 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
ファイル: Thesaurus.java プロジェクト: phspaelti/basex
  /**
   * 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);
    }
  }