Class WordCounter


  • public class WordCounter
    extends BaseCounter
    Word Count engine. Contains static methods to calculate number of words in a given text fragment.
    • Constructor Detail

      • WordCounter

        public WordCounter()
    • Method Detail

      • count

        public static long count​(ITextUnit textUnit,
                                 LocaleId language)
        Counts words in the source part of a given text unit.
        Parameters:
        textUnit - the given text unit
        language - the language of the source
        Returns:
        number of words
      • count

        public static long count​(TextContainer textContainer,
                                 LocaleId language)
        Counts words in a given text container.
        Parameters:
        textContainer - the given text container
        language - the language of the text
        Returns:
        number of words
      • count

        public static long count​(Segment segment,
                                 LocaleId language)
        Counts words in a given segment.
        Parameters:
        segment - the given segment
        language - the language of the text
        Returns:
        number of words
      • count

        public static long count​(TextFragment textFragment,
                                 LocaleId language)
        Counts words in a given text fragment.
        Parameters:
        textFragment - the given text fragment
        language - the language of the text
        Returns:
        number of words
      • count

        public static long count​(String string,
                                 LocaleId language)
        Counts words in a given string.
        Parameters:
        string - the given string
        language - the language of the text
        Returns:
        number of words
      • getCount

        public static long getCount​(IWithAnnotations res)
        Returns the word count information stored by WordCountStep in annotations of a given resource.
        Parameters:
        res - the given resource
        Returns:
        number of words (0 if no word count information found)
      • getCount

        public static long getCount​(ITextUnit tu)
        Returns the word count information stored by WordCountStep in the source part of a given text unit.
        Parameters:
        tu - the given text unit
        Returns:
        number of words (0 if no word count information found)
      • getCount

        public static long getCount​(TextContainer tc)
        Returns the word count information stored by WordCountStep in the given text container.
        Parameters:
        tc - the given text container
        Returns:
        number of words (0 if no word count information found)
      • getCount

        public static long getCount​(ITextUnit tu,
                                    int segIndex)
        Returns the word count information stored by WordCountStep in a given segment of the source part of a given text unit.
        Parameters:
        tu - the given tu
        segIndex - index of the segment in the source
        Returns:
        number of words (0 if no word count information found)
      • getCount

        public static long getCount​(Segment segment)
        Returns the word count information stored by WordCountStep in a given segment of the source part of a given text unit.
        Parameters:
        segment - the given segment
        Returns:
        number of words (0 if no word count information found)