word2vec.c
// Returns position of a word in the vocabulary; if the word is not found, returns -1
Returns position of a word in the vocabulary; if the word is not found, returns -1
Returns position of a word in the vocabulary ; if the word is not found returns - 1
int SearchVocab(char *word) {
    unsigned int hash = GetWordHash(word);
    while (1) {
        if (vocab_hash[hash] == -1) return -1;
        if (!strcmp(word, vocab[vocab_hash[hash]].word)) return vocab_hash[hash];
        hash = (hash + 1) % vocab_hash_size;
    }
    return -1;
}
int SearchVocab ( char * word ) { unsigned int hash = GetWordHash ( word ) ; while ( 1 ) { if ( vocab_hash [ hash ] == -1 ) return -1 ; if ( ! strcmp ( word , vocab [ vocab_hash [ hash ] ] . word ) ) return vocab_hash [ hash ] ; hash = ( hash + 1 ) % vocab_hash_size ; } return -1 ; }
Returns position of a word in the vocabulary; if the word is not found, returns -1
Returns position of a word in the vocabulary ; if the word is not found returns - 1