-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBirdClassificationProlog.cpp
More file actions
44 lines (39 loc) · 1.14 KB
/
Copy pathBirdClassificationProlog.cpp
File metadata and controls
44 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
map<string, set<string>> attributes;
void initialize() {
attributes["sparrow"] = {"feathers", "flies", "small", "land"};
attributes["penguin"] = {"feathers", "swims", "cannot fly", "water"};
attributes["ostrich"] = {"feathers", "cannot fly", "land"};
}
string classify(const set<string>& attrs) {
for (const auto& entry : attributes) {
if (includes(attrs.begin(), attrs.end(),
entry.second.begin(), entry.second.end())) {
return entry.first;
}
}
return "unknown bird";
}
int main() {
initialize();
set<string> query1 = {"feathers", "flies", "small", "land"};
set<string> query2 = {"feathers", "swims", "cannot fly", "water"};
cout << "Bird 1 classification: " << classify(query1) << '\n';
cout << "Bird 2 classification: " << classify(query2) << '\n';
return 0;
}