]> ruin.nu Git - germs.git/blobdiff - src/main.cpp
Only show models with positive score, and convert the enum to strings
[germs.git] / src / main.cpp
index 34ac34fbfc54cfa749900b90d337cd3a4b9be66f..1c6a85ecc85790716e6a8559e1ea86117d716922 100644 (file)
@@ -15,6 +15,13 @@ using namespace std;
 
 typedef pair<ModelIdentifier::Model,double> modelpair;
 
+struct ScoreCmp {
+       template<typename T>
+       bool operator()(T s1, T s2){
+               return s1.first < s2.first;
+       }
+};
+
 int main(int argc, char** argv){
 
        string ann = "default.ann";
@@ -61,9 +68,16 @@ int main(int argc, char** argv){
        //TODO: Identify
        ModelIdentifier mi(ann);
        map<ModelIdentifier::Model,double> scores = mi.identify(go);
+       priority_queue<pair<double,ModelIdentifier::Model>,vector<pair<double,ModelIdentifier::Model> >, ScoreCmp > pq;
        for (map<ModelIdentifier::Model,double>::iterator m = scores.begin();
                        m != scores.end(); ++m){
-               cout << "Model: " << m->first << " score: " << m->second << endl;
+               if (m->second > 0){
+                       pq.push(pair<double,ModelIdentifier::Model>(m->second,m->first));
+               }
+       }
+       while (pq.size() > 0){
+               cout << "Model: " << mi.modelName(pq.top().second) << " score: " << pq.top().first << endl;
+               pq.pop();
        }
 
        //TODO: Chose a sorter