-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_papers.py
37 lines (30 loc) · 1.34 KB
/
get_papers.py
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
import argparse
from ntarcpy import database as db
description = """
Gets list of papers that have fulfill a given logical condition.
"""
parser = argparse.ArgumentParser(description=description)
parser.add_argument('database', type=str, help="Path to the database directory.")
parser.add_argument('condition', type=str, help="The condition to evaluate. Needs escaping. "
"Example: \"paper.preprocessing.normalization_type == 'zscore' and "
"paper.analysis_method.supervised_learning\"")
parser.add_argument('-F', '--sep', type=str, default=';',
help="Separator to use in the output.")
parser.add_argument('--papers', action='store_true',
help="With this option, get the papers that use each value.")
parser.add_argument('--bibtex', action='store_true',
help="Get the papers in BibTeX format.")
if __name__ == '__main__':
args = parser.parse_args()
condition = args.condition
papers = []
for paper in db.iterate_directory(args.database):
if eval(condition):
papers.append(paper)
if args.bibtex:
for p in papers:
print(p.get_bibtex())
elif args.papers:
print(args.sep.join([str(p) for p in papers]))
else:
print(len(papers))