This repository was archived by the owner on Sep 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathAItest.cpp
More file actions
86 lines (74 loc) · 1.42 KB
/
AItest.cpp
File metadata and controls
86 lines (74 loc) · 1.42 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<string>test;
vector<string>feature;
vector<string>cls;
vector<string>like;
vector<string>mapc;
string str;
ifstream read("cat.txt");
while(getline (read,str))
{
test.push_back(str);
}
read.close();
/*for(int i=0;i<test.size();i++){
cout<<test[i]<<"\n";
}*/
FILE *fptr;
if ((fptr = fopen("likelihood.txt", "r")) == NULL)
{
printf("Error! opening file");
exit(1);
}
char f[100], c[100], l[100], m[100];
string c1,c2,m1,m2;
while(fscanf(fptr, "%s %s %s %s", f, c, l, m)!=EOF){
string s1="";
string s2="";
string s3="";
string s4="";
for(int i=0; i<strlen(f); i++){
s1 += f[i] ;
}
feature.push_back(s1);
for(int i=0; i<strlen(c); i++){
s2 += c[i] ;
}
cls.push_back(s2);
for(int i=0; i<strlen(l); i++){
s3 += l[i] ;
}
like.push_back(s3);
for(int i=0; i<strlen(m); i++){
s4 += m[i] ;
}
mapc.push_back(s4);
}
for(int i=0;i<test.size();i++){
for(int j=0;j<feature.size();j++){
if(test[i]==feature[j])
{
if(cls[j]=="dog")
{
c1 = cls[j];
m1 = mapc[j];
}
else
{
c2 = cls[j];
m2 = mapc[j];
}
}
}
if(m1>m2){
cout<<test[i]<<"\t--> "<<"dog"<<"\n";
}
else{
cout<<test[i]<<"\t--> "<<"cat"<<"\n";
}
}
return 0;
}