-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcoconut-client.cpp
36 lines (27 loc) · 1020 Bytes
/
coconut-client.cpp
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
#include <iostream>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include "gen-cpp/QuestionAnswering.h"
using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
int main(void) {
boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
QuestionAnsweringClient qaClient(protocol);
transport->open();
while (std::cin) {
std::string question;
std::string answer;
getline(std::cin, question);
getline(std::cin, answer);
if (question.size() > 0 && answer.size() > 0) {
std::cout << "Question: '" << question << "'" << std::endl;
std::cout << "Answer: '" << answer << "'" << std::endl;
std::cout << "Score: " << qaClient.getScore(question, answer) << std::endl;
}
}
}