Works from different sources

To support our “saturation” approach to the construction of bibliographic networks we need to input the data from different sources

  1. hits from OpenAlex
  2. list of important works identified with a preliminary analysis
  3. descriptions from a file - containing saved works or descriptions of works missing in OpenAlex

OA2Pajek

# source("OA2Pajek.R")

works <- "https://api.openalex.org/works"
VBlist <- read.table("VladoWorks.csv")$V1
Q <- list(
  search="handball",
  filter="publication_year:2015",
  select="id,title,countries_distinct_count,cited_by_count,referenced_works_count",
#  per_page="200"
  per_page="3"
)
json <- file("save.json","w",encoding="UTF-8")


openWorks <- function(query=NULL,list=NULL,file=NULL){
  WC <<- new.env(hash=TRUE,parent=emptyenv())
  WC$works <- "https://api.openalex.org/works"
  WC$Q <- query; WC$L <- list; WC$f <- file
  WC$n <- 0; WC$l <- 0; WC$m <- 0
  if(length(query[["search"]])>0) {
    WC$k <- 0; WC$nr <- 0; WC$act <- "page"
    if(length(query[["per_page"]])==0) WC$Q$per_page <- "200"
    WC$Q$cursor <- "*"
  } else if(length(list)>0) { WC$act <- "list"
  } else if(length(file)>0) { WC$act <- "open"
  } else WC$act <- "stop"
}

nextWork <- function(){
  # repeat{
  for(t in 1:5){
    switch(WC$act,
      "page" = {
        if(WC$n==10) {WC$act <- "list"; next}
        WC$k <- WC$k + 1
        if(WC$k>WC$nr){
          WC$wd <- GET(WC$works,query=WC$Q)
          if(WC$wd$status_code!=200) {WC$act <- "list"
            cat(WC$n,"GET error\n"); flush.console(); next}
          WC$k <- 1
          WC$wc <- fromJSON(rawToChar(WC$wd$content))
          WC$Q$cursor <- WC$wc$meta$next_cursor
          if(is.null(WC$Q$cursor)) {WC$act <- "list"; next}
          WC$df <- WC$wc$results; WC$nr <- nrow(WC$df)
          cat(WC$k,wc$meta$count,WC$nr,"\n   ",WC$Q$cursor,"\n")
        }
        WC$n <- WC$n + 1
        return(WC$df[WC$k,])    
      },
      "list" = {
        WC$l <- WC$l + 1 
        if(WC$l>length(WC$L)) {WC$act <- "open"; next}
        works <- paste(WC$works,"/",WC$L[WC$l],sep="")
        WC$wd <- GET(works,query=list(select=WC$Q[["select"]]))
        if(WC$wd$status_code!=200) {cat(WC$n,"GET error\n")
          flush.console(); next}
        cat("   >>>",WC$l,WC$L[WC$l],"\n")
        wc <- fromJSON(rawToChar(WC$wd$content))
        WC$n <- WC$n + 1
        return(wc)
      },
      "open" = {
        if(is.null(WC$f)) { WC$act <- "stop"; next }
        WC$ndj <- file(WC$f,open="r")
        WC$act <- "file"; next 
      },
      "file" = {
        wc <- readLines(con=WC$ndj,n=1)
        if(length(wc)==0){ close(WC$ndj); WC$act <- "stop"; next }
        WC$m <- WC$m + 1; WC$n <- WC$n + 1
        return(fromJSON(wc))
      },
      "stop" = { return(NULL) },
      stop(paste0("No handler for ",WC$act))
    ) 
  }
  stop("Too many errors")
}

processWork <- function(w) cat("   Process:",WC$n,w$title,"\n")

closeWorks <- function() rm(WC,inherits=TRUE)

openWorks(query=Q,list=VBlist,file="manual.ndjson")
print(ls.str(WC))
cat("*** OpenAlex2Pajek - Start",date(),"\n")
repeat{
  w <- nextWork()
  if(is.null(w)) break
  write(toJSON(as.list(w)),file=json)
  processWork(w)
}
cat("*** OpenAlex2Pajek - Stop",date(),"\n")
print(ls.str(WC))
closeWorks(); close(json)
print(ls.str(WC))
> source("OA2Pajek.R")
act :  chr "page"
f :  chr "manual.ndjson"
k :  num 0
l :  num 0
L :  chr [1:7] "W2147991930" "W2008006577" "W1981385379" "W2110311637" "W2083084326" "W2023723604" ...
m :  num 0
n :  num 0
nr :  num 0
Q : List of 5
 $ search  : chr "handball"
 $ filter  : chr "publication_year:2015"
 $ select  : chr "id,title,countries_distinct_count,cited_by_count,referenced_works_count"
 $ per_page: chr "3"
 $ cursor  : chr "*"
