1 /*
2  * Qt implementation of OpenWnn library
3  * This file is part of the Qt Virtual Keyboard module.
4  * Contact: http://www.qt.io/licensing/
5  *
6  * Copyright (C) 2015  The Qt Company
7  * Copyright (C) 2008-2012  OMRON SOFTWARE Co., Ltd.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef OPENWNNDICTIONARY_H
23 #define OPENWNNDICTIONARY_H
24 
25 #include <QObject>
26 #include <QBitArray>
27 #include "wnnword.h"
28 
29 class OpenWnnDictionaryPrivate;
30 
31 class OpenWnnDictionary : public QObject
32 {
33     Q_OBJECT
34     Q_DISABLE_COPY(OpenWnnDictionary)
35     Q_DECLARE_PRIVATE(OpenWnnDictionary)
36 public:
37     explicit OpenWnnDictionary(QObject *parent = 0);
38     ~OpenWnnDictionary();
39 
40     enum ApproxPattern {
41         APPROX_PATTERN_EN_TOUPPER,
42         APPROX_PATTERN_EN_TOLOWER,
43         APPROX_PATTERN_EN_QWERTY_NEAR,
44         APPROX_PATTERN_EN_QWERTY_NEAR_UPPER,
45         APPROX_PATTERN_JAJP_12KEY_NORMAL
46     };
47 
48     enum SearchOperation {
49         SEARCH_EXACT,
50         SEARCH_PREFIX,
51         SEARCH_LINK
52     };
53 
54     enum SearchOrder {
55         ORDER_BY_FREQUENCY,
56         ORDER_BY_KEY
57     };
58 
59     enum PartOfSpeechType {
60         POS_TYPE_V1,
61         POS_TYPE_V2,
62         POS_TYPE_V3,
63         POS_TYPE_BUNTOU,
64         POS_TYPE_TANKANJI,
65         POS_TYPE_SUUJI,
66         POS_TYPE_MEISI,
67         POS_TYPE_JINMEI,
68         POS_TYPE_CHIMEI,
69         POS_TYPE_KIGOU
70     };
71 
72     enum {
73         INDEX_USER_DICTIONARY = -1,
74         INDEX_LEARN_DICTIONARY = -2,
75     };
76 
77     void setInUseState(bool flag);
78 
79     void clearDictionary();
80     int setDictionary(int index, int base, int high);
81 
82     void clearApproxPattern();
83     int setApproxPattern(const QString &src, const QString &dst);
84     int setApproxPattern(ApproxPattern approxPattern);
85 
86     int searchWord(SearchOperation operation, SearchOrder order, const QString &keyString);
87     int searchWord(SearchOperation operation, SearchOrder order, const QString &keyString, const WnnWord &wnnWord);
88     QSharedPointer<WnnWord> getNextWord(int length = 0);
89 
90     QList<QBitArray> getConnectMatrix();
91     WnnPOS getPOS(PartOfSpeechType type);
92 
93     int learnWord(const WnnWord &word, const WnnWord *previousWord = 0);
94 };
95 
96 #endif // OPENWNNDICTIONARY_H
97