#ifndef UTTERANCETREE_H #define UTTERANCETREE_H #include #include #include #include "UttTreeNode.h" class UtteranceTree { public: enum DistType { L2, Mahal }; enum AgrCrit { Min, Max, Mean, Ward }; enum PartMeth { Silhouette, Bipartition }; UtteranceTree(); ~UtteranceTree(); void clearTree(); void clearTree(UttTreeNode *node); void setTree(const arma::mat &S, const arma::mat &W, const arma::mat &Sigma); void setDist(DistType dist); void setAgr(AgrCrit agr); void setPartMeth(PartMeth partMeth); void setDiff(const arma::mat &Diff); void displayTree(const arma::umat &map); void displayTree(UttTreeNode *node, const arma::umat &map); void displayTree(QVector characters); void displayTree(UttTreeNode *node, QVector characters); double computeWeight(UttTreeNode *node); void getClusterInstances(UttTreeNode *node, QList &instances); int getClusterSize(); int getClusterSize(UttTreeNode *node); void getCoordinates(QList>> &coord); void getCoordinates(UttTreeNode *node, QList>> &coord, int leftMost, QPointF from); DistType getDist(); void setPartition(qreal height); QList> cutTree(UttTreeNode *node, qreal height); void cutTree(UttTreeNode *node, double ultDist, QList &subTrees); double getBestCutValue(); QList> getPartition(); QVector getCutValues(); private: double computeDistance(const arma::mat &U, const arma::mat &V, const arma::mat &SigmaInv); arma::mat computeDistMat(const arma::mat &S, const arma::mat &SigmaInv); arma::mat updateDistances(QList clusters, UttTreeNode *merged1, UttTreeNode *merged2, arma::uword iMin, arma::uword iMax, const arma::mat &D); arma::mat updateDistancesWard(const arma::mat &S, QList clusters, UttTreeNode *newCluster, arma::uword iMin, arma::uword iMax); arma::mat retrieveCentroid(const arma::mat &S); arma::mat computeDeltaI(const arma::mat &D, const arma::mat &W); arma::mat computeClusterCenter(const arma::mat &S, const arma::umat &Idx); void retrieveUltDist(UttTreeNode *node, QList &ultDists); int getBestPartIdxSil(QList>> partitions); void displayClusters(QList clusters); double getBestCutValue(UttTreeNode *node); QList> m_partition; QVector m_cutValues; UttTreeNode *m_root; DistType m_dist; AgrCrit m_agr; PartMeth m_partMeth; arma::mat m_D; arma::mat m_Diff; arma::mat m_SigmaInv; }; #endif