Updated source code from upstream SVN
[svmtool++.git] / include / dict.h
blob21ae1e171c19eb6f15972a7460d2af01babc7dfd
1 /*
2 * Copyright (C) 2004 Jesus Gimenez, Lluis Marquez and Senen Moya
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef DICT_H
21 #include "list.h"
22 #include "hash.h"
23 #include <set>
24 #include <string>
26 #define TAMTXT 100
28 struct infoDict
30 std::string pos;
31 int num;
34 struct dataDict
36 std::string wrd;
37 int numWrd;
38 int numMaybe;
39 simpleList<infoDict*> maybe;
42 class dictionary
44 public:
45 dictionary(const std::string& name, const std::string& backup);
46 dictionary(const std::string& name);
47 dictionary(const std::string& name,int limInf, int limSup);
48 ~dictionary();
50 void dictAddBackup(const std::string& name);
51 void addBackupEntry(const std::string& token, const std::set<std::string>& tags);
53 dataDict* getElement(const std::string& key);
54 std::string& getElementWord(dataDict* ptr);
55 int getElementNumWord(dataDict* ptr);
56 int getElementNumMaybe(dataDict* ptr);
57 simpleList<infoDict*>& getElementMaybe(dataDict* ptr);
58 infoDict* getMFT(dataDict* w);
59 std::string getAmbiguityClass(dataDict* w);
61 hash_t<infoDict*>* dictFindAmbP(int *numPOS);
62 hash_t<infoDict*>* dictFindUnkP(int *numPOS);
63 void dictRepairFromFile(const std::string& fileName);
64 void dictRepairHeuristic(float dratio);
66 void dictCleanListInfoDict(simpleList< infoDict* >* l, int num);
68 void dictWrite(const std::string& outName);
70 private:
71 void dictLoad(FILE *in);
72 void dictCreate(FILE *f,int offset, int limit);
73 void dictIncInfo(dataDict *elem, const std::string& pos);
75 int readInt(FILE *in);
76 infoDict *readData(FILE *in);
78 hash_t<dataDict*> d;
81 #define DICT_H
82 #endif