a data structure with key as a cluster of words and value as a single word or string

老子叫甜甜 提交于 2019-12-31 07:49:10

问题


I want to create a data structure that is able to map a cluster or group of words to a single word or string , it can be thought as of a reverse of what a dictionary does in python .


回答1:


You can use a regular dict:

targetword = "good"
wordmap = {
    "best": targetword,
    "positive": targetword,
    "awesome": targetword,
    "fantastic": targetword
}


来源:https://stackoverflow.com/questions/37158160/a-data-structure-with-key-as-a-cluster-of-words-and-value-as-a-single-word-or-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!