MongoDB 및 텍스트 프로세스에서 새로 추가되었습니다. 구문 분석 된 트윗이있는 데이터베이스가 있습니다. 예 :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" : ""
}
트윗에 단어를 토큰 화했습니다. 다음 단계는 불용어를 삭제하는 것입니다.
내 코드 :
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
, 당신이 나를 도와 드릴까요? 당신은 $in
운영자하지 $eq
를 사용해야합니다
{
"_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 –