Class Concept

java.lang.Object
smile.taxonomy.Concept

public class Concept extends Object
Concept is a set of synonyms, i.e. group of words that are roughly synonymous in a given context.
  • Constructor Details

    • Concept

      public Concept(Concept parent, String... keywords)
      Constructor.
      Parameters:
      keywords - a list of keywords of this concept
      parent - the parent concept
  • Method Details

    • isLeaf

      public boolean isLeaf()
      Check if a node is a leaf in the taxonomy tree.
      Returns:
      true if a node is a leaf.
    • keywords

      public Set<String> keywords()
      Returns the concept synonym set.
      Returns:
      concept synomym set.
    • addKeywords

      public void addKeywords(String... keywords)
      Adds a list of synomym to the concept synset.
      Parameters:
      keywords - the synomyms.
    • removeKeyword

      public void removeKeyword(String keyword)
      Removes a keyword from the concept synset.
      Parameters:
      keyword - the keyword.
    • children

      public List<Concept> children()
      Gets all children concepts.
      Returns:
      a vector of children concepts.
    • addChild

      public Concept addChild(String concept)
      Adds a child to this node.
      Parameters:
      concept - the concept.
      Returns:
      the child node.
    • addChild

      public void addChild(Concept concept)
      Adds a child to this node.
      Parameters:
      concept - the concept.
    • removeChild

      public boolean removeChild(Concept concept)
      Removes a child to this node.
      Parameters:
      concept - the concept.
      Returns:
      true if the given concept is a child.
    • isAncestorOf

      public boolean isAncestorOf(Concept concept)
      Returns true if this concept is an ancestor of the given concept.
      Parameters:
      concept - the concept.
      Returns:
      true if this concept is an ancestor of the given concept.
    • getPathFromRoot

      public List<Concept> getPathFromRoot()
      Returns the path from root to this node.
      Returns:
      the path from root to this node.
    • getPathToRoot

      public List<Concept> getPathToRoot()
      Returns the path from this node to the root.
      Returns:
      the path from this node to the root.
    • toString

      public String toString()
      Overrides:
      toString in class Object