summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--src/hypergraph.cc11
-rw-r--r--src/hypergraph.hh6
-rw-r--r--src/odenwald.cc3
4 files changed, 11 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index f59d18e..8d5147b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
COMPILER=clang
CFLAGS=-std=c++11 -O3 -Wall
-TCMALLOC=external/gperftools/lib/libtcmalloc_minimal.a -pthread
MSGPACK_C_INCLUDE=-I external/msgpack-c/include
MSGPACK_C=external/msgpack-c/lib/libmsgpack.a $(MSGPACK_C_INCLUDE)
JSON_CPP_INCLUDE=-I external/json-cpp/include
@@ -14,7 +13,7 @@ PRINT_END = @echo -e "\e[1;32mfinished building $@\e[0m"
###############################################################################
# all
#
-all: $(BIN)/ow util test
+all: $(BIN)/ow test
###############################################################################
# ow
@@ -26,7 +25,6 @@ $(BIN)/ow: $(BIN) $(SRC)/hypergraph.o $(SRC)/odenwald.cc
-lstdc++ \
-lm \
$(MSGPACK_C) \
- $(TCMALLOC) \
$(SRC)/hypergraph.o \
$(SRC)/odenwald.cc \
-o $(BIN)/ow
@@ -84,7 +82,6 @@ $(BIN)/test_grammar: $(BIN) $(SRC)/test_grammar.cc $(SRC)/grammar.hh
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
- $(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/test_grammar.cc \
-o $(BIN)/test_grammar
@@ -95,7 +92,6 @@ $(BIN)/test_hypergraph: $(BIN) $(SRC)/test_hypergraph.cc $(SRC)/hypergraph.o $(S
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
- $(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/hypergraph.o \
$(SRC)/test_hypergraph.cc \
@@ -108,7 +104,6 @@ $(BIN)/test_parse: $(BIN) $(SRC)/test_parse.cc $(SRC)/parse.hh \
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
- $(TCMALLOC) \
$(MSGPACK_C) \
$(SRC)/test_parse.cc \
-o $(BIN)/test_parse
@@ -119,7 +114,6 @@ $(BIN)/test_sparse_vector: $(BIN) $(SRC)/test_sparse_vector.cc $(SRC)/sparse_vec
$(COMPILER) $(CFLAGS) \
-lstdc++ \
-lm \
- $(TCMALLOC) \
$(SRC)/test_sparse_vector.cc \
-o $(BIN)/test_sparse_vector
$(PRINT_END)
diff --git a/src/hypergraph.cc b/src/hypergraph.cc
index 6ec8441..0c36abe 100644
--- a/src/hypergraph.cc
+++ b/src/hypergraph.cc
@@ -73,13 +73,13 @@ viterbi_path(Hypergraph& hg, Path& p)
[](Node* n) { return n->incoming.size() == 0; });
//list<Node*>::iterator root = hg.nodes.begin();
+ Hg::reset(hg.nodes, hg.edges);
Hg::topological_sort(hg.nodes, root);
- // ^^^ FIXME do I need to do this when reading from file?
Semiring::Viterbi<score_t> semiring;
Hg::init(hg.nodes, root, semiring);
for (auto n: hg.nodes) {
- Edge* best_edge;
+ Edge* best_edge = nullptr;
bool best = false;
for (auto e: n->incoming) {
score_t s = semiring.one;
@@ -135,10 +135,10 @@ derive(const Path& p, const Node* cur, vector<string>& carry)
}
} // FIXME this is probably not so good
- unsigned j = 0;
+ unsigned j = 1;
for (auto it: next->rule->target) {
if (it->type() == G::NON_TERMINAL) {
- derive(p, next->tails[next->rule->order[j]], carry);
+ derive(p, next->tails[next->rule->order[j]-1], carry);
j++;
} else {
carry.push_back(it->symbol());
@@ -156,7 +156,8 @@ read(Hypergraph& hg, vector<G::Rule*>& rules, G::Vocabulary& vocab, const string
msgpack::unpacker pac;
while(true) {
pac.reserve_buffer(32*1024);
- size_t bytes = ifs.readsome(pac.buffer(), pac.buffer_capacity());
+ ifs.read(pac.buffer(), pac.buffer_capacity());
+ size_t bytes = ifs.gcount();
pac.buffer_consumed(bytes);
msgpack::unpacked result;
while(pac.next(&result)) {
diff --git a/src/hypergraph.hh b/src/hypergraph.hh
index 7a268c3..d782c9e 100644
--- a/src/hypergraph.hh
+++ b/src/hypergraph.hh
@@ -48,10 +48,10 @@ struct Node {
string symbol;
short left;
short right;
- score_t score;
+ score_t score = 0.0;
vector<Edge*> incoming;
vector<Edge*> outgoing;
- unsigned int mark;
+ unsigned int mark = 0;
inline bool is_marked() { return mark >= incoming.size(); };
friend ostream& operator<<(ostream& os, const Node& n);
@@ -98,7 +98,7 @@ void
write(Hypergraph& hg, vector<G::Rule*>& rules, const string& fn); // FIXME
void
-manual(Hypergraph& hg, vector<G::Rule*>& rules);
+manual(Hypergraph& hg, vector<G::Rule*>& rules, G::Vocabulary& vocab);
} // namespace
diff --git a/src/odenwald.cc b/src/odenwald.cc
index a520d0b..bdf21f8 100644
--- a/src/odenwald.cc
+++ b/src/odenwald.cc
@@ -20,8 +20,7 @@ main(int argc, char** argv)
// viterbi
clock_t begin_viterbi = clock();
Hg::Path p;
- Hg::sv_path(hg, p);
- exit(1);
+ Hg::viterbi_path(hg, p);
vector<string> s;
Hg::derive(p, p.back()->head, s);
for (auto it: s)