ツイートからテキストを抽出し、duplicated
実際の重複を削除するために使用します。
tweets = searchTwitter('aeCERT: aeCERT' , n=100, cainfo = "cacert.pem")
texts <- sapply( unlist( tweets ) , function(x) `$`( x , "text" ) )
length(texts)
#[1] 100
texts[87:91]
#[1] "You should always update your Operating System to reduce and eliminate vulnerabilities http://t.co/l0sdv0k304"
#[2] "We are today at Dubai Electricity and Water Authority (DEWA) in Dubai conducting information security awareness workshop by Eng. Khalifa..."
#[3] "We are today at Dubai Electricity and Water Authority (DEWA) in Dubai conducting information security awareness workshop by Eng. Khalifa..."
#[4] "صباح الخير لجميع المغردين ..متواجدين اليوم في هيئة كهرباء ومياه دبي لعقد ورش التوعية الأمنية الالكترونية يقدمها المهندس خليفة الشامسي"
#[5] "صباح الخير لجميع المغردين ..متواجدين اليوم في هيئة كهرباء ومياه دبي لعقد ورش التوعية الأمنية الالكترونية يقدمها المهندس خليفة الشامسي"
unq.texts <- texts[ ! duplicated( texts ) ]
length(unq.texts)
#[1] 82
unq.texts[71:74]
#[1] "You should always update your Operating System to reduce and eliminate vulnerabilities http://t.co/l0sdv0k304"
#[2] "We are today at Dubai Electricity and Water Authority (DEWA) in Dubai conducting information security awareness workshop by Eng. Khalifa..."
#[3] "صباح الخير لجميع المغردين ..متواجدين اليوم في هيئة كهرباء ومياه دبي لعقد ورش التوعية الأمنية الالكترونية يقدمها المهندس خليفة الشامسي"
#[4] "RT @Salim_aeCERT: لا تستجب للمكالمات الهاتفية التي تخبرك بأنك ربحت جوائز قيمة ومبالغ مالية، فقد تكون ضحية للاحتيال #aecert http://t.co/HTK5…"
ツイートのテキストが 1 文字変更されただけでも、ツイートが重複として検出されないことに注意してください (たとえば、誰かがリツイートし、別のリンク短縮機能を介してリンクを追加した場合に関連します)。
次のようなこともできます
sapply( unlist( tweets ) , function(x) length(`$`( x , "replyToUID" ) ) > 0 )
他の誰かのツイートへの返信であるすべてのツイートの論理ベクトルを取得するには、または
sapply( unlist( tweets ) , function(x) length(`$`( x , "retweeted" ) ) > 0 )
リツイートであるツイートの論理ベクトルを取得します (ただし、私のサンプルではツイートがリツイートされていないため、これが信頼できるかどうかはわかりません)。他の適用可能な名前とメソッドは、(たとえば) を使用して見つけることができます。
str(tweets[[1]])
Reference class 'status' [package "twitteR"] with 14 fields
$ text : chr "<U+062A><U+0639><U+0644><U+0645> <U+0627><U+0644><U+0645><U+0632><U+064A><U+062F> <U+0639><U+0646> <U+062A><U+062D><U+062F><U+"| __truncated__
$ favorited : logi FALSE
$ replyToSN : chr(0)
$ created : POSIXct[1:1], format: "2013-06-04 08:02:24"
$ truncated : logi FALSE
$ replyToSID : chr(0)
$ id : chr "341827259352641536"
$ replyToUID : chr(0)
$ statusSource: chr "<a href=\"http://www.hootsuite.com\" rel=\"nofollow\">HootSuite</a>"
$ screenName : chr "Salim_aeCERT"
$ retweetCount: num 1
$ retweeted : logi FALSE
$ longitude : chr(0)
$ latitude : chr(0)