Files
clients/MorphereAnalyzer/nbest_generator.h
admin 2e7d343f4a MorphereAnalyzer
git-svn-id: svn://192.168.0.12/source@76 8346c931-da38-4b9b-9d4c-e48b93cbd075
2015-04-17 02:44:11 +00:00

44 lines
1008 B
C++

// MeCab -- Yet Another Part-of-Speech and Morphological Analyzer
//
//
// Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
// Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
#ifndef MECAB_NBEST_GENERATOR_H_
#define MECAB_NBEST_GENERATOR_H_
#include <queue>
#include "mecab.h"
#include "freelist.h"
namespace MeCab {
class NBestGenerator {
private:
struct QueueElement {
Node *node;
QueueElement *next;
long fx; // f(x) = h(x) + g(x): cost function for A* search
long gx; // g(x)
};
class QueueElementComp {
public:
const bool operator()(QueueElement *q1, QueueElement *q2) {
return (q1->fx > q2->fx);
}
};
std::priority_queue<QueueElement *, std::vector<QueueElement *>,
QueueElementComp> agenda_;
FreeList <QueueElement> freelist_;
public:
explicit NBestGenerator() : freelist_(512) {}
virtual ~NBestGenerator() {}
bool set(Lattice *lattice);
bool next();
};
}
#endif // MECAB_NBEST_GENERATOR_H_