~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to converter/nbest_generator.cc

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <string>
33
33
#include "base/base.h"
34
34
#include "converter/candidate_filter.h"
35
 
#include "converter/connector.h"
36
 
#include "converter/converter_data.h"
37
 
#include "converter/pos.h"
 
35
#include "converter/connector_interface.h"
 
36
#include "converter/lattice.h"
 
37
#include "converter/pos_matcher.h"
38
38
#include "converter/segmenter.h"
39
39
#include "converter/segments.h"
40
40
 
43
43
NBestGenerator::NBestGenerator()
44
44
    : freelist_(128), filter_(NULL),
45
45
      begin_node_(NULL), end_node_(NULL),
46
 
      connector_(NULL), data_(NULL) {}
 
46
      connector_(ConnectorFactory::GetConnector()),
 
47
      lattice_(NULL) {}
47
48
 
48
49
NBestGenerator::~NBestGenerator() {}
49
50
 
50
51
void NBestGenerator::Init(Node *begin_node, Node *end_node,
51
 
                          ConnectorInterface *connector,
52
 
                          ConverterData *data) {
 
52
                          Lattice *lattice) {
53
53
  begin_node_ = begin_node;
54
54
  end_node_ = end_node;
55
 
  connector_ = connector;
56
 
  data_ = data;
 
55
  lattice_ = lattice;
57
56
  Reset();
58
57
}
59
58
 
73
72
bool NBestGenerator::Next(Segment::Candidate *candidate,
74
73
                          const Node **candidate_begin_node,
75
74
                          const Node **candidate_end_node) {
76
 
  if (data_ == NULL || !data_->has_lattice()) {
 
75
  if (lattice_ == NULL || !lattice_->has_lattice()) {
77
76
    LOG(ERROR) << "Must create lattice in advance";
78
77
    return false;
79
78
  }
80
79
 
81
 
  Node **end_nodes_list = data_->end_nodes_list();
82
80
  const int KMaxTrial = 500;
83
81
  int num_trials = 0;
84
82
  string key;
125
123
          has_constrained_node = true;
126
124
        }
127
125
 
128
 
        if (!is_functional && !POS::IsFunctional(node->lid)) {
 
126
        if (!is_functional && !POSMatcher::IsFunctional(node->lid)) {
129
127
          candidate->content_value += node->value;
130
128
          candidate->content_key += node->key;
131
129
        } else {
177
175
          // do nothing
178
176
      }
179
177
    } else {
180
 
      for (Node *lnode = end_nodes_list[rnode->begin_pos];
 
178
      for (Node *lnode = lattice_->end_nodes(rnode->begin_pos);
181
179
           lnode != NULL; lnode = lnode->enext) {
182
180
        // is_edge is true if current lnode/rnode has same boundary as
183
181
        // begin/end node regardless of its value.