Commit d4661ecc authored by Florent Jacquemard's avatar Florent Jacquemard
Browse files

target equiv2 : option -o : write [trees] to file

parent 61f5e3cb
...@@ -713,17 +713,24 @@ int main(int argc, char** argv) ...@@ -713,17 +713,24 @@ int main(int argc, char** argv)
tab->best(k0, k); // fill table up to k-best tab->best(k0, k); // fill table up to k-best
INFO("time to parse : {}ms", util::duration(time_start)); INFO("time to parse : {}ms", util::duration(time_start));
LabeledRhythmTree* t = LRTFactory<Parsing::KeyQ>::best(tab, k0);
assert(t);
INFO("Ouput tree : {}", *t);
if (f_output && (_output_file.size() == 0)) if (f_output && (_output_file.size() == 0))
{ {
ERROR("empty output file name"); ERROR("empty output file name");
return(1); return(1);
} }
LabeledRhythmTree* t = LRTFactory<Parsing::KeyQ>::best(tab, k0); if (f_output)
assert(t); {
INFO("Ouput tree : {}", *t);
INFO("export trees to file {}", _output_file);
t->write(std::cout); size_t err = t->write(_output_file);
if (err > 0)
ERROR("export failed");
}
return 0; return 0;
} }
...@@ -149,12 +149,12 @@ public: ...@@ -149,12 +149,12 @@ public:
/// pretty-print this tree in the given output stream /// pretty-print this tree in the given output stream
virtual void print(std::ostream& o) const; virtual void print(std::ostream& o) const;
virtual std::string to_string() const; virtual std::string to_string() const;
/// write a raw serial representation of this tree in the given file
size_t save(const std::string filename) const;
/// raw print this tree in the given output stream, 1 line per bar. /// raw print this tree in the given output stream, 1 line per bar.
virtual void write(std::ostream& o) const; virtual void write(std::ostream& o) const;
/// write a raw serial representation of this tree in the given file
size_t write(const std::string filename) const;
friend std::ostream& operator<<(std::ostream&, const LabeledRhythmTree&); friend std::ostream& operator<<(std::ostream&, const LabeledRhythmTree&);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "LRT.hpp" #include "LRT.hpp"
size_t LabeledRhythmTree::save(const std::string filename) const size_t LabeledRhythmTree::write(const std::string filename) const
{ {
std::ofstream file; std::ofstream file;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment