Home | History | Annotate | Download | only in text
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4  *******************************************************************************
      5  * Copyright (C) 2012, International Business Machines Corporation and         *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 package com.ibm.icu.text;
     10 
     11 import java.text.CharacterIterator;
     12 
     13 /**
     14  * The DictionaryMatcher interface is used to allow arbitrary "types" of
     15  * back-end data structures to be used with the break iteration code.
     16  */
     17 abstract class DictionaryMatcher {
     18     /**
     19      * Find dictionary words that match the text.
     20      *
     21      * @param text A CharacterIterator representing the text. The iterator is
     22      *            left after the longest prefix match in the dictionary.
     23      * @param maxLength The maximum number of code units to match.
     24      * @param lengths An array that is filled with the lengths of words that matched.
     25      * @param count Filled with the number of elements output in lengths.
     26      * @param limit The maximum amount of words to output. Must be less than or equal to lengths.length.
     27      * @param values Filled with the weight values associated with the various words.
     28      * @return The number of characters in text that were matched.
     29      */
     30     public abstract int matches(CharacterIterator text, int maxLength, int[] lengths,
     31             int[] count, int limit, int[] values);
     32 
     33     public int matches(CharacterIterator text, int maxLength, int[] lengths,
     34             int[] count, int limit) {
     35         return matches(text, maxLength, lengths, count, limit, null);
     36     }
     37 
     38     /**
     39      * @return the kind of dictionary that this matcher is using
     40      */
     41     public abstract int getType();
     42 }
     43