works :  chr "https://api.openalex.org/works"
*** OpenAlex2Pajek - Start Sun Mar 17 07:54:54 2024 
1 1330 3 
    Ils2MDIuNzQ4MSwgMTQzNzA5MTIwMDAwMCwgJ2h0dHBzOi8vb3BlbmFsZXgub3JnL1cyMTMzNDE0MDY4J10i 
   Process: 1 Improving Fitness of Elite Handball Players 
   Process: 2 Incidence and risk factors of injuries in Brazilian elite handball players: A prospective cohort study 
   Process: 3 Injury and illness surveillance during the 24th Men's Handball World Championship 2015 in Qatar 
1 1330 3 
    Ils0OTEuMTIxMiwgMTQzMDQzODQwMDAwMCwgJ2h0dHBzOi8vb3BlbmFsZXgub3JnL1cyMDEyMTk2Njg3J10i 
   Process: 4 Technical Match Characteristics and Influence of Body Anthropometry on Playing Performance in Male Elite Team Handball 
   Process: 5 Structural Brain Correlates Associated with Professional Handball Playing 
   Process: 6 Test-retest reliability of seven common clinical tests for assessing lower extremity muscle flexibility in futsal and handball players 
1 1330 3 
    Ils0NDkuMDMxMDQsIDE0MjQwNDQ4MDAwMDAsICdodHRwczovL29wZW5hbGV4Lm9yZy9XMjAxMTA3NjQ4NSddIg== 
   Process: 7 Comparison of Inflammatory Responses and Muscle Damage Indices Following a Soccer, Basketball, Volleyball and Handball Game at an Elite Competitive Level 
   Process: 8 Talent development as an ecology of games: a case study of Norwegian handball 
   Process: 9 Anthropometric and physical performance characteristics of top-elite, elite and non-elite youth female team handball players 
1 1330 3 
    Ils0MTUuNjM2MiwgMTQyNzg0NjQwMDAwMCwgJ2h0dHBzOi8vb3BlbmFsZXgub3JnL1cyMDI2NzQwNzgyJ10i 
   Process: 10 Isokinetic Strength Profile of Elite Female Handball Players 
   >>> 1 W2147991930 
   Process: 11 Fast algorithms for determining (generalized) core groups in social networks 
   >>> 2 W2008006577 
   Process: 12 Efficient generation of large random networks 
   >>> 3 W1981385379 
   Process: 13 Generalized blockmodeling of two-mode network data 
   >>> 4 W2110311637 
   Process: 14 Comparing resemblance measures 
   >>> 5 W2083084326 
   Process: 15 On bibliographic networks 
   >>> 6 W2023723604 
   Process: 16 Direct and indirect methods for structural equivalence 
   >>> 7 W1967880836 
   Process: 17 Some analyses of Erdős collaboration graph 
   Process: 18 Manual 1 
   Process: 19 Manual 2 
*** OpenAlex2Pajek - Stop Sun Mar 17 07:54:56 2024 
act :  chr "stop"
df : 'data.frame':      3 obs. of  5 variables:
 $ id                      : chr  "https://openalex.org/W2413590293" "https://openalex.org/W1995065687" "https://openalex.org/W2026740782"
 $ title                   : chr  "Isokinetic Strength Profile of Elite Female Handball Players" "The role of community in the development of elite handball and football players in Denmark" "Technical Activity Profile and Influence of Body Anthropometry on Playing Performance in Female Elite Team Handball"
 $ countries_distinct_count: int  2 1 2
 $ cited_by_count          : int  27 26 41
 $ referenced_works_count  : int  20 14 9
f :  chr "manual.ndjson"
k :  num 1
l :  num 8
L :  chr [1:7] "W2147991930" "W2008006577" "W1981385379" "W2110311637" "W2083084326" "W2023723604" ...
m :  num 2
n :  num 19
ndj :  'file' int 9
nr :  int 3
Q : List of 5
 $ search  : chr "handball"
 $ filter  : chr "publication_year:2015"
 $ select  : chr "id,title,countries_distinct_count,cited_by_count,referenced_works_count"
 $ per_page: chr "3"
 $ cursor  : chr "Ils0MTUuNjM2MiwgMTQyNzg0NjQwMDAwMCwgJ2h0dHBzOi8vb3BlbmFsZXgub3JnL1cyMDI2NzQwNzgyJ10i"
wc : List of 3
 $ meta    :List of 6
 $ results :'data.frame':       3 obs. of  5 variables:
 $ group_by: list()
wd : List of 10
 $ url        : chr "https://api.openalex.org/works/W1967880836?select=id%2Ctitle%2Ccountries_distinct_count%2Ccited_by_count%2Crefe"| __truncated__
 $ status_code: int 200
 $ headers    :List of 21
 $ all_headers:List of 1
 $ cookies    :'data.frame':    0 obs. of  7 variables:
 $ content    : raw [1:178] 7b 22 69 64 ...
 $ date       : POSIXct[1:1], format: "2024-03-17 06:54:56"
 $ times      : Named num [1:6] 0.0 3.3e-05 0.0 9.5e-05 1.9e-01 ...
 $ request    :List of 7
 $ handle     :Class 'curl_handle' <externalptr> 
