Commit d90649ac authored by tmikolov's avatar tmikolov

changed index of OOV from 0 to -1 (so that first word vector is included in search)

parent 70824595
...@@ -90,19 +90,19 @@ int main(int argc, char **argv) { ...@@ -90,19 +90,19 @@ int main(int argc, char **argv) {
cn++; cn++;
for (a = 0; a < cn; a++) { for (a = 0; a < cn; a++) {
for (b = 0; b < words; b++) if (!strcmp(&vocab[b * max_w], st[a])) break; for (b = 0; b < words; b++) if (!strcmp(&vocab[b * max_w], st[a])) break;
if (b == words) b = 0; if (b == words) b = -1;
bi[a] = b; bi[a] = b;
printf("\nWord: %s Position in vocabulary: %lld\n", st[a], bi[a]); printf("\nWord: %s Position in vocabulary: %lld\n", st[a], bi[a]);
if (b == 0) { if (b == -1) {
printf("Out of dictionary word!\n"); printf("Out of dictionary word!\n");
break; break;
} }
} }
if (b == 0) continue; if (b == -1) continue;
printf("\n Word Distance\n------------------------------------------------------------------------\n"); printf("\n Word Distance\n------------------------------------------------------------------------\n");
for (a = 0; a < size; a++) vec[a] = 0; for (a = 0; a < size; a++) vec[a] = 0;
for (b = 0; b < cn; b++) { for (b = 0; b < cn; b++) {
if (bi[b] == 0) continue; if (bi[b] == -1) continue;
for (a = 0; a < size; a++) vec[a] += M[a + bi[b] * size]; for (a = 0; a < size; a++) vec[a] += M[a + bi[b] * size];
} }
len = 0; len = 0;
...@@ -132,4 +132,4 @@ int main(int argc, char **argv) { ...@@ -132,4 +132,4 @@ int main(int argc, char **argv) {
for (a = 0; a < N; a++) printf("%50s\t\t%f\n", bestw[a], bestd[a]); for (a = 0; a < N; a++) printf("%50s\t\t%f\n", bestw[a], bestd[a]);
} }
return 0; return 0;
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment