【发布时间】:2016-06-02 15:16:17
【问题描述】:
我有 100 多个 json 格式的文档(推文)。我必须从这些文档中提取主题标签。我正在通过 mongodb-java 驱动程序读取这个文件。
entities=Document{
{
urls=[
],
hashtags=[
Document{
{
indices=[
89,
104
],
text=Hungry4Science
}
},
Document{
{
indices=[
105,
112
],
text=ASCO16
}
}
]}}
我必须从这个结构中获取文本,然后我将插入到我的 mongo 集合中。每条推文都有标签实体,但我无法读取较低级别的对象。
Document hash = (Document)old_status.get("entities");
new_status.append("hastags", hash.get("hashtags"));
我没有获取文本,而是将整个文档作为输出:
hashtags=[
Document{
{
indices=[
73,
80
],
text=cancer
}
},
Document{
{
indices=[
81,
90
],
text=moonshot
}
},
Document{
{
indices=[
125,
133
],
text=pallonc
}
}
]
我试过这样,但没有运气。 请帮忙。
【问题讨论】:
-
我得到了这个问题的答案!!!可能这个答案可以帮助任何人。
标签: json twitter4j mongodb-java