-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDatasetAdapter.cpp
More file actions
55 lines (43 loc) · 1.14 KB
/
DatasetAdapter.cpp
File metadata and controls
55 lines (43 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
45
46
47
48
49
50
51
52
53
/*
* DatasetAdapter.cpp
*
* Created on: Jul 26, 2016
* Author: trabucco
*/
#include "DatasetAdapter.h"
DatasetAdapter::DatasetAdapter() {
// TODO Auto-generated constructor stub
ifstream trainingDatasetFile("/stash/tlab/datasets/Language/nietzsche.txt");
charIndex = -1;
if (trainingDatasetFile.is_open()) {
char buffer;
while (trainingDatasetFile.get(buffer)) {
dataset.text.push_back(static_cast<unsigned char>(buffer));
} cout << "Text loaded" << endl;
trainingDatasetFile.close();
} else cout << "Error opening files" << endl;
}
DatasetAdapter::~DatasetAdapter() {
// TODO Auto-generated destructor stub
}
int DatasetAdapter::getCharSize() {
return charSize;
}
int DatasetAdapter::getDatasetSize() {
return dataset.text.size();
}
bool DatasetAdapter::nextChar() {
return (++charIndex < (getDatasetSize() - 1));
}
bool DatasetAdapter::isLastChar() {
return (charIndex == (getDatasetSize() - 2));
}
DatasetExample DatasetAdapter::getChar() {
DatasetExample example;
example.current = dataset.text[charIndex];
example.next = dataset.text[charIndex + 1];
return example;
}
void DatasetAdapter::reset() {
charIndex = -1;
}