Skip to content

Commit e973dd1

Browse files
author
Gerit Wagner
committed
update docs
1 parent 2358c63 commit e973dd1

20 files changed

+472
-251
lines changed

README.md

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -16,124 +16,6 @@ As a default it relies on the JSON schema proposed by an expert panel (Haddaway
1616
The package can be used programmatically or through the command line, has zero dependencies, and can therefore be integrated in a variety of environments.
1717
The heuristics, parsers, and linters are battle-tested on over 500 peer-reviewed queries registered at [searchRxiv](https://www.cabidigitallibrary.org/journal/searchrxiv).
1818

19-
## Installation
20-
21-
To install search-query, run:
22-
23-
```
24-
pip install search-query
25-
```
26-
27-
## Programmatic use
28-
29-
To create a query programmatically, run:
30-
31-
```Python
32-
from search_query import OrQuery, AndQuery
33-
34-
# Typical building-blocks approach
35-
digital_synonyms = OrQuery(["digital", "virtual", "online"], search_field="Abstract")
36-
work_synonyms = OrQuery(["work", "labor", "service"], search_field="Abstract")
37-
query = AndQuery([digital_synonyms, work_synonyms], search_field="Author Keywords")
38-
```
39-
40-
Parameters:
41-
42-
- list of strings or queries: strings that you want to include in the search query,
43-
- `search_field`: search field to which the query should be applied (available options: TODO: GIVE EXAMPLES AND LINK TO DOCS)
44-
45-
To load a JSON query file, run the parser:
46-
47-
```python
48-
from search_query.search_file import SearchFile
49-
from search_query.parser import parse
50-
51-
search = SearchFile("search-file.json")
52-
query = parse(search.search_string, syntax=search.platform)
53-
```
54-
55-
Available platform identifiers are listed [here](search_query/constants.py).
56-
57-
To validate a JSON query file, run the linter:
58-
59-
```Python
60-
from search_query.linter import run_linter
61-
62-
messages = run_linter(search.search_string, syntax=search.platform)
63-
print(messages)
64-
```
65-
66-
Linter messages are documented and explained [here](docs/dev_linter.md).
67-
68-
To simplify and format a query, run:
69-
70-
```Python
71-
query.format(*tbd: how to select/exclude rules?*)
72-
```
73-
To translate a query to a particular database syntax and print it, run:
74-
75-
```Python
76-
query.to_string(syntax="ebsco")
77-
query.to_string(syntax="pubmed")
78-
query.to_string(syntax="wos")
79-
```
80-
81-
To write a query to a JSON file, run the serializer:
82-
83-
```Python
84-
from search_query import save_file
85-
86-
save_file(
87-
filename="search-file.json",
88-
query_str=query.to_string(syntax="wos"),
89-
syntax="wos",
90-
authors=[{"name": "Tom Brady"}],
91-
record_info={},
92-
date={}
93-
)
94-
```
95-
96-
## CLI use
97-
98-
Linters can be run on the CLI:
99-
100-
```
101-
search-query lint search-file.json
102-
```
103-
104-
## Pre-commit hooks
105-
106-
Linters can be included as pre-commit hooks by adding the following to the `.pre-commit-config.yaml:
107-
108-
```yaml
109-
repos:
110-
- repo: https://github.com/CoLRev-Environment/search-query
111-
rev: main # or version of search-query
112-
hooks:
113-
- id: search-file-lint
114-
115-
```
116-
117-
For development and testing, use the following:
118-
119-
```yaml
120-
repos:
121-
- repo: local
122-
hooks:
123-
- id: search-file-lint
124-
name: Search-file linter
125-
entry: search-file-lint
126-
language: python
127-
files: \.json$
128-
```
129-
130-
To activate and run:
131-
132-
```
133-
pre-commit install
134-
pre-commit run --all
135-
```
136-
13719
## Documentation
13820

13921
[docs](docs/readme.md)

docs/source/dev_docs/linter.rst

Lines changed: 0 additions & 108 deletions
This file was deleted.

docs/source/dev_docs/parser.rst

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
Developing a parser
22
===================
33

4-
A code skeleton is available for the `parser <parser_skeleton.py>`_ and `tests <parser_skeleton_tests.py>`_.
4+
.. image:: documentation.png
5+
:width: 800px
6+
7+
Development setup
8+
-------------------
9+
10+
.. code-block::
11+
:caption: Installation in editable mode with `dev` extras
12+
13+
pip install -e ".[dev]"
14+
15+
Skeleton
16+
--------------------
17+
18+
A code skeleton is available for the parser and tests:
19+
20+
.. literalinclude:: parser_skeleton.py
21+
:language: python
22+
23+
24+
.. literalinclude:: parser_skeleton_tests.py
25+
:language: python
26+
527

628
To parse a list format, the numbered sub-queries should be replaced to create a search string, which can be parsed with the standard string-parser. This helps to avoid redundant implementation.
729

@@ -30,3 +52,76 @@ When parsing combined DB-Fields, the standard syntax should consist of n nodes,
3052
**n:1 matches**
3153

3254
If multiple Database-Fields correspond to the same Standard-Field, a combination of the default Database-Field and Standard-Field are added to the ``constants.SYNTAX_FIELD_MAP``. Non-default Database-Fields are replaced by the parser. For example, the default for MeSH terms at Pubmed is ``[mh]``, but the parser also supports ``[mesh]``.
55+
56+
Search Field Validation in Strict vs. Non-Strict Modes
57+
----------------------------------------------------------
58+
59+
.. list-table:: Search Field Validation in Strict vs. Non-Strict Modes
60+
:widths: 20 20 20 20 20
61+
:header-rows: 1
62+
63+
* - **Search-Field required**
64+
- **Search String**
65+
- **Search-Field**
66+
- **Mode: Strict**
67+
- **Mode: Non-Strict**
68+
* - Yes
69+
- With Search-Field
70+
- Empty
71+
- ok
72+
- ok
73+
* - Yes
74+
- With Search-Field
75+
- Equal to Search-String
76+
- ok - search-field-redundant
77+
- ok
78+
* - Yes
79+
- With Search-Field
80+
- Different from Search-String
81+
- error: search-field-contradiction
82+
- ok - search-field-contradiction. Parser uses Search-String per default
83+
* - Yes
84+
- Without Search-Field
85+
- Empty
86+
- error: search-field-missing
87+
- ok - search-field-missing. Parser adds `title` as the default
88+
* - Yes
89+
- Without Search-Field
90+
- Given
91+
- ok - search-field-extracted
92+
- ok
93+
* - No
94+
- With Search-Field
95+
- Empty
96+
- ok
97+
- ok
98+
* - No
99+
- With Search-Field
100+
- Equal to Search-String
101+
- ok - search-field-redundant
102+
- ok
103+
* - No
104+
- With Search-Field
105+
- Different from Search-String
106+
- error: search-field-contradiction
107+
- ok - search-field-contradiction. Parser uses Search-String per default
108+
* - No
109+
- Without Search-Field
110+
- Empty
111+
- ok - search-field-not-specified
112+
- ok - Parser uses default of database
113+
* - No
114+
- Without Search-Field
115+
- Given
116+
- ok - search-field-extracted
117+
- ok
118+
119+
Tests
120+
----------------
121+
122+
- All test data should be stored in standard JSON.
123+
124+
Resources
125+
---------------
126+
127+
- `Web of Science Errors <https://images.webofknowledge.com/WOKRS528R6/help/TCT/ht_errors.html>`_
File renamed without changes.

0 commit comments

Comments
 (0)