Skip to content

Commit 59a96b9

Browse files
author
Gerit Wagner
committed
refine docs and code comments/format
1 parent e47b8cb commit 59a96b9

File tree

7 files changed

+27
-14
lines changed

7 files changed

+27
-14
lines changed

docs/source/automate.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Using the Crossref API as an example, the following illustrates how to construct
4747
4848
if __name__ == "__main__":
4949
50-
query = OrQuery(["microsourcing", "lululemon"], field="title")
50+
query = OrQuery(["microsourcing", "online labor markets"], field="title")
5151
5252
url = to_crossref_url(query)
5353
api_crossref = crossref_api.CrossrefAPI(url=url)
@@ -56,15 +56,14 @@ Using the Crossref API as an example, the following illustrates how to construct
5656
sf = SearchFile(
5757
search_string=query.to_string(),
5858
platform="crossref",
59-
authors=[{"name": "Tom Brady"}],
59+
authors=[{"name": "Gerit Wagner"}],
6060
record_info={"source": "manual", "url": url},
6161
date={"data_entry": datetime.datetime.now().strftime("%Y-%m-%d %H:%M")},
6262
field="title",
63-
description="Search for work authored by Tom Brady",
64-
tags=["microsourcing", "lululemon", "research"]
63+
description="Search for research on microsourcing"
6564
)
6665
67-
sf.save("test/tom_brady_search.json")
66+
sf.save("test/microsourcing_search.json")
6867
6968
records_dict = {record.get_value("doi"): record.get_data() for record in records}
7069
write_file(records_dict=records_dict, filename=Path("test/crossref_records.bib"))

docs/source/dev_docs/_autosummary/search_query.parser_base.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ search\_query.parser\_base
99
.. autosummary::
1010

1111
QueryListParser
12+
QueryParserBase
1213
QueryStringParser

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Creating a query programmatically is simple:
4747
work_synonyms = OrQuery(["work", "labor", "service"], field="abstract")
4848
query = AndQuery([digital_synonyms, work_synonyms])
4949
50-
A query can also be parsed from a string or a `JSON search file <#json-search-files>`_ (see the :doc:`overview of platform identifiers </platforms/platform_index>`):
50+
A query can also be parsed from a string or a `JSON search file <load.html#file>`_ (see the :doc:`overview of platform identifiers </platforms/platform_index>`):
5151

5252
.. code-block:: python
5353

docs/source/load.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@ Load
55

66
Queries can be loaded from strings/files, defined as objects, or retrieved from the internal database.
77

8-
String/file
8+
String
99
-------------------------
1010

11-
Search-query can parse queries from strings and JSON query files.
12-
To load a JSON query file, run the parser:
11+
Search-query can parse queries from strings.
12+
To load a query from a string, run:
13+
14+
.. code-block:: python
15+
16+
from search_query.parser import parse
17+
18+
query_string = '("digital health"[Title/Abstract]) AND ("privacy"[Title/Abstract])'
19+
query = parse(query_string, platform="pubmed")
20+
21+
22+
File
23+
-------------------------
24+
25+
Search-query can parse queries from JSON query files.
26+
To load a JSON query file, run:
1327

1428
.. code-block:: python
1529

search_query/linter_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,8 @@ def _highlight_removed_chars(self, original: str, modified: str) -> str:
12411241
# skip added characters ('+')
12421242
return result
12431243

1244-
# TODO : 10.1079_SEARCHRXIV.2023.00129.json , 10.1079_SEARCHRXIV.2023.00269.json ,
1244+
# Examples:
1245+
# 10.1079_SEARCHRXIV.2023.00129.json , 10.1079_SEARCHRXIV.2023.00269.json ,
12451246
# 10.1079_SEARCHRXIV.2024.00457.json- position mismtach
12461247
def _check_unnecessary_nesting(self, query: Query) -> None:
12471248
"""Check for unnecessary same-operator nesting and provide simplification advice."""
@@ -1454,7 +1455,6 @@ def _check_for_wildcard_usage(self, term_field_query: Query) -> None:
14541455
return
14551456

14561457
if term_field_query.value == "OR" and term_field_query.operator:
1457-
# TODO : consider search-fields!
14581458
term_objects = [
14591459
child for child in term_field_query.children if child.is_term()
14601460
]

search_query/wos/linter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ def check_deprecated_field_tags(self, query: Query) -> None:
444444
if not query.field:
445445
return
446446

447-
# TODO: clarify advice... + context (called via CI / with filename?)
448-
449447
# use of the following field tags in the search interface prints
450448
# Search Error: Invalid field tag.
451449
if query.field.value in [

search_query/wos/translator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from __future__ import annotations
44

55
import re
6-
from search_query.constants import PLATFORM
6+
77
from search_query.constants import Fields
8+
from search_query.constants import PLATFORM
89
from search_query.query import Query
910
from search_query.query import SearchField
1011
from search_query.query_or import OrQuery

0 commit comments

Comments
 (0)