forked from aymara/lima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckDictionary.cpp
134 lines (109 loc) · 3.54 KB
/
checkDictionary.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
Copyright 2002-2013 CEA LIST
This file is part of LIMA.
LIMA is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LIMA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with LIMA. If not, see <http://www.gnu.org/licenses/>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <fstream>
#include <iterator>
#include <vector>
#include <iostream>
#include <cstdlib>
#include "common/LimaCommon.h"
#include "common/Data/strwstrtools.h"
#include "linguisticProcessing/core/LinguisticResources/LinguisticResources.h"
#include "linguisticProcessing/core/AnalysisDict/EnhancedAnalysisDictionary.h"
#include "BasicHandler.h"
#include <QtCore/QCoreApplication>
using namespace std;
using namespace Lima;
using namespace Lima::LinguisticProcessing;
using namespace Lima::LinguisticProcessing::AnalysisDict;
// options
typedef struct ParamStruct
{
std::string dataFileName;
int entryId;
}
Param;
void displayEntry(EnhancedAnalysisDictionary& data,StringsPoolIndex index);
#include "common/tools/LimaMainTaskRunner.h"
#include "common/AbstractFactoryPattern/AmosePluginsManager.h"
#include <QtCore/QTimer>
int run(int aargc,char** aargv);
int main(int argc, char **argv)
{
QCoreApplication a(argc, argv);
// Task parented to the application so that it
// will be deleted by the application.
LimaMainTaskRunner* task = new LimaMainTaskRunner(argc, argv, run, &a);
// This will cause the application to exit when
// the task signals finished.
QObject::connect(task, SIGNAL(finished(int)), &a, SLOT(quit()));
// This will run the task from the application event loop.
QTimer::singleShot(0, task, SLOT(run()));
return a.exec();
}
int run(int argc,char** argv)
{
QsLogging::initQsLog();
// Necessary to initialize factories
Lima::AmosePluginsManager::single();
for (int i = 1 ; i < argc; i++)
{
std::string arg(argv[i]);
if (arg == "--help")
{
std::cerr << "USAGE : " << argv[0] << " <dataFile> [entryId]" << std::endl;
return 0;
}
}
EnhancedAnalysisDictionary dico(QString::fromUtf8(argv[1]));
cout << dico.getSize() << " entries in data" << endl;
if (argc == 2) {
for (uint64_t i=0;i<dico.getSize();i++)
{
displayEntry(dico,StringsPoolIndex(i));
}
} else {
displayEntry(dico,StringsPoolIndex(atoi(argv[2])));
}
return 0;
}
void displayEntry(EnhancedAnalysisDictionary& dico,StringsPoolIndex index)
{
cout << "display entry " << index << " : " << endl;
DictionaryEntry entry(dico.getEntry(index));
if (entry.isFinal()) {
cout << " ** final entry ** " << endl;
}
if (entry.isEmpty()) {
cout << "empty entry ! " << endl;
} else {
cout << "entry is not empty : " << endl;
BasicHandler handler(&cout);
if (entry.hasLingInfos()) {
cout << "has ling infos :" << endl;
entry.parseLingInfos(&handler);
}
if (entry.hasAccentedForms()) {
cout << "has accented forms : " << endl;
entry.parseAccentedForms(&handler);
}
if (entry.hasConcatenated()) {
cout << "has concatenated forms : " << endl;
entry.parseConcatenated(&handler);
}
}
}