KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Lexicon.h
Go to the documentation of this file.
1 #ifndef LEXICON_H_
2 #define LEXICON_H_
3 
13 #include <list>
14 #include <vector>
15 #include <string>
16 
17 #include "spear/RCIPtr.h"
18 #include "spear/HashMap.h"
21 #include "spear/Pair.h"
22 #include "spear/StringMap.h"
23 #include "spear/Wide.h"
24 
25 
26 namespace spear {
27 
28  extern size_t LF_WORD_THRESHOLD;
29 
30 class Lexem : public RCObject
31 {
32  public:
33 
34  Lexem() : _count(0) {};
35 
36  Lexem(const String & w) : _word(w), _count(0) {};
37 
38  void add(int tag);
39 
40  const String & getWord() const { return _word; };
41 
42  const std::list< spear::Pair<int, int> > & getLabels() const { return _labels; };
43 
44  int getCount() const { return _count; };
45 
46  private:
48  String _word;
49 
51  int _count;
52 
57  std::list< spear::Pair<int, int> > _labels;
58 };
59 
61 
62 class Lexicon : public RCObject
63 {
64  public:
65  Lexicon();
66 
67  void addLexem(
68  const String & word,
69  const String & tag);
70 
71  int addLabel(const String & label);
72 
73  void sortLexems(std::vector<String> & sortedLex, size_t lf_thresh) const;
74  void sortLabels(std::vector<String> & sortedLabels) const;
75 
76 private:
77 
78  LexemPtr getLexem(const Char * word);
79 
81  std::vector<LexemPtr> _lexems;
82 
84  StringMap<int> _lexemIndeces;
85 
87  std::vector<String> _labels;
88 
90  StringMap<int> _labelIndeces;
91 };
92 
94 
95 } // end namespace spear
96 
97 #endif
int addLabel(const String &label)
Definition: Lexicon.cc:68
Reference counting pointer class This file contains the code for the classes and class templates maki...
void add(int tag)
Definition: Lexicon.cc:82
RCIPtr< spear::Lexem > LexemPtr
Definition: Lexicon.h:60
const std::list< spear::Pair< int, int > > & getLabels() const
Definition: Lexicon.h:42
Definition: RCIPtr.h:67
void addLexem(const String &word, const String &tag)
Definition: Lexicon.cc:101
void sortLabels(std::vector< String > &sortedLabels) const
Definition: Lexicon.cc:49
char Char
Definition: Wide.h:34
Lexem(const String &w)
Definition: Lexicon.h:36
Definition: Lexicon.h:62
size_t LF_WORD_THRESHOLD
Definition: Semspear_tree.cpp:32
RCIPtr< spear::Lexicon > LexiconPtr
Definition: Lexicon.h:93
#define String
Definition: Wide.h:36
int getCount() const
Definition: Lexicon.h:44
Definition: Lexicon.h:30
Lexicon()
Definition: Lexicon.cc:19
void sortLexems(std::vector< String > &sortedLex, size_t lf_thresh) const
Definition: Lexicon.cc:23
Definition: RCIPtr.h:24
const String & getWord() const
Definition: Lexicon.h:40
Lexem()
Definition: Lexicon.h:34