/* ---- This file is part of SECONDO. Copyright (C) 2004, University in Hagen, Department of Computer Science, Database Systems for New Applications. SECONDO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SECONDO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SECONDO; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ---- //paragraph [1] Title: [{\Large \bf \begin {center}] [\end {center}}] //[TOC] [\tableofcontents] split from the SymbolicTrajectoryAlgebra in April 2020. */ #include "Algebras/TemporalUnit/TemporalUnitAlgebra.h" #include "StandardTypes.h" #include "Stream.h" #include "Algebras/FText/FTextAlgebra.h" #include "Algebras/Temporal/TemporalAlgebra.h" #include "Algebras/Collection/CollectionAlgebra.h" #include "Algebras/Trie/InvertedFile.h" namespace stj { enum LabelFunction {TRIVIAL, EDIT}; enum DistanceFunction {FIRST, LAST, FIRST_LAST, ALL, ALL_DURATION, ALL_INTERVALS, EQUAL_LABELS, COSINUS_SIM, TF_IDF}; enum DistanceFunSym {ERROR = -1, EQUALLABELS, PREFIX, SUFFIX, PREFIXSUFFIX}; template class NewPair { public: NewPair() {} NewPair(const F f, const S s) : first(f), second(s) {} F first; S second; bool operator==(const NewPair& np) const { return (first == np.first && second == np.second); } bool operator!=(const NewPair& np) const { return !(*this == np); } bool operator<(const NewPair& np) const { if (first == np.first) { return second < np.second; } return first < np.first; } void set(const F& f, const S& s) { first = f; second = s; } void operator=(const NewPair& np) { set(np.first, np.second); } friend std::ostream& operator<<(std::ostream& os, const NewPair& np) { os << "(" << np.first << ", " << np.second << ")"; return os; } void Print(std::ostream& os) const { os << *this; } template void copy2ndFrom(const X newValue) { assert(sizeof(S) == sizeof(X)); memcpy((void*)&second, &newValue, sizeof(S)); } }; template class NewTriple { public: NewTriple() {} NewTriple(F f, S s, T t) : first(f), second(s), third(t) {} F first; S second; T third; bool operator==(const NewTriple& nt) const { return (first == nt.first && second == nt.second && third = nt.third); } bool operator<(const NewTriple& nt) const { if (first < nt.first) { return true; } if (first == nt.first) { if (second < nt.second) { return true; } if (second == nt.second) { return third < nt.third; } } return false; } friend std::ostream& operator<<(std::ostream& os, const NewTriple& nt) { os << nt.first << ", " << nt.second << ", " << nt.third; return os; } }; struct SymbolicUnit { public: SymbolicUnit() {} SymbolicUnit(unsigned int p, unsigned int r) : iv(true), pos(p) {} temporalalgebra::SecInterval iv; unsigned int pos; }; struct ExtSymbolicUnit : public SymbolicUnit { ExtSymbolicUnit() {} ExtSymbolicUnit(unsigned int p, unsigned int r) : SymbolicUnit(p,r), ref(r) {} unsigned int ref; }; struct BasicDistanceFuns { static double distance(const std::string& str1, const std::string& str2, const LabelFunction lf = TRIVIAL); static double distance(const std::pair& val1, const std::pair& val2, const LabelFunction lf = TRIVIAL); static double distance(const std::set& values1, const std::set& values2, const LabelFunction lf = EDIT); static double distance(std::set >& values1, std::set >& values2, const LabelFunction lf = EDIT); }; struct RecodeFun { #ifdef RECODE static bool recode(const std::string &src, const std::string &from, const std::string &to, std::string &result); #endif }; class Labels; /* \section{Class ~Label~} */ class Label : public Attribute { public: friend class Labels; typedef SymbolicUnit unitelem; typedef std::string base; typedef Labels coll; Label() {} Label(const std::string& text) : Attribute(true), value(8) {SetValue(text);} Label(const Label& rhs); explicit Label(const bool def) : Attribute(def), value(8) {} ~Label() {} void Clean() { if (value.getSize() > 0) {value.clean();}} void Destroy() {value.destroy();} void GetValue(std::string &text) const; std::string GetLabel() const {return GetValue();} std::string GetValue() const; unsigned int GetRef() const {return 0;} void GetValues(std::set& values) const; static void buildValue(const std::string& text, const unitelem& unit,base& result); static ListExpr getList(const std::string& text) { return nl->TextAtom(text); } void Set(const bool def, const std::string &text) { std::string newText = text; std::replace(newText.begin(), newText.end(), '\'', '`'); SetDefined(def); SetValue(newText); } void SetValue(const std::string &text); Label& operator=(const Label& lb) {CopyFrom(&lb); return *this;} bool operator==(const Label& lb) const; bool operator==(const std::string& text) const; double Distance(const Label& lb, const LabelFunction lf = EDIT) const; void InsertLabels(std::vector& result) const; void InsertLabels(std::set& result) const; void UpdateFrequencies(InvertedFile& inv, std::vector& fv) const; static bool readValueFrom(ListExpr LE, std::string& text, unitelem& unit); bool ReadFrom(ListExpr LE, ListExpr typeInfo); ListExpr ToListExpr(ListExpr typeInfo); static bool CheckKind(ListExpr type, ListExpr& errorInfo); static int SizeOfObj() {return sizeof(Label);} static ListExpr Property(); static const std::string BasicType() {return "label";} static const bool checkType(const ListExpr type); void CopyFrom(const Attribute* right); int NumOfFLOBs() const {return 1;} Flob *GetFLOB(const int i) {assert(i == 0); return &value;} int Compare(const Attribute* arg) const; size_t Sizeof() const {return sizeof(*this);} bool Adjacent(const Attribute*) const {return false;} Attribute* Clone() const {return new Label(*this);} size_t HashValue() const {return value.getSize();} std::ostream& Print(std::ostream& os) const; protected: Flob value; }; /* \section{Class ~Labels~} */ class Labels : public Attribute { public: typedef SymbolicUnit unitelem; typedef unsigned int arrayelem; typedef std::string base; typedef Label single; Labels() {} explicit Labels(const bool defined) : Attribute(defined), values(8), pos(1) {} Labels(const Labels& src, const bool sort = false); ~Labels() {} Labels& operator=(const Labels& src); bool operator==(const Labels& src) const; void Append(const Label &lb); void Append(const std::string& text); void Append(const std::set& values); void Destroy() {values.destroy(); pos.destroy();} int GetNoValues() const {return pos.Size();} int GetNoComponents() const {return GetNoValues();} size_t GetLength() const {return values.getSize();} void Get(int i, Label& lb) const; void GetValue(int i, std::string& text) const; void GetValues(std::set& values) const; static void getRefToLastElem(const int size, unsigned int& result); static unsigned int getFlobPos(const arrayelem elem); static void valuesToListExpr(const std::set& values, ListExpr& result); static void getString(const ListExpr& list, std::string& result); static void getElemFromList(const ListExpr& list, const unsigned int size, unsigned int& result); static void buildValue(const std::string& text, const unsigned int pos, std::string& result); static void printArrayElem(const arrayelem e) {cout << "print " << e << endl;} const bool IsEmpty() const {return GetNoValues() == 0;} void Clean() {values.clean(); pos.clean();} bool Contains(const std::string& text) const; bool Intersects(const Labels &lbs) const; void Union(const std::set& values1, const std::set& values2); void Intersection(const std::set& values1, const std::set& values2); void Minus(const std::set& values1, const std::set& values2); #ifdef RECODE bool Recode(const std::string& from, const std::string& to, Labels& result); #endif friend std::ostream& operator<<(std::ostream& os, const Labels& lbs); double Distance(const Labels& lbs, const LabelFunction lf = EDIT) const; void InsertLabels(std::vector& result) const; void InsertLabels(std::set& result) const; void UpdateFrequencies(InvertedFile& inv, std::vector& fv) const; int NumOfFLOBs() const {return 2;} Flob *GetFLOB(const int i); int Compare(const Attribute*) const; bool Adjacent(const Attribute*) const {return false;} Attribute *Clone() const {return new Labels(*this);} size_t Sizeof() const {return sizeof(*this);} std::ostream& Print(std::ostream& os) const {return (os << *this);} static ListExpr Property(); static bool CheckKind(ListExpr type, ListExpr& errorInfo); static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); static int SizeOfObj() {return sizeof(Labels);} static const std::string BasicType() {return Label::BasicType() + "s";} void CopyFrom(const Attribute* right) {*this = *((Labels*)right);} size_t HashValue() const; protected: Flob values; DbArray pos; }; class Places; /* \section{Class ~Place~} */ class Place : public Label { public: friend class Places; typedef ExtSymbolicUnit unitelem; typedef std::pair base; typedef Places coll; Place() : Label() {} Place(const std::pair& v) : Label(v.first), ref(v.second) {} Place(const Place& rhs) : Label(rhs.IsDefined()) {CopyFrom(&rhs);} explicit Place(const bool def) : Label(def), ref(0) {} ~Place() {} void Set(const bool defined, const std::pair& value); void SetValue(const std::pair& value); void SetRef(const unsigned int value) {ref = value;} void GetValue(std::pair& value) const; std::string GetLabel() const {return Label::GetLabel();} void GetValues(std::set >& values) const; static void buildValue(const std::string& text, const unitelem& unit,base& result); static ListExpr getList(const base& value); unsigned int GetRef() const {return ref;} Place& operator=(const Place& p); bool operator==(const Place& p) const; bool operator==(const std::pair& value) const; double Distance(const Place& p, const LabelFunction lf = EDIT) const; static ListExpr Property(); static int SizeOfObj() {return sizeof(Place);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "place";} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return Label::NumOfFLOBs();} Flob* GetFLOB(const int i) {return Label::GetFLOB(i);} size_t Sizeof() const {return sizeof(*this);} int Compare(const Attribute* arg) const; bool Adjacent(const Attribute *arg) const {return false;} Attribute *Clone() const {return new Place(*this);} size_t HashValue() const {return Label::HashValue() * ref;} virtual void CopyFrom(const Attribute* right) {*this = *((Place*)right);} ListExpr ToListExpr(ListExpr typeInfo); static bool readValueFrom(ListExpr LE, std::string& text, unitelem& unit); bool ReadFrom(ListExpr LE, ListExpr typeInfo); protected: unsigned int ref; }; /* \section{Class ~Places~} */ class Places : public Attribute { public: typedef ExtSymbolicUnit unitelem; typedef NewPair arrayelem; typedef std::pair base; typedef Place single; Places() {} Places(const int n) : Attribute(n > 0), values(8), posref(n) {} Places(const Places& rhs, const bool sort = false); explicit Places(const bool def) : Attribute(def), values(8), posref(1) {} ~Places() {} void Append(const base& value); void Append(const Place& pl); void Append(const std::set& values); void Destroy() {values.destroy(); posref.destroy();} int GetNoValues() const {return posref.Size();} int GetNoComponents() const {return GetNoValues();} size_t GetLength() const {return values.getSize();} void Get(const int i, Place& pl) const; void GetValue(int i, base& val) const; void GetValues(std::set& values) const; bool IsEmpty() const {return (GetNoValues() == 0);} bool Contains(const base& val) const; bool Intersects(const Places &pls) const; void Union(const std::set& values1, const std::set& values2); void Intersection(const std::set& values1, const std::set& values2); void Minus(const std::set& values1, const std::set& values2); void Clean() {values.clean(); posref.clean();} static void getRefToLastElem(const int size, arrayelem& result); static unsigned int getFlobPos(const arrayelem elem); static void valuesToListExpr(const std::set& values, ListExpr& result); static void getString(const ListExpr& list, std::string& result); static void getElemFromList(const ListExpr& list, const unsigned int size, arrayelem& result); static void buildValue(const std::string& text, const arrayelem pos, base& result); static void printArrayElem(const arrayelem e) {cout << e.first << " " << e.second;} void operator=(const Places& p); bool operator==(const Places& p) const; double Distance(const Places& p, const LabelFunction lf = EDIT) const; void InsertLabels(std::vector& result) const; void InsertLabels(std::set& result) const; void UpdateFrequencies(InvertedFile& inv, std::vector& fv) const; static ListExpr Property(); static int SizeOfObj() {return sizeof(Places);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return Place::BasicType() + "s";} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return 2;} Flob* GetFLOB(const int i); size_t Sizeof() const {return sizeof(*this);} int Compare(const Attribute* arg) const; bool Adjacent(const Attribute *arg) const {return false;} Attribute *Clone() const {return new Places(*this);} size_t HashValue() const; virtual void CopyFrom(const Attribute* right) {*this = *((Places*)right);} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); protected: Flob values; DbArray > posref; }; /* \section{Class ~IBasic~} */ template class IBasic : public temporalalgebra::Intime { public: IBasic() {} explicit IBasic(const Instant& inst, const B& val); explicit IBasic(const IBasic& rhs); IBasic(const bool def) : temporalalgebra::Intime(def) {} ~IBasic() {} static ListExpr Property(); static int SizeOfObj() {return sizeof(IBasic);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "i" + B::BasicType();} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return this->value.NumOfFLOBs();} Flob* GetFLOB(const int i) {return this->value.GetFLOB(i);} size_t Sizeof() const {return sizeof(*this);} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); void Val(B& result) const; }; /* \section{Class ~IBasics~} */ template class IBasics : public temporalalgebra::Intime { public: IBasics() {} explicit IBasics(const Instant& inst, const B& values); IBasics(const IBasics& rhs) : temporalalgebra::Intime(rhs) {} IBasics(const bool def) : temporalalgebra::Intime(def) {} static ListExpr Property(); static int SizeOfObj() {return sizeof(IBasics);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "i" + B::BasicType();} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return this->value.NumOfFLOBs();} Flob* GetFLOB(const int i) {return this->value.GetFLOB(i);} size_t Sizeof() const {return sizeof(*this);} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); void Val(B& result) const; }; /* \section{Class ~UBasic~} */ template class UBasic : public temporalalgebra::ConstTemporalUnit { public: UBasic() : temporalalgebra::ConstTemporalUnit(true) {} explicit UBasic(bool def) : temporalalgebra::ConstTemporalUnit(def) {} explicit UBasic(const temporalalgebra::SecInterval &iv, const B& val); UBasic(const temporalalgebra::Interval& iv, const B& b1, const B& b2); UBasic(const UBasic& ub); ~UBasic() {} bool operator==(const UBasic& rhs) const; static ListExpr Property(); static int SizeOfObj() {return sizeof(UBasic);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "u" + B::BasicType();} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return this->constValue.NumOfFLOBs();} Flob* GetFLOB(const int i) {return this->constValue.GetFLOB(i);} size_t Sizeof() const {return sizeof(*this);} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); void Initial(IBasic& result) const; void Final(IBasic& result) const; void GetInterval(temporalalgebra::SecInterval& result) const; }; /* \section{Class ~UBasics~} */ template class UBasics : public temporalalgebra::ConstTemporalUnit { public: UBasics() : temporalalgebra::ConstTemporalUnit(true) {} UBasics(const temporalalgebra::SecInterval& iv, const B& values); UBasics(const UBasics& rhs) : temporalalgebra::ConstTemporalUnit(rhs) {} explicit UBasics(const bool def) : temporalalgebra::ConstTemporalUnit(def) {} static ListExpr Property(); static int SizeOfObj() {return sizeof(UBasics);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "u" + B::BasicType();} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return this->constValue.NumOfFLOBs();} Flob* GetFLOB(const int i) {return this->constValue.GetFLOB(i);} size_t Sizeof() const {return sizeof(*this);} ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); void Initial(IBasics& result) const; void Final(IBasics& result) const; void GetInterval(temporalalgebra::SecInterval& result) const; }; class MLabel; /* \section{Class ~MBasic~} */ template class MBasic : public Attribute { public: typedef B base; MBasic() {} explicit MBasic(unsigned int n) : Attribute(n>0), values(1024), units(n), noChars(0) {} explicit MBasic(const MBasic& mb); ~MBasic() {} static ListExpr Property(); static int SizeOfObj() {return sizeof(MBasic);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "m" + B::BasicType();} static bool checkType(ListExpr t) {return listutils::isSymbol(t,BasicType());} int NumOfFLOBs() const {return 2;} Flob* GetFLOB(const int i); size_t Sizeof() const {return sizeof(*this);} int Compare(const Attribute *arg) const; Attribute* Clone() const {return new MBasic(*this);} bool Adjacent(const Attribute *arg) const {return false;} size_t HashValue() const; MBasic& operator=(const MBasic& src); void CopyFrom(const Attribute *arg); ListExpr unitToListExpr(const int i); ListExpr ToListExpr(ListExpr typeInfo); bool readUnitFrom(ListExpr LE); bool ReadFrom(ListExpr LE, ListExpr typeInfo); int GetNoChars() const {return noChars;} void serialize(size_t &size, char *&bytes) const; static MBasic* deserialize(const char *bytes); int Position(const Instant& inst, const bool ignoreClosedness = false) const; int FirstPosFrom(const Instant& inst) const; int LastPosUntil(const Instant& inst) const; void Get(const int i, UBasic& result) const; void GetInterval(const int i, temporalalgebra::SecInterval& result) const; void GetInterval(temporalalgebra::SecInterval& result) const; void GetDuration(datetime::DateTime& result) const; void GetBasic(const int i, B& result) const; void GetValue(const int i, typename B::base& result) const; bool IsEmpty() const {return units.Size() == 0;} int GetNoComponents() const {return units.Size();} bool IsValid() const; void Clear() {values.clean(); units.clean(); noChars = 0;} void StartBulkLoad() {assert(IsDefined());} void EndBulkLoad(const bool sort = true, const bool checkvalid = true); void Add(const temporalalgebra::SecInterval& iv, const B& value); void Add(const UBasic& ub); void MergeAdd(const UBasic& ub); bool Passes(const B& basic) const; template bool Passes(const T& value) const; void At(const B& basic, MBasic& result) const; template void At(const T& value, MBasic& result) const; void DefTime(temporalalgebra::Periods& per) const; void AtInstant(const Instant& inst, IBasic& result) const; void AtPeriods(const temporalalgebra::Periods& per, MBasic& result) const; void Initial(IBasic& result) const; void Final(IBasic& result) const; void InitialInstant(Instant& result) const; void FinalInstant(Instant& result) const; void Inside(const typename B::coll& coll, temporalalgebra::MBool& result) const; void Fill(MBasic& result, datetime::DateTime& duration) const; void Concat(const MBasic& src1, const MBasic& src2); void Compress(MBasic& result) const; void GetPart(const int from, const int to, MBasic& result); #ifdef RECODE void Recode(const std::string& from, const std::string& to,MBasic& result); #endif NewPair LongestCommonSubsequence(const MBasic& mb); std::ostream& Print(std::ostream& os) const; double Distance_FIRST(const MBasic& mb) const; double Distance_LAST(const MBasic& mb) const; double Distance_FIRST_LAST(const MBasic& mb, const LabelFunction lf) const; double Distance_ALL(const MBasic& mb, const LabelFunction lf) const; double Distance_ALL_DURATION(const MBasic& mb, const LabelFunction lf) const; double Distance_ALL_INTERVALS(const MBasic& mb, const LabelFunction lf) const; double Distance_EQUAL_LABELS(const MBasic& mb, const LabelFunction lf) const; double Distance_COSINUS_SIM(const MBasic& mb); double Distance_TF_IDF(const MBasic& mb); double Distance(const MBasic& mb, const DistanceFunction df = ALL, const LabelFunction lf = TRIVIAL, const double threshold = 1.0) const; int CommonPrefixSuffix(const MBasic& mb, const bool prefix); double DistanceSym(const MBasic& mb, const DistanceFunSym distfun); void InsertLabels(std::vector& result) const; void InsertLabels(std::set& result) const; void FrequencyVector(InvertedFile& inv, std::vector& fv, const bool useIdf = false) const; protected: Flob values; DbArray units; int noChars; }; /* \section{Class ~MBasics~} */ template class MBasics : public Attribute { public: typedef B base; MBasics() {} explicit MBasics(int n) : Attribute(n > 0), values(8), units(n), pos(1), noChars(0) {} explicit MBasics(const MBasics& mbs); ~MBasics() {} static ListExpr Property(); static int SizeOfObj() {return sizeof(MBasics);} static bool CheckKind(ListExpr type, ListExpr& errorInfo); static const std::string BasicType() {return "m" + B::BasicType();} static bool checkType(ListExpr t); int NumOfFLOBs() const {return 3;} Flob* GetFLOB(const int i); size_t Sizeof() const {return sizeof(*this);} int Compare(const Attribute* arg) const; bool Adjacent(const Attribute *arg) const {return false;} Attribute *Clone() const; size_t HashValue() const {return pos.Size() * units.Size();} void CopyFrom(const Attribute* right) {*this = *((MBasics*)right);} MBasics& operator=(const MBasics& src); ListExpr ToListExpr(ListExpr typeInfo); bool ReadFrom(ListExpr LE, ListExpr typeInfo); void Destroy() {values.destroy(); units.destroy(); pos.destroy();} int getUnitEndPos(const int i) const; ListExpr valuesToListExpr(int start, int end); ListExpr unitToListExpr(int i); bool readValues(ListExpr valuelist); bool readUnit(ListExpr unitlist); int GetNoChars() const {return noChars;} void serialize(size_t &size, char *&bytes) const; static MBasics* deserialize(const char *bytes); int Position(const Instant& inst, const bool ignoreClosedness = false) const; int FirstPosFrom(const Instant& inst) const; int LastPosUntil(const Instant& inst) const; void Get(const int i, UBasics& result) const; void GetBasics(const int i, B& result) const; bool IsEmpty() const {return units.Size() == 0;} void GetValues(const int i, std::set& result) const; void GetInterval(const int i, temporalalgebra::SecInterval& result) const; void GetInterval(temporalalgebra::SecInterval& result) const; int GetNoComponents() const {return units.Size();} int GetNoValues() const {return pos.Size();} void Clear(); void StartBulkLoad() {assert(IsDefined());} void EndBulkLoad(const bool sort = true, const bool checkvalid = true); bool IsValid() const; void Add(const UBasics& ut); void Add(const temporalalgebra::SecInterval& iv, const B& values); void MergeAdd(const UBasics& ut); void MergeAdd(const temporalalgebra::SecInterval& iv, const B& values); bool Passes(const typename B::single& sg) const; bool Passes(const B& bs) const; template bool Passes(const T& value) const; void At(const typename B::single& sg, MBasics& result) const; void At(const B& bs, MBasics& result) const; template void At(const T& value, MBasics& result) const; void DefTime(temporalalgebra::Periods& per) const; void AtInstant(const Instant& inst, IBasics& result) const; void AtPeriods(const temporalalgebra::Periods& per, MBasics& result) const; void Initial(IBasics& result) const; void Final(IBasics& result) const; void InitialInstant(Instant& result) const; void FinalInstant(Instant& result) const; void Fill(MBasics& result, datetime::DateTime& duration) const; void Concat(const MBasics& src1, const MBasics& src2); void Compress(MBasics& result) const; #ifdef RECODE void Recode(const std::string& from,const std::string& to,MBasics& result); #endif std::ostream& Print(std::ostream& os) const; double Distance_FIRST_LAST(const MBasics& mbs, const LabelFunction lf) const; double Distance_ALL(const MBasics& mbs, const LabelFunction lf) const; double Distance(const MBasics& mbs, const DistanceFunction df = ALL, const LabelFunction lf = TRIVIAL, const double threshold = 1.0) const; int CommonPrefixSuffix(const MBasics& mbs, const bool prefix); double DistanceSym(const MBasics& mbs, const DistanceFunSym distfun); void InsertLabels(std::vector& result) const; void InsertLabels(std::set& result) const; void FrequencyVector(InvertedFile& inv, std::vector& fv, const bool useIdf = false) const; protected: Flob values; DbArray units; DbArray pos; int noChars; }; /* \section{Class ~MLabel~} */ class MLabel : public MBasic