Skip to content

Commit 9ca8d30

Browse files
author
peterrr
committed
param for number ofpages for a category
1 parent 42537a9 commit 9ca8d30

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/create_categorie_graph.R

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
create_category_graph <- function(ctgry) {
2-
pages <- get_pages(ctgry)
1+
create_category_graph <- function(ctgry, n) {
2+
pages <- get_pages(ctgry, n)
33

44
cats_page_list <- list()
55

@@ -14,18 +14,16 @@ create_category_graph <- function(ctgry) {
1414
next
1515
}
1616

17-
#print(length(cats))
1817
edge_combs <- combn(unlist(cats), 2)
1918
edge_df <- data.frame(matrix(t(edge_combs), ncol=2))
2019
graph_df <- merge(graph_df, edge_df, all=T)
2120
}
2221

23-
return(graph_df)
24-
#return(cats_page_list)
22+
return(graph.data.frame(graph_df, directed=F))
2523
}
2624

27-
get_pages <- function(ctgry) {
28-
cat_url <- paste("http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmlimit=100&cmtype=page&format=json&cmtitle=Category:", ctgry, sep="")
25+
get_pages <- function(ctgry, n) {
26+
cat_url <- paste("http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmlimit=", n,"&cmtype=page&format=json&cmtitle=Category:", ctgry, sep="")
2927
pages <- fromJSON(cat_url)$query$categorymembers
3028

3129
page_list <- list()

0 commit comments

Comments
 (0)