如何使用R中的streamR包跟踪带有特殊字符的单词? [英] How to track words with special characters using streamR package in R?
问题描述
我正在使用 streamR 包来流式传输一些推文,但它不适用于一些葡萄牙语单词,例如policia"、médico"、audiência"和politica"等.如果我改用policia",它只会显示包含西班牙语policia"的推文,葡萄牙语不显示policia".
I am using streamR package to stream some tweets but It's not working with some portuguese words like "polícia", "médico", "audiência" and "política", etc. If I use "policia" instead, It only shows tweets containing "policia", in spanish, It doesn't show "polícia" in portuguese.
我使用的是 R 3.1、Windows 7、streamR 0.2.1.这是一段代码:
I'm under R 3.1, Windows 7, streamR 0.2.1. Here is the piece of code:
> filterStream(file="acento.json", track="polícia", timeout=60, oauth=twitCred)
Capturing tweets...
Connection to Twitter stream was closed after 61 seconds with up to 4 tweets downloaded.
> df <- parseTweets("acento.json")
Error in readLines(tweets, encoding = "UTF-8") :
5 arguments passed to .Internal(readLines) which requires 6
这条显示找到 4 条推文的消息看起来像是一条默认消息,因为生成的 json 文件永远不会超过 1kb.
This message showing that 4 tweets were found looks like a default message, because the json file generated never exceeds 1kb.
> filterStream(file="acento1.json", track="política", timeout=60, oauth=twitCred)
Capturing tweets...
Connection to Twitter stream was closed after 62 seconds with up to 4 tweets downloaded.
> df <- parseTweets("acento1.json")
Error in readLines(tweets, encoding = "UTF-8") :
5 arguments passed to .Internal(readLines) which requires 6
有人能告诉我如何处理这个问题吗?
Could someone please give me a hint of how to deal with this?
推荐答案
为 policia 试试这个:
filterStream(file="acento.json", track="pol\u00edcia", timeout=30, oauth= twitCred)
这篇关于如何使用R中的streamR包跟踪带有特殊字符的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!