c++ - efficient way to query similar sentences -
i have task need find similar sentences memory. task read input file containing:
a b c c d e f f h g w .............
and then, given new query, ex
h g w
the return should be
f h g w
which line in input file containing query words.
i know how efficiently store input sentence can used query efficiently.
you can store dictionary of words vector of strings:
vector<string> dict;
so in example, put "a"
, "b"
, "c"
, on inside dictionary.
then can represent sentence vector of integers, integer index of word in dictionary:
vector<int> sentence;
for example first sentence {0, 1, 2}
.
you can store sentences in vector:
vector<vector<int>> sentences;
at point, checking if subphrase inside phrase same substring search algorithm (provided convert phrase query vector of integers).
Comments
Post a Comment