WordCountDirectionEstimator class
Direction estimator that uses the "word count" heuristic.
Note: this is probably the recommended estimator for most use cases.
class WordCountDirectionEstimator extends DirectionEstimator { /** * An instance of WordCountDirectionEstimator, to be returned by {@link #get}. */ static final WordCountDirectionEstimator instance = new WordCountDirectionEstimator(); /** * Get an instance of WordCountDirectionEstimator. * * @return An instance of WordCountDirectionEstimator. */ static WordCountDirectionEstimator get() { return instance; } /** * Estimates the direction of a given string using the "word count" heuristic, * as defined at {@link BidiUtils#estimateDirection}. * * @param str Input string. * @return Direction The estimated direction of {@code str}. */ Direction estimateDirection(String str, [bool isHtml = false]) { return BidiUtils.get().estimateDirection(str); } }
Extends
DirectionEstimator > WordCountDirectionEstimator
Static Properties
final WordCountDirectionEstimator instance #
An instance of WordCountDirectionEstimator, to be returned by {@link #get}.
static final WordCountDirectionEstimator instance = new WordCountDirectionEstimator()
Static Methods
WordCountDirectionEstimator get() #
Get an instance of WordCountDirectionEstimator.
@return An instance of WordCountDirectionEstimator.
static WordCountDirectionEstimator get() { return instance; }
Methods
Direction estimateDirection(String str, [bool isHtml = false]) #
Estimates the direction of a given string using the "word count" heuristic, as defined at {@link BidiUtils#estimateDirection}.
@param str Input string. @return Direction The estimated direction of {@code str}.
Direction estimateDirection(String str, [bool isHtml = false]) { return BidiUtils.get().estimateDirection(str); }
Direction estimateSafetmlDirection(SafeHtml html) #
Estimates the direction of a SafeHtml.
@param html The string to check. @return {@code html}'s estimated direction.
Direction estimateSafetmlDirection(SafeHtml html) { return estimateDirection(BidiUtils.get().stripHtmlIfNeeded(html.asString(), true)); }
Direction estimateStringDirection(String str, [bool isHtml = false]) #
Estimates the direction of a string.
@param str The string to check. @param isHtml Whether {@code str} is HTML / HTML-escaped. {@code false}
means that {@code str} is plain-text.
@return {@code str}'s estimated direction.
Direction estimateStringDirection(String str, [bool isHtml = false]) { return estimateDirection(BidiUtils.get().stripHtmlIfNeeded(str, isHtml)); }