I build
Corpus = collections.namedtuple('Corpus', 'a, b, c, d')
Read all the files in the corpus and save the data,
def compute(counters, tokens, catergory)
...
counters.stats[tokens][catergory] = Corpus(a, b, c, d)
Both tokens and catergory are collection.Counter(). After reading all the information in a, b, c, d in counters.stats, I do some calculation in another function and get ‘e’ for each token. How can I add e into counters.stats in this function?
If you are talking about adding ‘e’ to the Corpus namedtuple of
counter.stats[tokens][category]then that is not possible as namedtuples are immutable. You may have to create a new namedtuple with thea b c d evalues and assign it to counter.stats[tokens][category]. The code below is an example: