fixed minor bugs
This commit is contained in:
parent
891d84c630
commit
ffd46fd134
@ -53,7 +53,13 @@ int main(int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (b = 0; b < words; b++) {
|
for (b = 0; b < words; b++) {
|
||||||
fscanf(f, "%s%c", &vocab[b * max_w], &ch);
|
a = 0;
|
||||||
|
while (1) {
|
||||||
|
vocab[b * max_w + a] = fgetc(f);
|
||||||
|
if (feof(f) || (vocab[b * max_w + a] == ' ')) break;
|
||||||
|
if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++;
|
||||||
|
}
|
||||||
|
vocab[b * max_w + a] = 0;
|
||||||
for (a = 0; a < max_w; a++) vocab[b * max_w + a] = toupper(vocab[b * max_w + a]);
|
for (a = 0; a < max_w; a++) vocab[b * max_w + a] = toupper(vocab[b * max_w + a]);
|
||||||
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
||||||
len = 0;
|
len = 0;
|
||||||
|
@ -51,7 +51,13 @@ int main(int argc, char **argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (b = 0; b < words; b++) {
|
for (b = 0; b < words; b++) {
|
||||||
fscanf(f, "%s%c", &vocab[b * max_w], &ch);
|
a = 0;
|
||||||
|
while (1) {
|
||||||
|
vocab[b * max_w + a] = fgetc(f);
|
||||||
|
if (feof(f) || (vocab[b * max_w + a] == ' ')) break;
|
||||||
|
if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++;
|
||||||
|
}
|
||||||
|
vocab[b * max_w + a] = 0;
|
||||||
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
||||||
len = 0;
|
len = 0;
|
||||||
for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
|
for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
|
||||||
|
@ -50,7 +50,13 @@ int main(int argc, char **argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (b = 0; b < words; b++) {
|
for (b = 0; b < words; b++) {
|
||||||
fscanf(f, "%s%c", &vocab[b * max_w], &ch);
|
a = 0;
|
||||||
|
while (1) {
|
||||||
|
vocab[b * max_w + a] = fgetc(f);
|
||||||
|
if (feof(f) || (vocab[b * max_w + a] == ' ')) break;
|
||||||
|
if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++;
|
||||||
|
}
|
||||||
|
vocab[b * max_w + a] = 0;
|
||||||
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
for (a = 0; a < size; a++) fread(&M[a + b * size], sizeof(float), 1, f);
|
||||||
len = 0;
|
len = 0;
|
||||||
for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
|
for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
|
||||||
|
@ -152,9 +152,9 @@ void SortVocab() {
|
|||||||
train_words = 0;
|
train_words = 0;
|
||||||
for (a = 0; a < size; a++) {
|
for (a = 0; a < size; a++) {
|
||||||
// Words occuring less than min_count times will be discarded from the vocab
|
// Words occuring less than min_count times will be discarded from the vocab
|
||||||
if (vocab[a].cn < min_count) {
|
if ((vocab[a].cn < min_count) && (a != 0)) {
|
||||||
vocab_size--;
|
vocab_size--;
|
||||||
free(vocab[vocab_size].word);
|
free(vocab[a].word);
|
||||||
} else {
|
} else {
|
||||||
// Hash will be re-computed, as after the sorting it is not actual
|
// Hash will be re-computed, as after the sorting it is not actual
|
||||||
hash=GetWordHash(vocab[a].word);
|
hash=GetWordHash(vocab[a].word);
|
||||||
|
Loading…
Reference in New Issue
Block a user