9

ウィキペディアにクエリを実行して (おそらく Mediawiki API を使用して)、そのようなクエリに関連する利用可能な記事のリストを取得したり、選択した記事をテキスト マイニング用にインポートしたりできる R 用のパッケージはありますか?

4

3 に答える 3

11

WikipediR「R の MediaWiki API ラッパー」があります。

library(devtools)
install_github("Ironholds/WikipediR")
library(WikipediR)

次の機能が含まれます。

ls("package:WikipediR")
 [1] "wiki_catpages"      "wiki_con"           "wiki_diff"          "wiki_page"         
 [5] "wiki_pagecats"      "wiki_recentchanges" "wiki_revision"      "wiki_timestamp"    
 [9] "wiki_usercontribs"  "wiki_userinfo"  

これが使用されており、多数のユーザーの投稿の詳細とユーザーの詳細を取得しています。

library(RCurl)
library(XML)

# scrape page to get usernames of users with highest numbers of edits
top_editors_page <- "http://en.wikipedia.org/wiki/Wikipedia:List_of_Wikipedians_by_number_of_edits"
top_editors_table <- readHTMLTable(top_editors_page)
very_top_editors <- as.character(top_editors_table[[3]][1:5,]$User)

# setup connection to wikimedia project 
con <- wiki_con("en", project = c("wikipedia"))

# connect to API and get last 50 edits per user
user_data <- lapply(very_top_editors,  function(i) wiki_usercontribs(con, i) )
# and get information about the users (registration date, gender, editcount, etc)
user_info <- lapply(very_top_editors,  function(i) wiki_userinfo(con, i) )
于 2014-06-04T02:04:45.813 に答える
7

RCurlパッケージを使用して情報を取得し、XMLまたはRJSONIOパッケージを使用して応答を解析します。

プロキシの背後にいる場合は、オプションを設定します。

opts <- list(
  proxy = "136.233.91.120", 
  proxyusername = "mydomain\\myusername", 
  proxypassword = 'whatever', 
  proxyport = 8080
)

関数を使用して APIgetFormにアクセスします。

search_example <- getForm(
  "http://en.wikipedia.org/w/api.php", 
  action  = "opensearch", 
  search  = "Te", 
  format  = "json",
  .opts   = opts
)

結果を解析します。

fromJSON(rawToChar(search_example))
于 2011-05-23T13:39:24.803 に答える
0

新しい大きな可能性はwikifactsパッケージです(CRAN上):

library(wikifacts)
wiki_define('R (programming language)')
## R (programming language) 
## "R is a programming language and free software environment for statistical computing and graphics supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and data miners for developing statistical software and data analysis. Polls, data mining surveys, and studies of scholarly literature databases show substantial increases in popularity; as of April 2021, R ranks 16th in the TIOBE index, a measure of popularity of programming languages.The official R software environment is a GNU package.\nIt is written primarily in C, Fortran, and R itself (thus, it is partially self-hosting) and is freely available under the GNU General Public License. Pre-compiled executables are provided for various operating systems."
于 2021-05-30T18:36:45.943 に答える