Skip to content

Commit

Permalink
updated to latest ticcutils
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Nov 17, 2024
1 parent b2db410 commit 49ad031
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 36 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ LIBS="$ICU_LIBS $LIBS"

AX_LIB_READLINE

PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.30] )
PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.36] )

CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS"
LIBS="$ticcutils_LIBS $LIBS"
Expand Down
6 changes: 4 additions & 2 deletions include/frog/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ class ParserBase {
isInit( false ),
filter( 0 )
{
errLog = new TiCC::LogStream(errlog, "parser-");
dbgLog = new TiCC::LogStream(dbglog, "parser-dbg-");
errLog = new TiCC::LogStream(errlog);
errLog->add_message("parser-");
dbgLog = new TiCC::LogStream(dbglog);
dbgLog->add_message("parser-dbg-");
};
virtual ~ParserBase();
virtual bool init( const TiCC::Configuration& ) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/AlpinoParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool AlpinoParser::init( const TiCC::Configuration& configuration ){
int level;
if ( TiCC::stringTo<int>( val, level ) ){
if ( level > 5 ){
dbgLog->setlevel( LogLevel::LogDebug );
dbgLog->set_level( LogLevel::LogDebug );
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/Frog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,17 @@ int main(int argc, char *argv[]) {
if ( system( remove_command.c_str() ) ){
// nothing
}
theErrLog = new TiCC::LogStream( cerr, "frog-", StampMessage );
theErrLog = new TiCC::LogStream( cerr );
theErrLog->set_message( "frog-" );
theErrLog->set_stamp( StampMessage );
Opts.extract( "debugfile", db_filename );
if ( db_filename.empty() ){
db_filename = "frog." + randnum(8) + ".debug";
}
the_dbg_stream = new ofstream( db_filename );
theDbgLog = new TiCC::LogStream( *the_dbg_stream, "frog-", StampMessage );
theDbgLog = new TiCC::LogStream( *the_dbg_stream );
theDbgLog->set_message( "frog-" );
theDbgLog->set_stamp( StampMessage );
FrogAPI frog( Opts, theErrLog, theDbgLog );
if ( !frog.options.fileNames.empty() ) {
frog.run_on_files();
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool Parser::init( const TiCC::Configuration& configuration ){
int level;
if ( TiCC::stringTo<int>( val, level ) ){
if ( level > 5 ){
dbgLog->setlevel( LogLevel::LogDebug );
dbgLog->set_level( LogLevel::LogDebug );
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/ckyparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ CKYParser::CKYParser( size_t num,
for ( const auto& constraint : constraints ){
addConstraint( constraint );
}
ckyLog = new TiCC::LogStream( log, "cky:" );
ckyLog = new TiCC::LogStream( log );
ckyLog->add_message( "cky:" );
}


Expand Down
19 changes: 9 additions & 10 deletions src/csidp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ unordered_map<string,double> split_dist( const vector< pair<string,double>>& dis
the result would be { {"a",0.5},{"b",0.5},{"c",0.6},{"d",0.6},{"e",0.6}}
*/
unordered_map<string,double> result;
for( const auto& it : dist ){
double d = it.second;
vector<string> tags = TiCC::split_at( it.first, "|" );
for( const auto& [str,val] : dist ){
vector<string> tags = TiCC::split_at( str, "|" );
for( const auto& t : tags ){
result[t] += d;
result[t] += val;
}
}
return result;
Expand Down Expand Up @@ -135,10 +134,10 @@ vector<const Constraint*> formulateWCSP( const vector<timbl_result>& d_res,
for ( size_t token_id = 1;
token_id <= sent_len;
++token_id ) {
for ( auto const& d : dit->dist() ){
for ( auto const& [str,val] : dit->dist() ){
constraints.push_back( new DependencyDirection( token_id,
d.first,
d.second ) );
str,
val ) );
}
++dit;

Expand Down Expand Up @@ -169,9 +168,9 @@ timbl_result::timbl_result( const string& cls,
_cls(cls),
_confidence(conf)
{
for ( const auto& it : vd ){
_dist.push_back( make_pair( TiCC::UnicodeToUTF8(it.second->Value()->name()),
it.second->Weight()) );
for ( const auto& [dummy,val] : vd ){
_dist.push_back( make_pair( TiCC::UnicodeToUTF8(val->Value()->name()),
val->Weight()) );
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/mblem_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ Mblem::Mblem( TiCC::LogStream *errlog, TiCC::LogStream *dbglog ):
keep_case( false ),
filter(0)
{
errLog = new TiCC::LogStream( errlog, "mblem-" );
errLog = new TiCC::LogStream( errlog );
errLog->add_message( "mblem-" );
if ( dbglog ){
dbgLog = new TiCC::LogStream( dbglog, "mblem" );
dbgLog = new TiCC::LogStream( dbglog );
dbgLog->add_message( "mblem" );
}
else {
dbgLog = errLog;
Expand Down
2 changes: 1 addition & 1 deletion src/mblem_prog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using namespace Timbl;
using namespace Tagger;
using TiCC::operator<<;

TiCC::LogStream my_default_log( cerr, "", StampMessage ); // fall-back
TiCC::LogStream my_default_log( cerr ); // fall-back
TiCC::LogStream *theErrLog = &my_default_log; // fill the externals

vector<string> fileNames;
Expand Down
6 changes: 4 additions & 2 deletions src/mbma_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ Mbma::Mbma( TiCC::LogStream *errlog, TiCC::LogStream *dbglog ):
\param errlog the LogStream to use for Error messages
\param dbglog the LogStream to use for Debug messages
*/
errLog = new TiCC::LogStream( errlog, "mbma-" );
errLog = new TiCC::LogStream( errlog );
errLog->add_message( "mbma-" );
if ( dbglog ){
dbgLog = new TiCC::LogStream( dbglog, "mbma-" );
dbgLog = new TiCC::LogStream( dbglog );
dbgLog->add_message( "mbma-" );
}
else {
dbgLog = errLog;
Expand Down
2 changes: 1 addition & 1 deletion src/mbma_prog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace icu;
using namespace Timbl;
using namespace Tagger;

TiCC::LogStream my_default_log( cerr, "", StampMessage ); // fall-back
TiCC::LogStream my_default_log( cerr ); // fall-back
TiCC::LogStream *theErrLog = &my_default_log; // fill the externals

vector<string> fileNames;
Expand Down
6 changes: 4 additions & 2 deletions src/mwu_chunker_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ Mwu::Mwu( TiCC::LogStream *err_log, TiCC::LogStream *dbg_log ){
a call to Mwu::init() is needed to be able to use the Mwu classifier
*/
errLog = new TiCC::LogStream( err_log, "mwu-" );
dbgLog = new TiCC::LogStream( dbg_log, "mwu-" );
errLog = new TiCC::LogStream( err_log );
errLog->add_message( "mwu-" );
dbgLog = new TiCC::LogStream( dbg_log );
dbgLog->add_message( "mwu-" );
filter = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ner_prog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using namespace std;
using namespace Timbl;
using namespace Tagger;

TiCC::LogStream my_default_log( cerr, "", StampMessage ); // fall-back
TiCC::LogStream my_default_log( cerr );
TiCC::LogStream *theErrLog = &my_default_log; // fill the externals

vector<string> fileNames;
Expand Down
16 changes: 9 additions & 7 deletions src/tagger_base.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ BaseTagger::BaseTagger( TiCC::LogStream *errlog,
tagger(NULL),
filter(NULL)
{
err_log = new TiCC::LogStream( errlog, _label + "-tagger-" );
err_log = new TiCC::LogStream( errlog );
err_log->set_message( _label + "-tagger-" );
if ( dbglog ){
dbg_log = new TiCC::LogStream( dbglog, _label + "-tagger-" );
dbg_log = new TiCC::LogStream( dbglog );
dbg_log->set_message( _label + "-tagger-" );
}
else {
dbg_log = err_log;
Expand Down Expand Up @@ -148,22 +150,22 @@ bool BaseTagger::init( const TiCC::Configuration& config ){
switch ( debug ){
case 0:
case 1:
dbg_log->setlevel(LogSilent);
dbg_log->set_level(LogSilent);
break;
case 2:
dbg_log->setlevel(LogNormal);
dbg_log->set_level(LogNormal);
break;
case 3:
case 4:
dbg_log->setlevel(LogDebug);
dbg_log->set_level(LogDebug);
break;
case 5:
case 6:
case 7:
dbg_log->setlevel(LogHeavy);
dbg_log->set_level(LogHeavy);
break;
default:
dbg_log->setlevel(LogExtreme);
dbg_log->set_level(LogExtreme);
}
string settings;
if ( _host.empty() ){
Expand Down
6 changes: 4 additions & 2 deletions src/ucto_tokenizer_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ UctoTokenizer::UctoTokenizer( TiCC::LogStream *err_log,
*/
tokenizer = 0;
cur_is = 0;
errLog = new TiCC::LogStream( err_log, "tok-" );
errLog = new TiCC::LogStream( err_log );
errLog->add_message( "tok-" );
if ( dbg_log ){
dbgLog = new TiCC::LogStream( dbg_log, "tok-" );
dbgLog = new TiCC::LogStream( dbg_log );
dbgLog->add_message( "tok-" );
}
else {
dbgLog = errLog;
Expand Down

0 comments on commit 49ad031

Please sign in to comment.