0
在MongoDB和文本過程中新的Im。 我有一個數據庫與解析推文。 示例:MongoDB/PyMongo如何從數組中刪除一個具體項目
{
"_id" : ObjectId("59b24aa1a0c99b0b85732406"),
"idt" : "906060929829183489",
"tweet" : [
"RT",
"@moocowpong1",
":",
"@whitequark",
"isn't",
"the",
"cloud",
"just",
"your",
"data",
"relocating",
"to",
"san",
"francisco"
],
"createdDate" : ISODate("2017-09-08T07:45:34Z"),
"userName" : "Fiora Aeterna",
"userLocation" : "San Jose, CA",
"geo" : null,
"geoCoord" : null,
"Lang" : "en",
"retweet_count" : 0,
"sentimiento" : "",
"score_tag" : ""
}
我將tweet中的詞標記爲詞。 我的下一步是刪除停用詞。
我的代碼:
for doc in tweets.find({},{'tweet': 1}).limit(1):
print (doc)
for term in (doc['tweet']):
if set(stop).intersection(term.split()):
print ("Found One")
tweets.update({ 'idt': doc['_id'] }, { '$pull': { 'tweet': { '$eq': term } } })
stop
與停用詞陣列。 我想從鳴叫的數組中刪除這個項目,但我的代碼失敗:
raise WriteError(error.get("errmsg"), error.get("code"), error) pymongo.errors.WriteError: unknown top level operator: $eq
我不知道如果我的更新是正確的,你能幫幫我嗎?
我最後objetive像(類似)的寄存器:
{
"_id" : ObjectId("59b24aa1a0c99b0b85732406"),
"idt" : "906060929829183489",
"tweet" : [
"@moocowpong1",
"@whitequark",
"cloud",
"just",
"data",
"relocating",
"san",
"francisco"
],
"createdDate" : ISODate("2017-09-08T07:45:34Z"),
"userName" : "Fiora Aeterna",
"userLocation" : "San Jose, CA",
"geo" : null,
"geoCoord" : null,
"Lang" : "en",
"retweet_count" : 0,
"sentimiento" : "",
"score_tag" : ""
}
更新錯誤:提高WriteError(error.get(「ERRMSG」),error.get(「代碼」 ),錯誤) pymongo.errors.WriteError:未知頂級運算符:$ eq –