-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_lookup.sh
More file actions
executable file
·35 lines (29 loc) · 943 Bytes
/
if_lookup.sh
File metadata and controls
executable file
·35 lines (29 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# 影响因子查询
# 用法: bash scripts/if_lookup.sh "journal_name"
# 示例: bash scripts/if_lookup.sh "Nature Medicine"
# 返回: 影响因子和分区信息(JSON 格式)
set -e
# 初始化
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_ROOT="$(dirname "$SCRIPT_DIR")"
DATA_DIR="$SKILL_ROOT/data"
# 参数
NAME="${1:-}"
if [[ -z "$NAME" ]]; then
echo '{"error": "Usage: bash scripts/if_lookup.sh \"journal_name\""}' >&2
exit 1
fi
# 检查数据库
DB_FILE="$DATA_DIR/impact_factor.sqlite3"
if [[ ! -f "$DB_FILE" ]]; then
echo "{\"error\": \"Impact factor database not found. Download from: https://github.com/suqingdong/impact_factor\"}" >&2
exit 1
fi
# 查询(使用 LIKE 匹配)
sqlite3 "$DB_FILE" -json \
"SELECT journal, factor, jcr, zky
FROM factor
WHERE journal LIKE '%${NAME}%'
ORDER BY factor DESC
LIMIT 5;" 2>/dev/null | jq '.[]?' || echo '[]'