word2vec.c
// Reads a single word from a file, assuming space + tab + EOL to be word boundaries
Reads a single word from a file, assuming space + tab + EOL to be word boundaries
Reads a single word from a file assuming space + tab + EOL to be word boundaries
void ReadWord(char *word, FILE *fin) {
    int a = 0, ch;
    while (!feof(fin)) {
        ch = fgetc(fin);
        if (ch == 13) continue;
        if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
            if (a > 0) {
                if (ch == '\n') ungetc(ch, fin);
                break;
            }
            if (ch == '\n') {
                strcpy(word, (char *)"</s>");
                return;
            } else continue;
        }
        word[a] = ch;
        a++;
        if (a >= MAX_STRING - 1) a--;   
    }
    word[a] = 0;
}
void ReadWord ( char * word , FILE * fin ) { int a = 0 , ch ; while ( ! feof ( fin ) ) { ch = fgetc ( fin ) ; if ( ch == 13 ) continue ; if ( ( ch == ' ' ) || ( ch == ' \t ' ) || ( ch == ' \n ' ) ) { if ( a > 0 ) { if ( ch == ' \n ' ) ungetc ( ch , fin ) ; break ; } if ( ch == ' \n ' ) { strcpy ( word , ( char * ) " " ) ; return ; } else continue ; } word [ a ] = ch ; a ++ ; if ( a >= MAX_STRING - 1 ) a -- ; } word [ a ] = 0 ; }
Reads a single word from a file, assuming space + tab + EOL to be word boundaries
Reads a single word from a file assuming space + tab + EOL to be word boundaries
// Truncate too long words