Class PartOfSpeech

  • All Implemented Interfaces:
    Tag, Serializable

    public final class PartOfSpeech
    extends Object
    implements Tag, Serializable

    Interface defining a part-of-speech. A part-of-speech has an associated name representing a human-readable label, a tag which is used in annotated corpora, and a UniversalFeatureSet set relating to the features the tag invokes.

    Out-of-the-box Hermes provides the Universal and Penn Treebank tag sets. New tags can be created by calling create(String, String, PartOfSpeech, boolean, Tuple2[]), which will register the tag. Note: It is important that name and tag are unique. In the case where a pos tag would have the same name or tag value, it should reuse an existing tag when compatible or prefix the name and tag with a tag set identifier, e.g. if we want a tag with the name "NN" and it does not correspond to the Penn Treebank tag, we could prefix with tag set identifier, like "myNN". Note: This means your training and testing corpora will need to be modified to include the prefix.

    See Also:
    Serialized Form
    • Method Detail

      • forText

        public static PartOfSpeech forText​(@NonNull
                                           @NonNull HString text)
        Determines the best fundamental POS (NOUN, VERB, ADJECTIVE, or ADVERB) for a text.
        Parameters:
        text - The text
        Returns:
        The part of speech
      • valueOf

        public static PartOfSpeech valueOf​(String nameOrTag)
        Gets the PartOfSpeech from the given name or tag
        Parameters:
        nameOrTag - the name or tag of the PartOfSpeech we want
        Returns:
        the PartOfSpeech
      • values

        public static Collection<PartOfSpeech> values()
        Returns:
        All known and registered PartOfSpeech tags
      • getUniversalTag

        public PartOfSpeech getUniversalTag()
        Returns:
        The Universal PartOfSpeech this PartOfSpeech maps to
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isAdjective

        public boolean isAdjective()
        Returns:
        True if this PartOfSpeech is an Adjective
      • isAdposition

        public boolean isAdposition()
        Returns:
        True if this PartOfSpeech is an Adposition
      • isAdverb

        public boolean isAdverb()
        Returns:
        True if this PartOfSpeech is an Adverb
      • isAuxiliary

        public boolean isAuxiliary()
        Returns:
        True if this PartOfSpeech is an Auxiliary
      • isCoordinatingConjunction

        public boolean isCoordinatingConjunction()
        Returns:
        True if this PartOfSpeech is a Coordinating Conjunction
      • isDeterminer

        public boolean isDeterminer()
        Returns:
        True if this PartOfSpeech is a Determiner
      • isInstance

        public boolean isInstance​(@NonNull
                                  @NonNull Tag tag)
        Specified by:
        isInstance in interface Tag
      • isInterjection

        public boolean isInterjection()
        Returns:
        True if this PartOfSpeech is an Interjection
      • isNoun

        public boolean isNoun()
        Returns:
        True if this PartOfSpeech is a Noun
      • isNumeral

        public boolean isNumeral()
        Returns:
        True if this PartOfSpeech is a Numeral
      • isParticle

        public boolean isParticle()
        Returns:
        True if this PartOfSpeech is a Particle
      • isPronoun

        public boolean isPronoun()
        Returns:
        True if this PartOfSpeech is a Pronoun
      • isProperNoun

        public boolean isProperNoun()
        Returns:
        True if this PartOfSpeech is a Proper Noun
      • isPunctuation

        public boolean isPunctuation()
        Returns:
        True if this PartOfSpeech is a Punctuation
      • isSubordinationConjunction

        public boolean isSubordinationConjunction()
        Returns:
        True if this PartOfSpeech is a Subordination Conjunction
      • isSymbol

        public boolean isSymbol()
        Returns:
        True if this PartOfSpeech is a Symbol
      • isUniversalTag

        public boolean isUniversalTag()
        Returns:
        True if this PartOfSpeech represents a Universal POS tag.
      • isVerb

        public boolean isVerb()
        Returns:
        True if this PartOfSpeech is a verb
      • name

        public String name()
        Specified by:
        name in interface Tag
      • tag

        public String tag()
        Returns:
        the tag form of the PartOfSpeech