You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在openalexR包的oa_fetch函数中添加Topics筛选检索目标文献?

解决方案:通过OpenAlex Topics筛选非标准工作安排文献

一、使用openalexR包实现Topics筛选

openalexR的oa_fetch函数支持直接通过主题筛选,无需额外API请求,以下是两种实现方式:

1. 按主题名称模糊匹配

结合主题检索、社会科学领域限定与原有的标题关键词,覆盖表述模糊的文献:

library(openalexR)

results <- oa_fetch(
  entity = "works",
  # 修正原代码拼写错误,保留多语言标题关键词
  title.search = c("nonstandard schedules", "nonday work", 
                   "night work", "weekend work", 
                   "saturday work", "sunday work", 
                   "atypical hours", "heures atypiques", 
                   "shift work", 
                   "travail le weekend", 
                   "travail le samedi", "travail le dimanche", 
                   "unsocial hours", "horaires atypiques", 
                   "evening work", "morning work", 
                   "non-standard work schedules"),
  # 指定社会学、政治学及相关主题
  topic.search = c("sociology", "political science", "非标准工作安排"),
  # 限定社会科学领域,排除非研究性文本
  filter = list(
    fields_of_study = "Social Sciences",
    is_paratext = FALSE
  ),
  count_only = FALSE
)

2. 按主题ID精确筛选

若需更精准匹配,可使用OpenAlex官方主题ID(如社会学T432、政治学T127)直接筛选:

results <- oa_fetch(
  entity = "works",
  title.search = c("nonstandard schedules", ...), # 保留原标题关键词列表
  filter = list(
    topics.id = c("T432", "T127"), # 社会学、政治学的主题ID
    fields_of_study = "Social Sciences"
  ),
  count_only = FALSE
)

二、直接调用OpenAlex API的备选方案

如果openalexR参数无法满足需求,可通过httr包直接发送API请求:

library(httr)
library(jsonlite)

base_url <- "https://api.openalex.org/works"
query_params <- list(
  title.search = paste(c("nonstandard schedules", ...), collapse = "|"), # 标题关键词用|分隔
  topics.search = "sociology|political science",
  filter = "fields_of_study:Social Sciences",
  per_page = 200 # 单次请求最大返回量
)

response <- GET(base_url, query = query_params)
data <- fromJSON(content(response, "text"))

注意事项

  • 修正了原代码中non-standatd的拼写错误
  • openalexR会自动处理分页,直接调用API需手动管理cursor参数获取全量结果
  • 可通过filter参数添加更多限定条件(如发表年份、文献类型等)

内容的提问来源于stack exchange,提问作者cielo_azzurro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 15:05:02