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

rename namespace Parsing to parsing

debug KeySI & KeySIP : computation of runs
parent 5a1dbb82
......@@ -36,15 +36,15 @@ int read_config(const std::string filename)
if (reader.ParseError() < 0)
return -1;
Parsing::OPT_RUN_DUR = reader.GetBoolean("options", "run_dur", true);
Parsing::OPT_RUN_UNIT = reader.GetBoolean("options", "run_unit", true);
Parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "run_strict", false);
if (Parsing::OPT_RUN_DUR == false)
parsing::OPT_RUN_DUR = reader.GetBoolean("options", "run_dur", true);
parsing::OPT_RUN_UNIT = reader.GetBoolean("options", "run_unit", true);
parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "run_strict", false);
if (parsing::OPT_RUN_DUR == false)
{
Parsing::OPT_RUN_UNIT = false;
Parsing::OPT_RUN_STRICT = false;
parsing::OPT_RUN_UNIT = false;
parsing::OPT_RUN_STRICT = false;
}
Parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "norest", false);
parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "norest", false);
// CST_ALPHA = reader.GetReal("params", "alpha", 0.5);
Weight::CST_ALPHA = reader.GetReal("params", "alpha", 1.0);
......
......@@ -192,9 +192,9 @@ bool Krecord<P>::bestFilter(const Run<P>* r)
assert(r->inner() || r->terminal());
// filter acc. to optimization flags
if (Parsing::OPT_RUN_UNIT)
if (parsing::OPT_RUN_UNIT)
{
//assert (Parsing::OPT_RUN_DUR);
//assert (parsing::OPT_RUN_DUR);
if (r->duration.unit() && r->inner())
return false;
}
......
......@@ -368,9 +368,9 @@ bool Run<P>::filter()
// filter acc. to optimization flags
// we do not filter out meta runs
if (! this->meta() && Parsing::OPT_RUN_UNIT)
if (! this->meta() && parsing::OPT_RUN_UNIT)
{
//assert(Parsing::OPT_RUN_DUR);
//assert(parsing::OPT_RUN_DUR);
if (this->duration.unit() && this->inner())
return false;
}
......@@ -447,14 +447,14 @@ void Run<P>::update(const Weight& w, const DurationList& dl) // arg duration
weight *= w;
// (flag) concatenation dur
if (Parsing::OPT_RUN_DUR) // dl may be empty in case of manual update
if (parsing::OPT_RUN_DUR) // dl may be empty in case of manual update
{
duration += dl;
}
_first_partialortoupdate++;
// update is terminated
if (this->complete() && Parsing::OPT_RUN_DUR && (! dl.empty()))
if (this->complete() && parsing::OPT_RUN_DUR && (! dl.empty()))
{
assert (duration.summed() == this->arity());
duration.normalize(); // .mult(Rational(1, arity));
......@@ -466,7 +466,7 @@ template<class P>
void Run<P>::_init_duration_list(label_t label)
{
// update duration list
if (Parsing::OPT_RUN_DUR)
if (parsing::OPT_RUN_DUR)
{
if (Label::continuation(label))
{
......
......@@ -9,7 +9,7 @@
#include "Ranked.hpp"
namespace Parsing{
namespace parsing{
Ranked::Ranked(size_t k):
......@@ -37,4 +37,4 @@ bool Ranked::operator==(const Ranked& p) const
return (p._rank == _rank);
}
} // end namespace Parsing
} // end namespace parsing
......@@ -1109,7 +1109,7 @@ int main(int argc, char** argv)
INFO("compute best tree sequence for {} and input in {}",
_schema_file, _input_file);
typedef LRTFactory<Parsing::KeySIP> TreeFactory;
typedef LRTFactory<parsing::KeySIP> TreeFactory;
// check options
if (!(f_barsec || f_bars))
......@@ -1130,35 +1130,35 @@ int main(int argc, char** argv)
assert(_schema);
assert(_iseg);
Parsing::ParsingEnv env = Parsing::ParsingEnv(_schema, _iseg);
parsing::ParsingEnv env = parsing::ParsingEnv(_schema, _iseg);
assert(env.segment);
// flag f_max: ordering for enumeration (user option)
Parsing::RunCompare<Parsing::KeySIP> comp =
(f_max)?Parsing::weightMax<Parsing::KeySIP>:Parsing::weightMin<Parsing::KeySIP>;
Parsing::TableA<Parsing::KeySIP>* tab; // empty table
parsing::RunCompare<parsing::KeySIP> comp =
(f_max)?parsing::weightMax<parsing::KeySIP>:parsing::weightMin<parsing::KeySIP>;
parsing::TableA<parsing::KeySIP>* tab; // empty table
if (_k == 1) // 1-best
{
INFO("1-best computation");
tab = new Parsing::TableParse<Parsing::KeySIP,
Parsing::RecordOne<Parsing::KeySIP>,
Parsing::KeySIPHasher>(&env, comp);
tab = new parsing::TableParse<parsing::KeySIP,
parsing::RecordOne<parsing::KeySIP>,
parsing::KeySIPHasher>(&env, comp);
}
else // k-best
{
INFO("{}-best computation", _k);
assert(_k > 1); // cannot be 0
tab = new Parsing::TableParse<Parsing::KeySIP,
Parsing::RecordQueue<Parsing::KeySIP>,
Parsing::KeySIPHasher>(&env, comp);
tab = new parsing::TableParse<parsing::KeySIP,
parsing::RecordQueue<parsing::KeySIP>,
parsing::KeySIPHasher>(&env, comp);
}
// state_t init = _schema->initial();
// initial augmented state
// pre = 0
// post = 0 (complete key)
const Parsing::KeySIP k0 = Parsing::KeySIP(_barsec, env, true, 0, 0);
const parsing::KeySIP k0 = parsing::KeySIP(_barsec, env, true, 0, 0);
// pre = 0
// post = Unknown (partial key)
//const KeySIP k0 = KeySIP(_barsec, env, true, 0);
......@@ -1238,7 +1238,7 @@ int main(int argc, char** argv)
//parser->demo(_schema_file, _input_file);
for (size_t i = 1; i <= _k; i++)
{
const Parsing::Run<Parsing::KeySIP>* best_run = tab->best(k0, i);
const parsing::Run<parsing::KeySIP>* best_run = tab->best(k0, i);
if (best_run == NULL)
{
......@@ -1255,8 +1255,8 @@ int main(int argc, char** argv)
}
else
{
const Parsing::RunRanked<Parsing::KeySIP>* best_runr =
dynamic_cast<const Parsing::RunRanked<Parsing::KeySIP>*>(best_run);
const parsing::RunRanked<parsing::KeySIP>* best_runr =
dynamic_cast<const parsing::RunRanked<parsing::KeySIP>*>(best_run);
assert(best_runr);
//LabeledRhythmTree* best_tree = tab->bestTree(best_runr);
LabeledRhythmTree* best_tree = TreeFactory::projection(tab, best_runr);
......@@ -1278,7 +1278,7 @@ int main(int argc, char** argv)
INFO("compute best tree sequence for {} and input in {}",
_schema_file, _input_file);
typedef LRTFactory<Parsing::KeySIR> TreeFactory;
typedef LRTFactory<parsing::KeySIR> TreeFactory;
// check options
if (!(f_barsec || f_bars))
......@@ -1304,28 +1304,28 @@ int main(int argc, char** argv)
assert(_schema);
assert(_iseg);
Parsing::ParsingEnv* penv = new Parsing::ParsingEnv(_schema, _iseg);
parsing::ParsingEnv* penv = new parsing::ParsingEnv(_schema, _iseg);
assert(penv->segment);
// flag f_max: ordering for enumeration (user option)
Parsing::RunCompare<Parsing::KeySIR> comp =
(f_max)?Parsing::weightMax<Parsing::KeySIR>:Parsing::weightMin<Parsing::KeySIR>;
Parsing::TableA<Parsing::KeySIR>* tab; // empty table
parsing::RunCompare<parsing::KeySIR> comp =
(f_max)?parsing::weightMax<parsing::KeySIR>:parsing::weightMin<parsing::KeySIR>;
parsing::TableA<parsing::KeySIR>* tab; // empty table
if (_k == 1) // 1-best
{
INFO("1-best computation");
tab = new Parsing::TableParse<Parsing::KeySIR,
Parsing::RecordOne<Parsing::KeySIR>,
Parsing::KeySIRHasher>(penv, comp);
tab = new parsing::TableParse<parsing::KeySIR,
parsing::RecordOne<parsing::KeySIR>,
parsing::KeySIRHasher>(penv, comp);
}
else // k-best
{
INFO("{}-best computation", _k);
assert(_k > 1); // cannot be 0
tab = new Parsing::TableParse<Parsing::KeySIR,
Parsing::RecordQueue<Parsing::KeySIR>,
Parsing::KeySIRHasher>(penv, comp);
tab = new parsing::TableParse<parsing::KeySIR,
parsing::RecordQueue<parsing::KeySIR>,
parsing::KeySIRHasher>(penv, comp);
}
// state_t init = _schema->initial();
......@@ -1333,7 +1333,7 @@ int main(int argc, char** argv)
// pre = 0
// post = 0 (complete key)
assert(penv);
const Parsing::KeySIR k0 = Parsing::KeySIR(_barsec, *penv, true);
const parsing::KeySIR k0 = parsing::KeySIR(_barsec, *penv, true);
// pre = 0
// post = Unknown (partial key)
//const KeySIR k0 = KeySIR(_barsec, penv, true, 0);
......@@ -1371,7 +1371,7 @@ int main(int argc, char** argv)
sm::TableMonoImporter importer(std::string("score1"), _ts);
assert(tab);
assert(senv);
importer.readPart<Parsing::KeySIR>(std::string("part1"), *senv, *tab, k0);
importer.readPart<parsing::KeySIR>(std::string("part1"), *senv, *tab, k0);
sm::Score* score = importer.getScore();
assert(score);
......@@ -1462,8 +1462,8 @@ int main(int argc, char** argv)
assert(_iseg);
INFO("quantize segment ({} points) wrt parse tree", _iseg->size()-1);
// quantize wrt the 1-best for k0
//_iseg->quantize<Parsing::KeySIR>(tab, k0, 1);
Parsing::Quantizer<Parsing::KeySIR> quantizer(*tab);
//_iseg->quantize<parsing::KeySIR>(tab, k0, 1);
parsing::Quantizer<parsing::KeySIR> quantizer(*tab);
quantizer.quantize(*_iseg, k0, 1);
INFO("quantized input segment:"); _iseg->print(std::cout);
// qseg->respell(); // not for MIDI out!
......@@ -1480,7 +1480,7 @@ int main(int argc, char** argv)
//parser->demo(_schema_file, _input_file);
for (size_t i = 1; i <= _k; i++)
{
const Parsing::Run<Parsing::KeySIR>* best_run = tab->best(k0, i);
const parsing::Run<parsing::KeySIR>* best_run = tab->best(k0, i);
if (best_run == NULL)
{
......@@ -1498,8 +1498,8 @@ int main(int argc, char** argv)
}
else
{
const Parsing::RunRanked<Parsing::KeySIR>* best_runr =
dynamic_cast<const Parsing::RunRanked<Parsing::KeySIR>*>(best_run);
const parsing::RunRanked<parsing::KeySIR>* best_runr =
dynamic_cast<const parsing::RunRanked<parsing::KeySIR>*>(best_run);
assert(best_runr);
//LabeledRhythmTree* best_tree = tab->bestTree(best_runr);
LabeledRhythmTree* best_tree =
......
......@@ -32,15 +32,15 @@ int read_config(const std::string filename)
if (reader.ParseError() < 0)
return -1;
Parsing::OPT_RUN_DUR = reader.GetBoolean("options", "run_dur", true);
Parsing::OPT_RUN_UNIT = reader.GetBoolean("options", "run_unit", true);
Parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "run_strict", false);
if (Parsing::OPT_RUN_DUR == false)
parsing::OPT_RUN_DUR = reader.GetBoolean("options", "run_dur", true);
parsing::OPT_RUN_UNIT = reader.GetBoolean("options", "run_unit", true);
parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "run_strict", false);
if (parsing::OPT_RUN_DUR == false)
{
Parsing::OPT_RUN_UNIT = false;
Parsing::OPT_RUN_STRICT = false;
parsing::OPT_RUN_UNIT = false;
parsing::OPT_RUN_STRICT = false;
}
Parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "norest", false);
parsing::OPT_RUN_STRICT = reader.GetBoolean("options", "norest", false);
// CST_ALPHA = reader.GetReal("params", "alpha", 0.5);
Weight::CST_ALPHA = reader.GetReal("params", "alpha", 1.0);
......
......@@ -29,7 +29,7 @@
#include "ParsingEnv.hpp"
namespace Parsing{
namespace parsing{
/// @brief template for keys.
/// a key is an augmented state,
......@@ -280,7 +280,7 @@ private:
};
} // end namespace Parsing
} // end namespace parsing
// separated definition of template class
......
......@@ -6,7 +6,7 @@
// Copyright © 2019 Florent Jacquemard. All rights reserved.
//
namespace Parsing{
namespace parsing{
template<class K>
......@@ -126,4 +126,4 @@ Run* Key<K>::failRun(const ParsingEnv& env) const
} // end namespace Parsing
} // end namespace parsing
......@@ -9,7 +9,7 @@
#include "KeyS.hpp"
namespace Parsing{
namespace parsing{
// rank default to 1 at creation
......@@ -176,4 +176,4 @@ std::ostream& operator<<(std::ostream& o, const KeyS& k)
}
} // end namespace Parsing
} // end namespace parsing
......@@ -27,7 +27,7 @@
#include "RunFactory.hpp"
namespace Parsing{
namespace parsing{
// for printing the keys
#define KEY_LPAR '<'
......@@ -230,7 +230,7 @@ struct KeySHasher
};
} // end namespace Parsing
} // end namespace parsing
// separated definition of template class
......
......@@ -8,7 +8,7 @@
#include "KeySI.hpp"
namespace Parsing{
namespace parsing{
// internal use
......@@ -293,8 +293,6 @@ void KeySI::RunsTerminal(const Transition& t,
const ParsingEnv& env) const
{
const label_t& a = t.label();
Weight w = terminalWeight(a, t, env);
size_t len = 0; // set in the different cases below
assert(SymbLabel::terminal(a));
assert(_interval);
......@@ -315,7 +313,8 @@ void KeySI::RunsTerminal(const Transition& t,
if ((_interval->lsize() == 0) && (_interval->rsize() == 0))
{
// 0 or -1 point to read in interval
len = 0;
Weight w = terminalWeight(a, t, env);
size_t len = 0;
RunFactory<KeySI>::terminalRun(*this, t, a, w, len, st);
}
}
......@@ -328,7 +327,8 @@ void KeySI::RunsTerminal(const Transition& t,
(_interval->rsize() == 0))
{
// 0 or -1 points to read
len = _interval->lsize();;
Weight w = terminalWeight(a, t, env);
size_t len = _interval->lsize();;
RunFactory<KeySI>::terminalRun(*this, t, a, w, len, st);
}
}
......@@ -340,7 +340,8 @@ void KeySI::RunsTerminal(const Transition& t,
(_interval->rsize() == 0))
{
// _interval->lsize() = gn + grace-rests + 1 notev or -1 points to read
len = _interval->lsize();
Weight w = terminalWeight(a, t, env);
size_t len = _interval->lsize();
RunFactory<KeySI>::terminalRun(*this, t, a, w, len, st);
}
}
......@@ -350,7 +351,8 @@ void KeySI::RunsTerminal(const Transition& t,
if ((_interval->rduration() < _barlen) && (! _interval->inhabited()))
{
// 0 or -1 point to read in interval
len = 0;
Weight w = terminalWeight(a, t, env);
size_t len = 0;
RunFactory<KeySI>::terminalRun(*this, t, a, w, len, st);
}
}
......@@ -598,4 +600,4 @@ std::ostream& operator<<(std::ostream& o, const KeySI& p)
} // end namespace Parsing
} // end namespace parsing
......@@ -23,7 +23,7 @@
#include "IntervalTree.hpp"
#include "IntervalHeap.hpp"
namespace Parsing{
namespace parsing{
/// Key (augmented SWTA state) made of
......@@ -239,7 +239,7 @@ struct KeySIHasher
}
};
} // end namespace Parsing
} // end namespace parsing
#endif /* KeySI_hpp */
......
......@@ -9,7 +9,7 @@
#include "KeySIO.hpp"
namespace Parsing{
namespace parsing{
// top constructor (top state = first bar)
......@@ -533,4 +533,4 @@ std::ostream& operator<<(std::ostream& o, const KeySIO& p)
}
} // end namespace Parsing
} // end namespace parsing
......@@ -29,7 +29,7 @@
namespace Parsing{
namespace parsing{
/// type for pre post values in augmented states
/// same as KeySIP.hpp
......@@ -302,7 +302,7 @@ struct KeySIOHasher
};
} // end namespace Parsing
} // end namespace parsing
#endif /* KeySIO_hpp */
......
......@@ -9,7 +9,7 @@
#include "KeySIP.hpp"
namespace Parsing{
namespace parsing{
// static
//pre_t KeySIP::P_UNKNOWN = -1;
......@@ -282,9 +282,6 @@ void KeySIP::RunsTerminal(const Transition& t,
}
assert(knew);
assert(P_KNOWN(knew->_post));
Weight w = terminalWeight(a, t, env); // terminalWeight(a, t, env);
assert(! w.unknown());
/// filter term label
if (SymbLabel::note(a) || SymbLabel::rest(a) ||
......@@ -297,8 +294,8 @@ void KeySIP::RunsTerminal(const Transition& t,
size_t n = SymbLabel::nbEvents(a);
if (n == _pre + _interval->lsize())
{
Weight w = terminalWeight(a, t, env); // terminalWeight(a, t, env);
assert(! w.unknown());
// n points = grace-notes + grace-rests + 1 note or -1
RunFactory<KeySIP>::terminalRun(*knew, t, a, w, n, st);
}
......@@ -313,6 +310,8 @@ void KeySIP::RunsTerminal(const Transition& t,
// && (DBL_APPROX_EQUAL(_interval->rend(), _interval->rbegin()))
if ((_interval->rduration() < _barlen) && (! _interval->inhabited()))
{
Weight w = terminalWeight(a, t, env); // terminalWeight(a, t, env);
assert(! w.unknown());
// 0 or -1 point to read in interval
RunFactory<KeySIP>::terminalRun(*knew, t, a, w, 0, st);
}
......@@ -482,4 +481,4 @@ std::ostream& operator<<(std::ostream& o, const KeySIP& p)
} // end namespace Parsing
} // end namespace parsing
......@@ -25,7 +25,7 @@
#include "IntervalHeap.hpp"
namespace Parsing{
namespace parsing{
/// type for pre post values in augmented states
typedef long pre_t;
......@@ -225,7 +225,7 @@ struct KeySIPHasher
}
};
} // end namespace Parsing
} // end namespace parsing
#endif /* KeySIP_hpp */
......
......@@ -9,7 +9,7 @@
#include "KeySIR.hpp"
namespace Parsing{
namespace parsing{
// static
......@@ -502,4 +502,4 @@ std::ostream& operator<<(std::ostream& o, const KeySIR& p)
}
} // end namespace Parsing
} // end namespace parsing
......@@ -27,7 +27,7 @@
#include "IntervalHeap.hpp"
namespace Parsing{
namespace parsing{
// type for pre post values in augmented states
//typedef long pre_t;
......@@ -267,7 +267,7 @@ struct KeySIRHasher
};
} // end namespace Parsing
} // end namespace parsing
#endif /* KeySIR_hpp */
......
......@@ -8,7 +8,7 @@
#include "KeySV.hpp"
namespace Parsing{
namespace parsing{
// internal use
......@@ -598,4 +598,4 @@ std::ostream& operator<<(std::ostream& o, const KeySV& k)
}
} // end namespace Parsing
} // end namespace parsing
......@@ -25,7 +25,7 @@
//#include "Distance.hpp"
//#include "Runey.hpp"
namespace Parsing{
namespace parsing{
//template<class K> class Run;
......@@ -348,7 +348,7 @@ struct KeySVHasher
};
} // end namespace Parsing
} // end namespace parsing
#endif /* KeySV_hpp */
......
Markdown is supported
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