All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Go to the documentation of this file.
1 #ifndef MODEL_H_
2 #define MODEL_H_
11 #include <iostream>
12 #include <vector>
14 #include "spear/RCIPtr.h"
15 #include "spear/BankEdge.h"
16 #include "spear/StringMap.h"
17 #include "spear/Lexicon.h"
18 #include "spear/Wide.h"
20 namespace spear {
22  class Model : public RCObject
23  {
24  public:
26  Model(size_t lf_thresh = 6)
27  : sentences_seen_(0),
28  nts_seen_(0),
29  lf_thresh_(lf_thresh)
30  {}
32  virtual void preprocessEdge(
33  spear::BankEdgePtr& edge,
34  std::vector<spear::BankEdgePtr>& sentence);
36  virtual void extractTerminals(
37  spear::BankEdgePtr& edge,
38  std::vector<spear::BankEdgePtr>& sentence);
40  virtual void generate_events(
41  OStream& os,
42  spear::BankEdgePtr& edge,
43  std::vector<spear::BankEdgePtr>& sentence);
45  virtual void storeGrammar(
46  OStream& rulesStream,
47  OStream& labelsStream,
48  OStream& lexiconStream);
50  virtual bool isEmptyNode(const spear::BankEdgePtr& edge) const;
52  protected:
54  virtual void pruneUnnecessaryNodes(spear::BankEdgePtr& edge);
55  virtual bool isUnnecessaryNode(const spear::BankEdgePtr& edge) const;
56  virtual void stripLabelAugmentation(spear::BankEdgePtr& edge) const;
57  virtual void removeEmptyNodes(spear::BankEdgePtr& edge) const;
58  virtual void addBaseNounPhrases(const spear::BankEdgePtr& edge) const;
59  virtual bool isBaseNounPhrase(const spear::BankEdgePtr& edge) const;
60  virtual void addBaseNounPhraseParents(
61  const spear::BankEdgePtr& edge) const;
62  virtual bool isCoordinatedNounPhrase(
63  const spear::BankEdgePtr& edge) const;
64  virtual void repairBaseNounPhrases(
65  const spear::BankEdgePtr& edge) const;
66  virtual void labelSubjectlessSentencess(
67  const spear::BankEdgePtr& edge) const;
68  virtual bool isSentenceWithNilSubject(
69  const spear::BankEdgePtr& edge) const;
70  virtual void raisePunctuation(
71  const spear::BankEdgePtr& edge,
72  std::list<spear::BankEdgePtr>& parentChildren,
73  std::list<spear::BankEdgePtr>::iterator begin,
74  std::list<spear::BankEdgePtr>::iterator end) const;
75  virtual bool isPunctuation(const spear::BankEdgePtr & edge) const;
76  virtual void identifyArguments(const spear::BankEdgePtr & edge) const;
77  virtual void repairSubjectlessSentences(
78  const spear::BankEdgePtr & edge) const;
79  virtual void generateSentence(
80  const spear::BankEdgePtr& edge,
81  std::vector<spear::BankEdgePtr>& sentence,
82  bool setIndex
83  ) const;
84  virtual void generateDependencyEvents(
85  OStream& os,
86  const spear::BankEdgePtr& edge,
87  const spear::BankEdgePtr& parent,
88  int parent_num);
89  virtual bool isCoordination(
90  std::list<spear::BankEdgePtr>::const_iterator begin,
91  std::list<spear::BankEdgePtr>::const_iterator end,
92  const BankEdge* previous,
93  const BankEdge* parent
94  ) const;
95  virtual bool isCoordination(
96  std::list<spear::BankEdgePtr>::reverse_iterator begin,
97  std::list<spear::BankEdgePtr>::reverse_iterator eoi,
98  const BankEdge* previous,
99  const BankEdge* parent
100  ) const;
101  virtual bool containsVerb(const spear::BankEdgePtr & e) const;
102  virtual bool splitLabel(
103  const String& label,
104  String& coreLabel,
105  String& labelAugment
106  ) const;
107  virtual void learnLexicon(const spear::BankEdgePtr & e);
108  virtual void markUnary(const spear::BankEdgePtr & edge, int) const;
109  virtual void normalizeNumbers(const spear::BankEdgePtr & edge) const;
110  virtual void annotateTags(
111  const spear::BankEdgePtr& edge,
112  const String& parent
113  ) const;
114  virtual void addHorizontalHistory(BankEdgePtr & edge);
115  virtual std::list<spear::BankEdgePtr>::iterator
116  findNext(
117  spear::BankEdgePtr& edge,
118  std::list<spear::BankEdgePtr>::iterator it
119  );
120  virtual std::list<spear::BankEdgePtr>::reverse_iterator
121  findNext(
122  spear::BankEdgePtr& edge,
123  std::list<spear::BankEdgePtr>::reverse_iterator it
124  );
125  int sentences_seen() const { return sentences_seen_;}
126  int nts_seen() const { return nts_seen_;}
127  protected:
132  size_t lf_thresh_;
133  };
137 } // end namespace spear
139 #endif /* MODEL_H */
size_t lf_thresh_
Definition: Model.h:132
Definition: Model.h:22
virtual void labelSubjectlessSentencess(const spear::BankEdgePtr &edge) const
Definition: Model.cc:561
Reference counting pointer class This file contains the code for the classes and class templates maki...
virtual void raisePunctuation(const spear::BankEdgePtr &edge, std::list< spear::BankEdgePtr > &parentChildren, std::list< spear::BankEdgePtr >::iterator begin, std::list< spear::BankEdgePtr >::iterator end) const
Definition: Model.cc:577
spear::Lexicon lexicon_
Definition: Model.h:129
spear::StringMap< int > modifiers_
Definition: Model.h:128
virtual bool isSentenceWithNilSubject(const spear::BankEdgePtr &edge) const
Definition: Model.cc:528
virtual void addHorizontalHistory(BankEdgePtr &edge)
Definition: Model.cc:42
int nts_seen_
Definition: Model.h:131
#define OStream
Definition: Wide.h:38
virtual void stripLabelAugmentation(spear::BankEdgePtr &edge) const
Definition: Model.cc:203
Definition: RCIPtr.h:67
virtual void markUnary(const spear::BankEdgePtr &edge, int) const
Definition: Model.cc:1344
virtual void normalizeNumbers(const spear::BankEdgePtr &edge) const
Definition: Model.cc:1372
int sentences_seen_
Definition: Model.h:130
int nts_seen() const
Definition: Model.h:126
virtual bool splitLabel(const String &label, String &coreLabel, String &labelAugment) const
Definition: Model.cc:178
Definition: BankEdge.h:21
virtual bool isUnnecessaryNode(const spear::BankEdgePtr &edge) const
Definition: Model.cc:163
virtual void generateDependencyEvents(OStream &os, const spear::BankEdgePtr &edge, const spear::BankEdgePtr &parent, int parent_num)
Definition: Model.cc:824
Definition: Lexicon.h:62
virtual void generateSentence(const spear::BankEdgePtr &edge, std::vector< spear::BankEdgePtr > &sentence, bool setIndex) const
Definition: Model.cc:648
virtual void annotateTags(const spear::BankEdgePtr &edge, const String &parent) const
Definition: Model.cc:1387
virtual bool isCoordinatedNounPhrase(const spear::BankEdgePtr &edge) const
Definition: Model.cc:431
virtual void extractTerminals(spear::BankEdgePtr &edge, std::vector< spear::BankEdgePtr > &sentence)
Definition: Model.cc:155
virtual bool containsVerb(const spear::BankEdgePtr &e) const
Definition: Model.cc:812
virtual std::list< spear::BankEdgePtr >::iterator findNext(spear::BankEdgePtr &edge, std::list< spear::BankEdgePtr >::iterator it)
virtual void preprocessEdge(spear::BankEdgePtr &edge, std::vector< spear::BankEdgePtr > &sentence)
Definition: Model.cc:91
#define String
Definition: Wide.h:36
virtual void removeEmptyNodes(spear::BankEdgePtr &edge) const
Definition: Model.cc:265
virtual bool isEmptyNode(const spear::BankEdgePtr &edge) const
Definition: Model.cc:245
virtual void generate_events(OStream &os, spear::BankEdgePtr &edge, std::vector< spear::BankEdgePtr > &sentence)
Definition: Model.cc:677
virtual void repairSubjectlessSentences(const spear::BankEdgePtr &edge) const
Definition: Model.cc:644
virtual bool isPunctuation(const spear::BankEdgePtr &edge) const
Definition: Model.cc:286
virtual void identifyArguments(const spear::BankEdgePtr &edge) const
Definition: Model.cc:640
virtual void storeGrammar(OStream &rulesStream, OStream &labelsStream, OStream &lexiconStream)
Definition: Model.cc:1301
virtual void repairBaseNounPhrases(const spear::BankEdgePtr &edge) const
Definition: Model.cc:499
virtual void addBaseNounPhrases(const spear::BankEdgePtr &edge) const
Definition: Model.cc:415
Definition: RCIPtr.h:24
virtual void learnLexicon(const spear::BankEdgePtr &e)
Definition: Model.cc:1280
virtual bool isBaseNounPhrase(const spear::BankEdgePtr &edge) const
Definition: Model.cc:390
RCIPtr< Model > ModelPtr
Definition: Model.h:135
Model(size_t lf_thresh=6)
Definition: Model.h:26
virtual void pruneUnnecessaryNodes(spear::BankEdgePtr &edge)
Definition: Model.cc:218
int sentences_seen() const
Definition: Model.h:125
virtual bool isCoordination(std::list< spear::BankEdgePtr >::const_iterator begin, std::list< spear::BankEdgePtr >::const_iterator end, const BankEdge *previous, const BankEdge *parent) const
Definition: Model.cc:340
virtual void addBaseNounPhraseParents(const spear::BankEdgePtr &edge) const
Definition: Model.cc:456