11import json
22import re
3+ import os
34from datetime import datetime
45from typing import Optional , List , Dict , Any
6+ from contextlib import redirect_stdout , redirect_stderr
57
68from acl_anthology import Anthology
79
@@ -12,8 +14,10 @@ class AnthologySingleton:
1214 @classmethod
1315 def get (cls ) -> Anthology :
1416 if cls .instance is None :
15- cls .instance = Anthology .from_repo ()
16- cls .instance .load_all ()
17+ with open (os .devnull , "w" ) as devnull :
18+ with redirect_stdout (devnull ), redirect_stderr (devnull ):
19+ cls .instance = Anthology .from_repo ()
20+ cls .instance .load_all ()
1721 return cls .instance
1822
1923
@@ -93,13 +97,13 @@ def _parse_query(query: str, paper: Any) -> bool:
9397
9498def anthology_search (
9599 query : str ,
96- offset : Optional [int ] = 0 ,
97- limit : Optional [int ] = 5 ,
100+ offset : int = 0 ,
101+ limit : int = 5 ,
102+ sort_by : str = "relevance" ,
103+ sort_order : str = "descending" ,
104+ include_abstracts : bool = False ,
98105 start_date : Optional [str ] = None ,
99106 end_date : Optional [str ] = None ,
100- sort_by : Optional [str ] = "relevance" ,
101- sort_order : Optional [str ] = "descending" ,
102- include_abstracts : Optional [bool ] = False ,
103107) -> str :
104108 """
105109 Search ACL Anthology papers with field-specific queries.
@@ -136,11 +140,11 @@ def anthology_search(
136140 query: The search query, required.
137141 offset: The offset in search results. If it is 10, the first 10 items will be skipped. 0 by default.
138142 limit: The maximum number of items that will be returned. limit=5 by default, limit=10 is the maximum.
139- start_date: Start date in %Y-%m-%d format. None by default.
140- end_date: End date in %Y-%m-%d format. None by default.
141143 sort_by: 3 options to sort by: relevance, lastUpdatedDate, submittedDate. relevance by default.
142144 sort_order: 2 sort orders: ascending, descending. descending by default.
143145 include_abstracts: include abstracts in the result or not. False by default.
146+ start_date: Start date in %Y-%m-%d format. None by default.
147+ end_date: End date in %Y-%m-%d format. None by default.
144148 """
145149 assert isinstance (query , str ), "Error: Your search query must be a string"
146150 assert isinstance (offset , int ), "Error: offset should be an integer"
0 commit comments