Skip to content

Commit

Permalink
Merge branch 'valueclass'
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Jan 2, 2023
2 parents ffd77a2 + 058871e commit 38304f5
Show file tree
Hide file tree
Showing 45 changed files with 3,498 additions and 3,245 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/timbl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C/C++ CI

on:
push:
branches: [master]
branches: [master, valueclass]
paths:
- 'src/**'
- 'include/**'
Expand Down Expand Up @@ -32,6 +32,7 @@ jobs:
${{ github.actor }} started a build of
${{ github.event.repository.name }}
[${{ steps.extract_branch.outputs.branch }}]
build:
runs-on: ${{ matrix.os }}
needs: notification
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_PREREQ([2.69])
AC_INIT([timbl],[6.8],[[email protected]]) #also adapt in codemeta.json!
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([.])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_HEADERS([config.h])

if test x"${CXXFLAGS+set}" = xset; then
# the user set CXXFLAGS; don't override it.
Expand Down
6 changes: 3 additions & 3 deletions demos/api_test6.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ using namespace Timbl;
int main(){
TimblAPI My_Experiment( "-a IB1 +vDI+DB -G 0 -k3", "test6" );
My_Experiment.Learn( "dimin.train" );
const ValueDistribution *vd;
const ClassDistribution *vd;
const TargetValue *tv
= My_Experiment.Classify( std::string("-,=,O,m,+,h,K,=,-,n,I,N,K"), vd );
cout << "resulting target: " << tv << endl;
cout << "resulting Distribution: " << vd << endl;
ValueDistribution::dist_iterator it=vd->begin();
ClassDistribution::dist_iterator it=vd->begin();
while ( it != vd->end() ){
cout << it->second << " OR ";
cout << it->second->Value() << " " << it->second->Weight() << endl;
Expand All @@ -48,7 +48,7 @@ int main(){

cout << "the same with neighborSets" << endl;
const neighborSet *nb = My_Experiment.classifyNS( "-,=,O,m,+,h,K,=,-,n,I,N,K" );
WValueDistribution *vd2 = nb->bestDistribution();
WClassDistribution *vd2 = nb->bestDistribution();
vd2->Normalize();
cout << "default answer " << vd2 << endl;
decayStruct *dc = new expDecay(0.3);
Expand Down
10 changes: 5 additions & 5 deletions include/timbl/BestArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ namespace Timbl {
friend std::ostream& operator<< ( std::ostream&, const BestRec * );
public:
BestRec();
BestRec( const BestRec& ) = delete; // forbid copies
BestRec& operator=( const BestRec& ) = delete; // forbid copies
~BestRec();
size_t totalBests() const { return aggregateDist.totalSize(); };
double bestDistance;
ValueDistribution aggregateDist;
std::vector<ValueDistribution*> bestDistributions;
ClassDistribution aggregateDist;
std::vector<ClassDistribution*> bestDistributions;
std::vector<icu::UnicodeString> bestInstances;
private:
BestRec( const BestRec& );
BestRec& operator=( const BestRec& );
};

class BestArray {
Expand All @@ -61,7 +61,7 @@ namespace Timbl {
~BestArray();
void init( unsigned int, unsigned int, bool, bool, bool );
double addResult( double,
const ValueDistribution *,
const ClassDistribution *,
const icu::UnicodeString& );
void initNeighborSet( neighborSet& ) const;
void addToNeighborSet( neighborSet& , size_t ) const;
Expand Down
47 changes: 30 additions & 17 deletions include/timbl/Choppers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ namespace Timbl{

class Chopper {
public:
Chopper():
vSize(0)
{};
virtual ~Chopper() {};
virtual bool chop( const icu::UnicodeString&, size_t ) = 0;
const icu::UnicodeString& operator[]( int i ) const {
return choppedInput[i]; }
const icu::UnicodeString& getField( size_t i ) const {
return choppedInput[i];
};
Expand Down Expand Up @@ -68,24 +73,32 @@ namespace Timbl{

class ExChopper: public virtual Chopper {
public:
double getExW() const { return exW; };
ExChopper():
Chopper(),
exW(-1.0)
{};
double getExW() const override { return exW; };
protected:
void init( const icu::UnicodeString&, size_t, bool );
void init( const icu::UnicodeString&, size_t, bool ) override;
double exW;
};

class OccChopper: public virtual Chopper {
public:
int getOcc() const { return occ; };
OccChopper():
Chopper(),
occ(-1)
{};
int getOcc() const override { return occ; };
protected:
void init( const icu::UnicodeString&, size_t, bool );
void init( const icu::UnicodeString&, size_t, bool ) override;
int occ;
};

class C45_Chopper : public virtual Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
};

class C45_ExChopper : public C45_Chopper, public ExChopper {
Expand All @@ -96,7 +109,7 @@ namespace Timbl{

class ARFF_Chopper : public C45_Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
bool chop( const icu::UnicodeString&, size_t ) override;
};

class ARFF_ExChopper : public C45_ExChopper {
Expand All @@ -107,8 +120,8 @@ namespace Timbl{

class Bin_Chopper : public virtual Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
};

class Bin_ExChopper : public Bin_Chopper, public ExChopper {
Expand All @@ -120,8 +133,8 @@ namespace Timbl{
class Compact_Chopper : public virtual Chopper {
public:
explicit Compact_Chopper( int L ): fLen(L){};
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
private:
int fLen;
Compact_Chopper();
Expand All @@ -143,8 +156,8 @@ namespace Timbl{

class Columns_Chopper : public virtual Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
};

class Columns_ExChopper : public Columns_Chopper, public ExChopper {
Expand All @@ -155,8 +168,8 @@ namespace Timbl{

class Tabbed_Chopper : public virtual Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
};

class Tabbed_ExChopper : public Tabbed_Chopper, public ExChopper {
Expand All @@ -168,8 +181,8 @@ namespace Timbl{

class Sparse_Chopper : public virtual Chopper {
public:
bool chop( const icu::UnicodeString&, size_t );
icu::UnicodeString getString() const;
bool chop( const icu::UnicodeString&, size_t ) override;
icu::UnicodeString getString() const override;
};

class Sparse_ExChopper : public Sparse_Chopper, public ExChopper {
Expand Down
5 changes: 3 additions & 2 deletions include/timbl/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
#define TIMBL_COMMON_H

#include <iostream>
#include <limits>
#include <cmath>
#include <cfloat>
#include <cassert>

namespace Common {
const double Epsilon = DBL_EPSILON; // smallest x so that 1+x != 1
const double Epsilon = std::numeric_limits<double>::epsilon();
// smallest x so that 1+x != 1
const int DEFAULT_MAX_FEATS = 2500; // default maximun number of Features

std::string Version();
Expand Down
Loading

0 comments on commit 38304f5

Please sign in to comment.