Here I am building on this question, adding the possibility that a term has been inserted within the window of another term of the same type. Here, I have inserted an A as the third character, from the original example.

txt <- "A D A C E A D F E B A C E D"

producing a window size 2 (+/- 2 terms) context co-occurrence matrix:

        features
contexts A B C D E F
       A 2 1 3 3 4 1
       B 1 0 1 0 1 1
       C 3 1 0 2 2 0
       D 3 0 2 0 3 1
       E 4 1 2 3 0 1
       F 1 1 0 1 1 0

Question: Is this the correct way to compute the co-occurrence of A with itself? And should the first A be considered within the window of itself twice, once counting the second A (index position 3, counting from 1) in the context window of the first A (position 1), and once counting the first A in the context window of the second A?

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.