Skip to content

Commit ab7a7ae

Browse files
committed
pre-release, article ranking and download set up
1 parent 991661f commit ab7a7ae

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ cython_debug/
153153

154154
# Cheshire Cat Plugin settings
155155
data/
156-
156+
literature/
157+
hissmed/

hissmed_literature_assistant.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ def hisscat_download_literature(user_message, cat):
1616
log.info(f"Action input: {action_input}") # Log the action input
1717
settings = cat.mad_hatter.get_plugin().load_settings()
1818
log.info(f"User email: {settings['email']}") # Log the user email
19-
PapersDownloader.set_email(email=settings['email'])
19+
email = settings['email']
20+
top_n_articles = settings['top_n_articles']
21+
top_references = settings['top_references']
22+
citation_weight = settings['citation_weight']
23+
year_weight = settings['year_weight']
24+
journal_weight = settings['journal_weight']
25+
PapersDownloader.set_email(email=email)
2026
log.info(f"Saving articles in {os.path.join(os.getcwd(),'literature')}") # Log the output folder
21-
PapersDownloader.run(user_message) # Download the articles
27+
PapersDownloader.create_directory()
28+
PapersDownloader.batch_download_pdfs(query=query, top_n_articles=top_n_articles, citation_w=citation_weight, year_w=year_weight, journal_w=journal_weight)
2229
log.info(f"Downloaded articles") # Log the download status
2330
return user_message
2431

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HissMed Literature Assistant",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "HissMed literature assistant, fetch your queries on PubMed central and gives you answers and references.",
55
"author_name": "Jacopo Umberto Verga",
66
"plugin_url": "https://github.com/VergaJU/HissMed",

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
biopython>=1.85
1+
biopython>=1.85
2+
pandas
3+
numpy
4+
xml

settings.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
class MySettings(BaseModel):
55
email: str = "your.email@mail.com"
66
top_references: int = 5
7+
top_n_articles: int=10
8+
citation_weight: float=0.7
9+
year_weight: float=0.5
10+
journal_weight: float=0.9
711

812
@field_validator("email")
913
@classmethod
@@ -12,6 +16,43 @@ def email_validator(cls, email):
1216
raise ValueError("Invalid email address")
1317
elif "your.email@mail.com" == email:
1418
raise ValueError("Please set your email address")
19+
20+
@field_validator("top_references")
21+
@classmethod
22+
def top_references_validator(cls, top_references):
23+
assert isinstance(top_references, int), f"Top references is {type(top_references)}, it must be an integer"
24+
if top_references < 0:
25+
raise ValueError("Invalid top references")
26+
27+
28+
@field_validator("top_n_articles")
29+
@classmethod
30+
def top_n_articles_validator(cls, top_n_articles):
31+
assert isinstance(top_n_articles, int), f"Top n articles is {type(top_n_articles)}, it must be an integer"
32+
if top_n_articles < 0:
33+
raise ValueError("Invalid top n articles")
34+
35+
@field_validator("citation_weight")
36+
@classmethod
37+
def citation_weight_validator(cls, citation_weight):
38+
assert isinstance(citation_weight, float), f"Citation weight is {type(citation_weight)}, it must be a float"
39+
if citation_weight < 0 or citation_weight > 1:
40+
raise ValueError("Invalid citation weight")
41+
42+
@field_validator("year_weight")
43+
@classmethod
44+
def year_weight_validator(cls, year_weight):
45+
assert isinstance(year_weight, float), f"Year weight is {type(year_weight)}, it must be a float"
46+
if year_weight < 0 or year_weight > 1:
47+
raise ValueError("Invalid year weight")
48+
49+
@field_validator("journal_weight")
50+
@classmethod
51+
def journal_weight_validator(cls, journal_weight):
52+
assert isinstance(journal_weight, float), f"Journal weight is {type(journal_weight)}, it must be a float"
53+
if journal_weight < 0 or journal_weight > 1:
54+
raise ValueError("Invalid journal weight")
55+
1556

1657
@plugin
1758
def settings_model():

0 commit comments

Comments
 (0)