ULAPI  8.0
uldefiner.h
1 
7 #ifndef ULDEFINER_H
8 #define ULDEFINER_H
9 
10 #include "uldictionary.h"
11 #include "uldictionarydatasource.h"
12 #include "ulstemmer.h"
13 
19 class ULDefiner : public ULDictionary
20 {
21  UL_TEST_FRIEND;
22 
23 public:
24  ULDefiner();
25  ULDefiner(const ULDefiner& other);
26  virtual ~ULDefiner();
27 
28  ULDefiner& operator=(const ULDefiner& other);
29  virtual void clear();
30 
31  // ULWorker operations.
32  virtual bool isServiceAvailable(const ULServiceDescriptor& service);
33  virtual void getAvailableServices(ULList<ULServiceDescriptor>& serviceList);
34 
35  // Accessors.
38 
39  void setFirstStemmer(ULStemmer *stemmer);
41 
42  void setSecondStemmer(ULStemmer *stemmer);
44 
45  // ULDictionary operations.
46  virtual ULError begin(const ULLanguage& searchLanguage,
47  uluint32 indexID,
48  ULDictionaryIterator& iterator);
49 
50  virtual ULError end(const ULLanguage& searchLanguage,
51  uluint32 indexID,
52  ULDictionaryIterator& iterator);
53 
54  virtual ULError find(const ULString& s,
55  const ULLanguage& searchLanguage,
56  uluint32 indexID,
57  ULDictionaryIterator& iterator);
58 
59  // Definition support beyond the ULDictionary operations.
60  ULError simpleFind(const ULString& s,
61  const ULLanguage& searchLanguage,
62  ULDictionaryIterator& iterator);
63 
64  ULError find(const ULString& searchString,
65  const ULLanguage& searchLanguage,
66  ULDictionaryIterator& dictionaryIterator);
67 
68  ULError getHeadwordSearchResults(const ULString& originalSearchString,
69  const ULLanguage& searchLanguage,
70  uluint32 maxBrowsingResults,
71  uluint32 approximateRequiredPrefixLength,
72  /* Out: */
73  ULList<ULDerivation>& stemmingMatches,
74  ULList<ULDerivation>& substringMatches,
75  ULList<ULDerivation>& approximateMatches);
76 
77  ULError lookUp(const ULString& searchString,
78  const ULLanguage& searchLanguage,
80 
81 private:
82  ULDictionaryDataSource *dictionaryDataSource;
83  ULStemmer *firstStemmer;
84  ULStemmer *secondStemmer;
85 
86  enum { MaxHeadwordResults=50 };
87 
88  // Utility functions for lookUp.
89  void tokenize(const ULString& s, const ULLanguage& language, ULList<ULString>& tokenList);
90  uluint32 getNextRawToken(ULStringIterator& it, ULString& token);
91  bool hasInsensitiveSubstring(const ULString& haystack, const ULString& needle, const ULLanguage& language);
92  ULLanguageDataSource *getLanguageDataSource(const ULLanguage& language);
93  ULStemmer *getStemmerForLanguage(const ULLanguage& language); // Needed to get correct stemmer w/o bad accesses
94 };
95 
96 #endif
97