-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathword-log.hpp
90 lines (75 loc) · 2.87 KB
/
word-log.hpp
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
87
88
89
90
#ifndef WORD_LOG_H_
#define WORD_LOG_H_
#include <vector>
#include <string>
#include "sense-interface.hpp"
#include "string-utils.hpp"
#include "pos-group.hpp"
#include "wn3-path.hpp"
namespace jay_io
{
struct Word_Log
{
bool containsCargo;
std::string word;
// if contains cargo, use:
std::vector<POS_Group> posGroups;
// if does not contain cargo (no match found), use:
// also write Suggestion(), Suggestion::suggestor()
std::vector<std::string> suggestions;
void previewWordLog()
{
using namespace std;
auto prettyPrintVectorOfStrings = [&] (std::vector<std::string> &vos) -> std::string {
std::string a, t;
if (vos.size() == 0)
return "-";
for (int i = 0; i < vos.size(); i++)
{
if (vos.size() - 1 != i) {
t = vos[i];
t.append(", ");
a.append(t);
} else
a.append(vos[i]);
}
return a;
};
if (posGroups.size() != 0) {
cout << "Word: " << word << endl << endl;
for (auto i: posGroups) {
for (auto itr: i.prettySenses)
itr.consoleDump();
}
} else
cout << "No results found for `" << word << "` :\\" << endl << endl;
}
std::string toHtml()
{
auto prettyPrintVectorOfStrings = [&] (std::vector<std::string> &vos) -> std::string {
std::string a, t;
if (vos.size() == 0)
return "-";
for (int i = 0; i < vos.size(); i++)
{
if (vos.size() - 1 != i) {
t = vos[i];
t.append(", ");
a.append(t);
} else
a.append(vos[i]);
}
return a;
};
std::string html = "<html><body>";
if (posGroups.size() != 0)
for (auto i: posGroups)
for (auto itr: i.prettySenses)
html += itr.toHtmlDiv();
html += "</body></html>";
std::cout << html;
return html;
}
};
}
#endif /* WORD_LOG_H_ */