Class Taxonomy

java.lang.Object
smile.taxonomy.Taxonomy

public class Taxonomy extends Object
A taxonomy is a tree of terms (aka concept) where leaves must be named but intermediary nodes can be anonymous.
  • Constructor Details

    • Taxonomy

      public Taxonomy(String... rootConcept)
      Constructor.
      Parameters:
      rootConcept - the keyword of root concept.
  • Method Details

    • getRoot

      public Concept getRoot()
      Returns the root node of taxonomy tree.
      Returns:
      root node.
    • getConcept

      public Concept getConcept(String keyword)
      Returns the concept node which synset contains the keyword.
      Parameters:
      keyword - the keyword.
      Returns:
      the concept node which synset contains the keyword.
    • getConcepts

      public List<String> getConcepts()
      Returns all named concepts in the taxonomy.
      Returns:
      all named concepts.
    • lowestCommonAncestor

      public Concept lowestCommonAncestor(String v, String w)
      Returns the lowest common ancestor (LCA) of concepts v and w. The lowest common ancestor is defined between two nodes v and w as the lowest node that has both v and w as descendants (where we allow a node to be a descendant of itself).
      Parameters:
      v - a concept.
      w - the other concept.
      Returns:
      the lowest common ancestor.
    • lowestCommonAncestor

      public Concept lowestCommonAncestor(Concept v, Concept w)
      Returns the lowest common ancestor (LCA) of concepts v and w. The lowest common ancestor is defined between two nodes v and w as the lowest node that has both v and w as descendants (where we allow a node to be a descendant of itself).
      Parameters:
      v - a concept.
      w - the other concept.
      Returns:
      the lowest common ancestor.