Python: How to update value of key value pair in nested dictionary?

后端 未结 9 1055
广开言路
广开言路 2021-01-21 20:25

i am trying to make an inversed document index, therefore i need to know from all unique words in a collection in which doc they occur and how often.

i have used this an

9条回答
  •  没有蜡笔的小新
    2021-01-21 21:14

    Not sure why you need nested dicts here. In a typical index scenario you have a forward index mapping

    document id -> [word_ids]

    and an inverse index mapping

    word_id -> [document_ids]

    Not sure if this is related here but using two indexes you can perform all kind of queries very efficiently and the implementation is straight forward since you don't need to deal with nested data structures.

提交回复
热议问题