Skip to content

Commit 38304f5

Browse files
committed
Merge branch 'valueclass'
2 parents ffd77a2 + 058871e commit 38304f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3498
-3245
lines changed

.github/workflows/timbl.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: C/C++ CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [master, valueclass]
66
paths:
77
- 'src/**'
88
- 'include/**'
@@ -32,6 +32,7 @@ jobs:
3232
${{ github.actor }} started a build of
3333
${{ github.event.repository.name }}
3434
[${{ steps.extract_branch.outputs.branch }}]
35+
3536
build:
3637
runs-on: ${{ matrix.os }}
3738
needs: notification

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- Autoconf -*-
22
# Process this file with autoconf to produce a configure script.
33

4-
AC_PREREQ(2.61)
4+
AC_PREREQ([2.69])
55
AC_INIT([timbl],[6.8],[[email protected]]) #also adapt in codemeta.json!
66
AM_INIT_AUTOMAKE
77
AC_CONFIG_SRCDIR([.])
88
AC_CONFIG_MACRO_DIR([m4])
9-
AC_CONFIG_HEADER([config.h])
9+
AC_CONFIG_HEADERS([config.h])
1010

1111
if test x"${CXXFLAGS+set}" = xset; then
1212
# the user set CXXFLAGS; don't override it.

demos/api_test6.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ using namespace Timbl;
3434
int main(){
3535
TimblAPI My_Experiment( "-a IB1 +vDI+DB -G 0 -k3", "test6" );
3636
My_Experiment.Learn( "dimin.train" );
37-
const ValueDistribution *vd;
37+
const ClassDistribution *vd;
3838
const TargetValue *tv
3939
= My_Experiment.Classify( std::string("-,=,O,m,+,h,K,=,-,n,I,N,K"), vd );
4040
cout << "resulting target: " << tv << endl;
4141
cout << "resulting Distribution: " << vd << endl;
42-
ValueDistribution::dist_iterator it=vd->begin();
42+
ClassDistribution::dist_iterator it=vd->begin();
4343
while ( it != vd->end() ){
4444
cout << it->second << " OR ";
4545
cout << it->second->Value() << " " << it->second->Weight() << endl;
@@ -48,7 +48,7 @@ int main(){
4848

4949
cout << "the same with neighborSets" << endl;
5050
const neighborSet *nb = My_Experiment.classifyNS( "-,=,O,m,+,h,K,=,-,n,I,N,K" );
51-
WValueDistribution *vd2 = nb->bestDistribution();
51+
WClassDistribution *vd2 = nb->bestDistribution();
5252
vd2->Normalize();
5353
cout << "default answer " << vd2 << endl;
5454
decayStruct *dc = new expDecay(0.3);

include/timbl/BestArray.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ namespace Timbl {
3838
friend std::ostream& operator<< ( std::ostream&, const BestRec * );
3939
public:
4040
BestRec();
41+
BestRec( const BestRec& ) = delete; // forbid copies
42+
BestRec& operator=( const BestRec& ) = delete; // forbid copies
4143
~BestRec();
4244
size_t totalBests() const { return aggregateDist.totalSize(); };
4345
double bestDistance;
44-
ValueDistribution aggregateDist;
45-
std::vector<ValueDistribution*> bestDistributions;
46+
ClassDistribution aggregateDist;
47+
std::vector<ClassDistribution*> bestDistributions;
4648
std::vector<icu::UnicodeString> bestInstances;
4749
private:
48-
BestRec( const BestRec& );
49-
BestRec& operator=( const BestRec& );
5050
};
5151

5252
class BestArray {
@@ -61,7 +61,7 @@ namespace Timbl {
6161
~BestArray();
6262
void init( unsigned int, unsigned int, bool, bool, bool );
6363
double addResult( double,
64-
const ValueDistribution *,
64+
const ClassDistribution *,
6565
const icu::UnicodeString& );
6666
void initNeighborSet( neighborSet& ) const;
6767
void addToNeighborSet( neighborSet& , size_t ) const;

include/timbl/Choppers.h

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ namespace Timbl{
3434

3535
class Chopper {
3636
public:
37+
Chopper():
38+
vSize(0)
39+
{};
3740
virtual ~Chopper() {};
3841
virtual bool chop( const icu::UnicodeString&, size_t ) = 0;
42+
const icu::UnicodeString& operator[]( int i ) const {
43+
return choppedInput[i]; }
3944
const icu::UnicodeString& getField( size_t i ) const {
4045
return choppedInput[i];
4146
};
@@ -68,24 +73,32 @@ namespace Timbl{
6873

6974
class ExChopper: public virtual Chopper {
7075
public:
71-
double getExW() const { return exW; };
76+
ExChopper():
77+
Chopper(),
78+
exW(-1.0)
79+
{};
80+
double getExW() const override { return exW; };
7281
protected:
73-
void init( const icu::UnicodeString&, size_t, bool );
82+
void init( const icu::UnicodeString&, size_t, bool ) override;
7483
double exW;
7584
};
7685

7786
class OccChopper: public virtual Chopper {
7887
public:
79-
int getOcc() const { return occ; };
88+
OccChopper():
89+
Chopper(),
90+
occ(-1)
91+
{};
92+
int getOcc() const override { return occ; };
8093
protected:
81-
void init( const icu::UnicodeString&, size_t, bool );
94+
void init( const icu::UnicodeString&, size_t, bool ) override;
8295
int occ;
8396
};
8497

8598
class C45_Chopper : public virtual Chopper {
8699
public:
87-
bool chop( const icu::UnicodeString&, size_t );
88-
icu::UnicodeString getString() const;
100+
bool chop( const icu::UnicodeString&, size_t ) override;
101+
icu::UnicodeString getString() const override;
89102
};
90103

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

97110
class ARFF_Chopper : public C45_Chopper {
98111
public:
99-
bool chop( const icu::UnicodeString&, size_t );
112+
bool chop( const icu::UnicodeString&, size_t ) override;
100113
};
101114

102115
class ARFF_ExChopper : public C45_ExChopper {
@@ -107,8 +120,8 @@ namespace Timbl{
107120

108121
class Bin_Chopper : public virtual Chopper {
109122
public:
110-
bool chop( const icu::UnicodeString&, size_t );
111-
icu::UnicodeString getString() const;
123+
bool chop( const icu::UnicodeString&, size_t ) override;
124+
icu::UnicodeString getString() const override;
112125
};
113126

114127
class Bin_ExChopper : public Bin_Chopper, public ExChopper {
@@ -120,8 +133,8 @@ namespace Timbl{
120133
class Compact_Chopper : public virtual Chopper {
121134
public:
122135
explicit Compact_Chopper( int L ): fLen(L){};
123-
bool chop( const icu::UnicodeString&, size_t );
124-
icu::UnicodeString getString() const;
136+
bool chop( const icu::UnicodeString&, size_t ) override;
137+
icu::UnicodeString getString() const override;
125138
private:
126139
int fLen;
127140
Compact_Chopper();
@@ -143,8 +156,8 @@ namespace Timbl{
143156

144157
class Columns_Chopper : public virtual Chopper {
145158
public:
146-
bool chop( const icu::UnicodeString&, size_t );
147-
icu::UnicodeString getString() const;
159+
bool chop( const icu::UnicodeString&, size_t ) override;
160+
icu::UnicodeString getString() const override;
148161
};
149162

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

156169
class Tabbed_Chopper : public virtual Chopper {
157170
public:
158-
bool chop( const icu::UnicodeString&, size_t );
159-
icu::UnicodeString getString() const;
171+
bool chop( const icu::UnicodeString&, size_t ) override;
172+
icu::UnicodeString getString() const override;
160173
};
161174

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

169182
class Sparse_Chopper : public virtual Chopper {
170183
public:
171-
bool chop( const icu::UnicodeString&, size_t );
172-
icu::UnicodeString getString() const;
184+
bool chop( const icu::UnicodeString&, size_t ) override;
185+
icu::UnicodeString getString() const override;
173186
};
174187

175188
class Sparse_ExChopper : public Sparse_Chopper, public ExChopper {

include/timbl/Common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
#define TIMBL_COMMON_H
3030

3131
#include <iostream>
32+
#include <limits>
3233
#include <cmath>
33-
#include <cfloat>
3434
#include <cassert>
3535

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

4041
std::string Version();

0 commit comments

Comments
 (0)