Semantic Pointer vocab


#1

I don’t understand the ff: code:

D = 8
model = spa.SPA(seed = 4)
with model:
   model.vocab = spa.Vocabulary(D)
   Fruit = ['CHERRY', 'APPLE', 'PEAR']
   for word in Fruit:
       model.vocab.parse(word)
  
   print(CHERRY)

I get an error I doesn’t recognize CHERRY

But

CHERRY = model.vocab.parse('CHERRY')

print(CHERRY)

yields the appropriate vector

It seems that for many models - including the AssociativeMemory model on the web site, the initial code is used.

What am I missing?

Thanks


#2

In the first case CHERRY is not an assigned variable. You either need to write print(model.vocab['CHERRY']), print(model.vocab.parse('CHERRY')), or do what you did in the second case where you assign the semantic pointer to an actual variable in your namespace.