blob: aa1df3db5df7849b6cf9996691137c35ca652d2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include "lattice.h"
#include "tdict.h"
#include "hg_io.h"
using namespace std;
bool LatticeTools::LooksLikePLF(const string &line) {
return (line.size() > 5) && (line.substr(0,4) == "((('");
}
void LatticeTools::ConvertTextToLattice(const string& text, Lattice* pl) {
Lattice& l = *pl;
vector<WordID> ids;
TD::ConvertSentence(text, &ids);
l.resize(ids.size());
for (int i = 0; i < l.size(); ++i)
l[i].push_back(LatticeArc(ids[i], 0.0, 1));
}
void LatticeTools::ConvertTextOrPLF(const string& text_or_plf, Lattice* pl) {
if (LooksLikePLF(text_or_plf))
HypergraphIO::PLFtoLattice(text_or_plf, pl);
else
ConvertTextToLattice(text_or_plf, pl);
}
|