Repository navigation
Expand file tree
/
Copy pathexample_custom_rules.py
More file actions
135 lines (113 loc) · 3.71 KB
/
Copy pathexample_custom_rules.py
File metadata and controls
135 lines (113 loc) · 3.71 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python3
"""
Example Custom Rules for arXiv Bot
Modify this file to create your own filtering rules.
"""
from typing import Dict, Any, List
def custom_paper_filter(paper: Dict[str, Any], config: Dict[str, Any]) -> bool:
"""
Custom function to filter papers.
Return True to include the paper, False to exclude it.
Args:
paper: Dictionary containing paper information
config: Configuration dictionary
Returns:
bool: True if paper should be included, False otherwise
"""
# Example 1: Only include papers with specific authors
target_authors = ["Geoffrey Hinton", "Yann LeCun", "Yoshua Bengio"]
paper_authors = " ".join(paper.get("authors", [])).lower()
for author in target_authors:
if author.lower() in paper_authors:
return True
# Example 2: Exclude papers with certain words in title
title = paper.get("title", "").lower()
exclude_words = ["preliminary", "draft", "work in progress", "extended abstract"]
for word in exclude_words:
if word in title:
return False
# Example 3: Only include papers with sufficient abstract length
abstract = paper.get("summary", "")
if len(abstract) < 200:
return False
# Example 4: Check for required keywords
required_keywords = config.get("required_keywords", [])
if required_keywords:
text_to_check = f"{paper.get('title', '')} {paper.get('summary', '')}".lower()
found_required = False
for keyword in required_keywords:
if keyword.lower() in text_to_check:
found_required = True
break
if not found_required:
return False
return True
def custom_paper_score(paper: Dict[str, Any], config: Dict[str, Any]) -> float:
"""
Custom function to score papers.
Return a float score (higher = more relevant).
Args:
paper: Dictionary containing paper information
config: Configuration dictionary
Returns:
float: Relevance score
"""
score = 0.0
title = paper.get("title", "").lower()
abstract = paper.get("summary", "").lower()
# Score based on keyword matches
keywords = config.get("keywords", [])
for keyword in keywords:
if keyword.lower() in title:
score += 2.0 # Title matches worth more
if keyword.lower() in abstract:
score += 1.0
# Score based on author reputation
authors = paper.get("authors", [])
famous_authors = [
"geoffrey hinton",
"yann lecun",
"yoshua bengio",
"andrew ng",
"fei-fei li",
"ilya sutskever",
"david silver",
"richard sutton",
"peter norvig",
]
for author in authors:
if author.lower() in famous_authors:
score += 1.0
# Score based on abstract quality indicators
quality_indicators = [
"novel",
"improved",
"state-of-the-art",
"benchmark",
"significant",
"outperform",
"advance",
"breakthrough",
]
for indicator in quality_indicators:
if indicator in abstract:
score += 0.5
# Score based on abstract length (longer abstracts often more detailed)
abstract_length = len(abstract)
if abstract_length > 500:
score += 0.5
elif abstract_length < 100:
score -= 1.0
return score
# Example usage in your config.json:
"""
{
"categories": ["cs.AI", "cs.LG", "cs.CL"],
"keywords": ["machine learning", "deep learning", "transformer"],
"exclude_keywords": ["survey", "review", "tutorial"],
"required_keywords": ["neural", "network"],
"max_papers": 30,
"days_back": 7,
"min_score": 1.0
}
"""