Implement skip-gram training pair generation for Word2Vec.
In the skip-gram model, given a center word, we predict the context words within a window. Generate all (center_word, context_word) training pairs.
Input format:
For each word at position i, context words are at positions max(0, i-W) to min(n-1, i+W), excluding position i itself.
Output: A list of tuples (center_word, context_word) in order of center word position, and for each center word, context words from left to right.
I love NLP deeply 2
[('I', 'love'), ('I', 'NLP'), ('love', 'I'), ('love', 'NLP'), ('love', 'deeply'), ('NLP', 'I'), ('NLP', 'love'), ('NLP', 'deeply'), ('deeply', 'love'), ('deeply', 'NLP')]Words: ["I", "love", "NLP", "deeply"], window=2
Center "I" (pos 0): context positions max(0,0-2)=0 to min(3,0+2)=2, excluding 0 => 1,2 Pairs: (I, love), (I, NLP)
Center "love" (pos 1): context 0 to 3, excluding 1 => 0,2,3 Pairs: (love, I), (love, NLP), (love, deeply)
Center "NLP" (pos 2): context 0 to 3, excluding 2 => 0,1,3 Pairs: (NLP, I), (NLP, love), (NLP, deeply)
Center "deeply" (pos 3): context 1 to 3, excluding 3 => 1,2 Pairs: (deeply, love), (deeply, NLP)