works :  chr "https://api.openalex.org/works"
Error in ls.str(WC) : object 'WC' not found
{"id":["https://openalex.org/W1111111111"],"title":["Manual 1"],"countries_distinct_count":[1],"cited_by_count":[74],"referenced_works_count":[29]}
{"id":["https://openalex.org/W2222222222"],"title":["Manual 2"],"countries_distinct_count":[2],"cited_by_count":[89],"referenced_works_count":[25]} 
{"id":["https://openalex.org/W1971587050"],"title":["Improving Fitness of Elite Handball Players"],"countries_distinct_count":[1],"cited_by_count":[74],"referenced_works_count":[29]}
{"id":["https://openalex.org/W2218176234"],"title":["Incidence and risk factors of injuries in Brazilian elite handball players: A prospective cohort study"],"countries_distinct_count":[2],"cited_by_count":[89],"referenced_works_count":[25]}
{"id":["https://openalex.org/W2133414068"],"title":["Injury and illness surveillance during the 24th Men's Handball World Championship 2015 in Qatar"],"countries_distinct_count":[3],"cited_by_count":[85],"referenced_works_count":[39]}
{"id":["https://openalex.org/W2014565141"],"title":["Technical Match Characteristics and Influence of Body Anthropometry on Playing Performance in Male Elite Team Handball"],"countries_distinct_count":[2],"cited_by_count":[73],"referenced_works_count":[8]}
{"id":["https://openalex.org/W2070786099"],"title":["Structural Brain Correlates Associated with Professional Handball Playing"],"countries_distinct_count":[3],"cited_by_count":[40],"referenced_works_count":[82]}
{"id":["https://openalex.org/W2012196687"],"title":["Test-retest reliability of seven common clinical tests for assessing lower extremity muscle flexibility in futsal and handball players"],"countries_distinct_count":[1],"cited_by_count":[78],"referenced_works_count":[25]}
{"id":["https://openalex.org/W1999308010"],"title":["Comparison of Inflammatory Responses and Muscle Damage Indices Following a Soccer, Basketball, Volleyball and Handball Game at an Elite Competitive Level"],"countries_distinct_count":[1],"cited_by_count":[73],"referenced_works_count":[27]}
{"id":["https://openalex.org/W2273156203"],"title":["Talent development as an ecology of games: a case study of Norwegian handball"],"countries_distinct_count":[1],"cited_by_count":[31],"referenced_works_count":[25]}
{"id":["https://openalex.org/W2011076485"],"title":["Anthropometric and physical performance characteristics of top-elite, elite and non-elite youth female team handball players"],"countries_distinct_count":[2],"cited_by_count":[52],"referenced_works_count":[22]}
{"id":["https://openalex.org/W2413590293"],"title":["Isokinetic Strength Profile of Elite Female Handball Players"],"countries_distinct_count":[2],"cited_by_count":[27],"referenced_works_count":[20]}
{"id":["https://openalex.org/W2147991930"],"title":["Fast algorithms for determining (generalized) core groups in social networks"],"countries_distinct_count":[1],"cited_by_count":[231],"referenced_works_count":[16]}
{"id":["https://openalex.org/W2008006577"],"title":["Efficient generation of large random networks"],"countries_distinct_count":[1],"cited_by_count":[229],"referenced_works_count":[8]}
{"id":["https://openalex.org/W1981385379"],"title":["Generalized blockmodeling of two-mode network data"],"countries_distinct_count":[2],"cited_by_count":[184],"referenced_works_count":[21]}
{"id":["https://openalex.org/W2110311637"],"title":["Comparing resemblance measures"],"countries_distinct_count":[1],"cited_by_count":[163],"referenced_works_count":[8]}
{"id":["https://openalex.org/W2083084326"],"title":["On bibliographic networks"],"countries_distinct_count":[1],"cited_by_count":[124],"referenced_works_count":[10]}
{"id":["https://openalex.org/W2023723604"],"title":["Direct and indirect methods for structural equivalence"],"countries_distinct_count":[2],"cited_by_count":[112],"referenced_works_count":[17]}
{"id":["https://openalex.org/W1967880836"],"title":["Some analyses of Erdős collaboration graph"],"countries_distinct_count":[1],"cited_by_count":[127],"referenced_works_count":[3]}
{"id":["https://openalex.org/W1111111111"],"title":["Manual 1"],"countries_distinct_count":[1],"cited_by_count":[74],"referenced_works_count":[29]}
{"id":["https://openalex.org/W2222222222"],"title":["Manual 2"],"countries_distinct_count":[2],"cited_by_count":[89],"referenced_works_count":[25]}
vlado/work/bib/alex/srcs.txt · Last modified: 2024/03/17 08:03 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki