@iebh/polyglot 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,286 +1,286 @@
1
- # Polyglot Search Translator
2
- This module is part of the [Bond University Centre for Research in Evidence-Based Practice](https://github.com/IEBH) Systematic Review Assistant suite of tools.
3
-
4
- When given a complex search query in either PubMed or Ovid MEDLINE format it will attempt to translate it to any of the supported search engine formats.
5
-
6
- It forms the [Polyglot Search Syntax Translator](http://sr-accelerator.com/#/polyglot) module of the [Systematic Review Accelerator](http://sr-accelerator.com).
7
-
8
- [DEMO](https://iebh.github.io/sra-polyglot/)
9
-
10
- # Table of Contents
11
- - [Polyglot Search Translator](#polyglot-search-translator)
12
- - [Contributing](#contributing)
13
- - [Testing](#testing)
14
- - [Usage Guide](#usage-guide)
15
- - [Plain-text phrases](#plain-text-phrases)
16
- - [Mesh Headings](#mesh-headings)
17
- - [Logical Syntax](#logical-syntax)
18
- - [Proximity searching](#proximity-searching)
19
- - [Line Referencing](#line-referencing)
20
- - [Bracket Expansion](#bracket-expansion)
21
- - [Replacing Empty Field Tags](#replacing-empty-field-tags)
22
- - [Tooltips](#tooltips)
23
- - [Templates](#templates)
24
- - [Comments](#comments)
25
- - [For Developers](#for-developers)
26
- - [Updating Polyglot](#updating-polyglot)
27
- - [Input Output API](#input-output-api)
28
- - [Parsed Tree Object](#parsed-tree-object)
29
- - [group](#group)
30
- - [joinAnd](#joinand)
31
- - [joinNear](#joinnear)
32
- - [joinNot](#joinnot)
33
- - [joinOr](#joinor)
34
- - [mesh](#mesh)
35
- - [phrase](#phrase)
36
- - [raw](#raw)
37
- - [template](#template)
38
-
39
-
40
- # Contributing
41
- Please get in touch if you would like to extend Polyglot or any of the databases we support. Its best to [get in touch with us](https://sr-accelerator.com/#/contact) as we can provide help and resources.
42
-
43
- Generally the process of extending Polyglot takes these steps:
44
-
45
- 1. Prepare a list of translations for known search symbols
46
- 2. Copy a known translation set most similar to the database being added
47
- 3. Check the translations using the [TestKits#testing]
48
- 4. Create a Pull-Request against this repo to include your changes
49
-
50
-
51
- # Testing
52
- When adding new search translations we would strongly recommend existing the existing suite of [testing scripts](./test) to include the new translations. This allows us to track regressions with future feature additions.
53
-
54
- 1. Edit an existing [test file](./test) or create a new one to include your fixes
55
- 2. Run `npm run test` to verify the tests all pass successfully
56
- 3. Create a Pull-Request against this repo to include your changes
57
-
58
-
59
- # Usage Guide
60
- A search query can be specified in either PubMed query format, Ovid MEDLINE format or a mix of the two. Most of the usual search query syntax will be supported by Polyglot by default.
61
-
62
- The following sub-headings break down each individual syntax.
63
-
64
- **General notes**:
65
-
66
- * Generally you can use either PubMed or Ovid MEDLINE query syntax without any issue
67
- * By default queries referenced by line number will be grouped
68
- * Multiple terms can be grouped using speachmarks but this is optional
69
- * [Comments](#comments) can be specified to make your search strategy easier to read in future
70
- * [Templates](#templates) are supported allowing inserts of compound search terms which can be specific to different output engines
71
-
72
-
73
- ## Plain-text phrases
74
- To search for basic phrases simply specify the words within the search term with or without being enclosed in speachmarks. Specific search fields can be specified by appending it to the term in any of the following supported formats:
75
-
76
- * `Term` (Generic search in all fields, polyglot will underline the word in blue: [Replacing Empty Field Tags](#replacing-empty-field-tags))
77
- * `Term[ti]` (PubMed field specification, fields also supported: `tiab`, `ti`, `tw`, `ab`, `nm`, `sh`, `pt`, `la`)
78
- * `Term.ti.` or `Term:ti` (Ovid MEDLINE field specification, fields also supported: `tw`, `ti,ab`, `ab,ti`, `ti`, `ab`, `mp`, `nm`, `pt`, `fs`, `sh`, `xm`, `lg`)
79
-
80
-
81
- ## Mesh Headings
82
- To search for a supported Mesh term use any of the following:
83
-
84
- * `Term[Mesh]` (exploded Mesh heading, PubMed format)
85
- * `Term[Mesh:NoExp]` (non-exploded Mesh heading, PubMed format)
86
- * `Term[Majr]` or `Term[MeSH Major Topic]` (Major Mesh heading, PubMed format)
87
- * `exp Term/` (exploded Mesh heading, Ovid MEDLINE format #1)
88
- * `exp *Term/` (Major Mesh heading, Ovid MEDLINE format #1)
89
- * `Term/` (non-exploded Mesh heading, Ovid MEDLINE format #1)
90
- * `Term.xm.` (exploded Mesh heading, Ovid MEDLINE format #2)
91
- * `Term.sh.` (non-exploded Mesh heading, Ovid MEDLINE format #2)
92
-
93
-
94
- ## Logical Syntax
95
- Any of the following keywords can be used to join multiple phrases together:
96
-
97
- * `Term1 AND Term2`
98
- * `Term1 OR Term2`
99
- * `Term1 NOT Term2`
100
- * `(Term1 OR Term2) AND (Term3 OR Term4)` (logical grouping using brackets)
101
-
102
- All keywords are case insensitive (i.e. `and` works the same as `AND` or `And`).
103
-
104
-
105
- ## Proximity searching
106
- Similar to [Logical Syntax](#logical-syntax), proximity searching allows the searching of a secondary term within the range of the primary:
107
-
108
- * `Term1 ADJ3 Term2` (Search for `Term2` within 3 words of `Term1`, Ovid MEDLINE format)
109
- * `Term1 NEAR3 Term2` (Search for `Term2` within 3 words of `Term1`, Cochrane Library format)
110
- * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, CINAHL format)
111
- * `Term1 NEAR/3 Term2` (Search for `Term2` within 3 words of `Term1`, Embase and Web of Science formats)
112
- * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, PsycInfo (Ebsco) format)
113
- * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, Business format)
114
- * `Term1 AND Term2` (Search for `Term2` within 3 words of `Term1`, Lilacs format)
115
-
116
-
117
- ## Line Referencing
118
- There are two main methods to number lines, either leave the beginning of the line blank and use the numbers provided in the left hand side of the editor, or specify a custom number at the beginning of each line.
119
- Automatic line expansion can be used by enabling the checkbox.
120
- **If you specify a line number at the beginning of a line, all lines must be numbered.**
121
-
122
- ![blank line number](https://user-images.githubusercontent.com/25999161/61197739-d3be5d00-a719-11e9-94ab-60f3bd00175a.png)
123
-
124
- ![custom line number](https://user-images.githubusercontent.com/25999161/61197858-5c3cfd80-a71a-11e9-83ff-cda3adce3a76.png)
125
-
126
- To reference a certain line simply insert the line number before or after [Logical Syntax](#logical-syntax). Any lines that are referenced will be automatically grouped
127
-
128
- ```
129
- 1. foo[ti]
130
- 2. baz[tiab]
131
- 3. 1 OR 2
132
- 4. bar[ti]
133
- 5. 3 AND 4
134
- ```
135
-
136
- ![output](https://user-images.githubusercontent.com/25999161/61197608-43801800-a719-11e9-8d61-b54ad5c50368.png)
137
-
138
-
139
- ## Bracket Expansion
140
- While Ovid Medline supports using field tags on groups, PubMed doesn't, so any time a group contains a field tag on the end, it will be expanded for any engines which do not support field tags on groups.
141
-
142
- **e.g. Ovid to PubMed** `(foo or bar).ti. --> (foo[ti] or bar[ti])`
143
-
144
-
145
- ## Replacing Empty Field Tags
146
- Any time there is a phrase without a field tag (a generic search for all fields), a dashed blue underline will appear underneath it. Clicking on the word will bring up a dialogue box which will allow you to specify a field tag to replace the missing field tag for either just that word or all phrases with no field tags.
147
-
148
- ![box](https://user-images.githubusercontent.com/25999161/61197578-07e54e00-a719-11e9-96b3-b64d0282fff3.png)
149
-
150
-
151
- ## Tooltips
152
- Any time a black dotted line appears underneath a word, hover over it to display a tooltip with more information. These tooltips will usually appear to inform the user when polyglot makes a decision on their behalf.
153
-
154
- **e.g. When attempting to convert foo.ab. from and Ovid Medline Search to PubMed, because PubMed does not support searching the abstract field term by itself Polyglot translates it to the Title and Abstract field term.**
155
-
156
- ![tooltip](https://user-images.githubusercontent.com/25999161/61197414-2e56b980-a718-11e9-91ff-64979e3ea765.png)
157
-
158
-
159
- ## Templates
160
- These are specified using the `<Template ID>` syntax.
161
-
162
- For example the "RCT Filter" template (specified via `<RCT Filter>` in Polyglot) has a specific syntax in PubMed and Ovid MEDLINE and in some search engines is omitted all other. Using templates allows Polyglot to correctly swap the syntax based on the output engine.
163
-
164
- | Template ID | Description |
165
- |---------------|-------------------------------|
166
- | `<rct filter>`| Standard Cochrane RCT Filter |
167
- | `<sr filter>` | Standard Cochrane SR Filter |
168
- | `<engine>` | The current output engine |
169
-
170
-
171
- ## Comments
172
- Comments allow you to add notes within your search strategy which will be removed from the output.
173
- These allow you to write your query in a human-readable way without effecting the output in each search engine.
174
-
175
- To use comments simply add a hash character (`#`) anywhere on a line. Any text *after* that character will be ignored until the next line.
176
-
177
-
178
- # For Developers
179
-
180
- ## Updating Polyglot
181
- To update polyglot, update spreadsheet and then replace `data/v4.xlsx` with spreadsheet
182
- Run `npm run preprocess` to update translations and republish
183
- ## Input Output API
184
- ```javascript
185
- polyglot = require('sra-polyglot').default;
186
-
187
- var queries = polyglot.translateAll('"Primary Health Care"[Mesh] OR Primary care OR Primary healthcare OR Family practice OR General practice\n\nAND\n\n"Treatment Failure"[Mesh] OR Treatment failure OR Treatment failures\n\nAND\n\n"Bacterial Infections"[Mesh] OR Bacteria OR Bacterial\n\nAND\n\n"Anti-Bacterial Agents"[Mesh] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic');
188
-
189
- console.log(queries);
190
- ```
191
-
192
- Will output an object structure like:
193
-
194
- ```json
195
- {
196
- "pubmed": "(\"Primary Health Care\"[MESH] OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(\"Treatment Failure\"[MESH] OR Treatment failure OR Treatment failures)\n\nAND\n\n(\"Bacterial Infections\"[MESH] OR Bacteria OR Bacterial)\n\nAND\n\n(\"Anti-Bacterial Agents\"[MESH] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
197
- "ovid": "(exp Primary Health Care/ OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(exp Treatment Failure/ OR Treatment failure OR Treatment failures)\n\nAND\n\n(exp Bacterial Infections/ OR Bacteria OR Bacterial)\n\nAND\n\n(exp Anti-Bacterial Agents/ OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
198
- "cochrane": "([mh \"Primary Health Care\"] OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n([mh \"Treatment Failure\"] OR Treatment failure OR Treatment failures)\n\nAND\n\n([mh \"Bacterial Infections\"] OR Bacteria OR Bacterial)\n\nAND\n\n([mh \"Anti-Bacterial Agents\"] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
199
- "embase": "('Primary Health Care'/exp OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n('Treatment Failure'/exp OR Treatment failure OR Treatment failures)\n\nAND\n\n('Bacterial Infections'/exp OR Bacteria OR Bacterial)\n\nAND\n\n('Anti-Bacterial Agents'/exp OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
200
- "webofscience": "(Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(Treatment failure OR Treatment failures)\n\nAND\n\n(Bacteria OR Bacterial)\n\nAND\n\n(Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
201
- "cinahl": "((MH \"Primary Health Care+\") OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n((MH \"Treatment Failure+\") OR Treatment failure OR Treatment failures)\n\nAND\n\n((MH \"Bacterial Infections+\") OR Bacteria OR Bacterial)\n\nAND\n\n((MH \"Anti-Bacterial Agents+\") OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
202
- "business": "((MH \"Primary Health Care+\") OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n((MH \"Treatment Failure+\") OR Treatment failure OR Treatment failures)\n\nAND\n\n((MH \"Bacterial Infections+\") OR Bacteria OR Bacterial)\n\nAND\n\n((MH \"Anti-Bacterial Agents+\") OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)"
203
- }
204
- ```
205
-
206
- See the JSDoc of the [inline code](index.js) for more details on the supported APIs.
207
-
208
- A demo is also available. To use this [follow the instructions in the demo directory](./demo/README.md).
209
-
210
- ## Parsed Tree Object
211
- This section is only intended for people who are interested in the inner working of the parsing tree used by Polyglot.
212
-
213
- Each of the following sub-sections describes a node which can be contained within the compiled tree returned by `Polyglot.parse(query)`.
214
-
215
- The result tree can then be fed into `Polyglot.engines.ENGINE.compile(tree)` to return the translated search.
216
-
217
-
218
- ### group
219
- A sub-grouping of nodes. This represents a lexical parentheses level.
220
-
221
- | Property | Type | Description |
222
- |----------|-------------|-----------------------------------------------------------------------------------------------|
223
- | `field` | String Enum | The field to use for complex logical comparisons (see the `phrase` section for the full list) |
224
- | `nodes` | Array | Sub-nodes to include within the search group |
225
-
226
-
227
- ### joinAnd
228
- A logical 'And' condition between the previous and next element.
229
-
230
-
231
- ### joinNear
232
- A proximity join between the previous and next element.
233
-
234
- | Property | Type | Description |
235
- |-------------|--------|--------------------------------------------------------------------|
236
- | `proximity` | Number | The number of (usually) words to allow as a maximum proximity scan |
237
-
238
-
239
- ### joinNot
240
- A logical 'Not' condition between the previous and next element.
241
-
242
-
243
- ### joinOr
244
- A logical 'Or' condition between the previous and next element.
245
-
246
-
247
- ### mesh
248
- A valid Mesh heading.
249
-
250
- | Property | Type | Description |
251
- |-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------|
252
- | `content` | String | The Mesh heading to use |
253
- | `recurse` | Boolean | Whether to recurse down child Mesh nodes when searching. This is only present if the input syntax supports it (Ovid MEDLINE specifically) |
254
-
255
-
256
- ### phrase
257
- A simple text phrase.
258
-
259
- | Property | Type | Description |
260
- |-----------|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
261
- | `field` | String Enum: `title`, `abstract`, `title+abstract`, `practiceGuideline`, `floatingSubheading` | The field to use for simple phrase comparisons |
262
- | `content` | String | If specified the string of text to search for in the field specified by `context`. Cannot be used with `nodes` |
263
- | `nodes` | Array | If specified points to a group of nodes used to compile the search expression to be searched in the field specified by `context`. The `nodes` structure must contain exactly 1 element and it must be of a group type. Cannot be used with `content` |
264
-
265
-
266
- ### raw
267
- A string of text that should be passed from the input to the output.
268
- This string can contain control characters such as line-feeds.
269
-
270
-
271
- | Property | Type | Description |
272
- |-----------|--------|--------------------------------|
273
- | `content` | String | The string of text to preserve |
274
-
275
-
276
- ### template
277
- A meta template specified which Polyglot will insert into the output correctly based on the search engine.
278
-
279
- These are specified using the `<Template ID>` syntax.
280
-
281
- For example the "RCT Filter" template (specified via `<RCT Filter>` in Polyglot) has a specific syntax in PubMed and Ovid MEDLINE and in some search engines is omitted all other. Using templates allows Polyglot to correctly swap the syntax based on the output engine.
282
-
283
-
284
- | Property | Type | Description |
285
- |-----------|--------|--------------------------------------------------|
286
- | `content` | String | The lower-case version of the template ID to use |
1
+ # Polyglot Search Translator
2
+ This module is part of the [Bond University Centre for Research in Evidence-Based Practice](https://github.com/IEBH) Systematic Review Assistant suite of tools.
3
+
4
+ When given a complex search query in either PubMed or Ovid MEDLINE format it will attempt to translate it to any of the supported search engine formats.
5
+
6
+ It forms the [Polyglot Search Syntax Translator](http://sr-accelerator.com/#/polyglot) module of the [Systematic Review Accelerator](http://sr-accelerator.com).
7
+
8
+ [DEMO](https://iebh.github.io/sra-polyglot/)
9
+
10
+ # Table of Contents
11
+ - [Polyglot Search Translator](#polyglot-search-translator)
12
+ - [Contributing](#contributing)
13
+ - [Testing](#testing)
14
+ - [Usage Guide](#usage-guide)
15
+ - [Plain-text phrases](#plain-text-phrases)
16
+ - [Mesh Headings](#mesh-headings)
17
+ - [Logical Syntax](#logical-syntax)
18
+ - [Proximity searching](#proximity-searching)
19
+ - [Line Referencing](#line-referencing)
20
+ - [Bracket Expansion](#bracket-expansion)
21
+ - [Replacing Empty Field Tags](#replacing-empty-field-tags)
22
+ - [Tooltips](#tooltips)
23
+ - [Templates](#templates)
24
+ - [Comments](#comments)
25
+ - [For Developers](#for-developers)
26
+ - [Updating Polyglot](#updating-polyglot)
27
+ - [Input Output API](#input-output-api)
28
+ - [Parsed Tree Object](#parsed-tree-object)
29
+ - [group](#group)
30
+ - [joinAnd](#joinand)
31
+ - [joinNear](#joinnear)
32
+ - [joinNot](#joinnot)
33
+ - [joinOr](#joinor)
34
+ - [mesh](#mesh)
35
+ - [phrase](#phrase)
36
+ - [raw](#raw)
37
+ - [template](#template)
38
+
39
+
40
+ # Contributing
41
+ Please get in touch if you would like to extend Polyglot or any of the databases we support. Its best to [get in touch with us](https://sr-accelerator.com/#/contact) as we can provide help and resources.
42
+
43
+ Generally the process of extending Polyglot takes these steps:
44
+
45
+ 1. Prepare a list of translations for known search symbols
46
+ 2. Copy a known translation set most similar to the database being added
47
+ 3. Check the translations using the [TestKits#testing]
48
+ 4. Create a Pull-Request against this repo to include your changes
49
+
50
+
51
+ # Testing
52
+ When adding new search translations we would strongly recommend existing the existing suite of [testing scripts](./test) to include the new translations. This allows us to track regressions with future feature additions.
53
+
54
+ 1. Edit an existing [test file](./test) or create a new one to include your fixes
55
+ 2. Run `npm run test` to verify the tests all pass successfully
56
+ 3. Create a Pull-Request against this repo to include your changes
57
+
58
+
59
+ # Usage Guide
60
+ A search query can be specified in either PubMed query format, Ovid MEDLINE format or a mix of the two. Most of the usual search query syntax will be supported by Polyglot by default.
61
+
62
+ The following sub-headings break down each individual syntax.
63
+
64
+ **General notes**:
65
+
66
+ * Generally you can use either PubMed or Ovid MEDLINE query syntax without any issue
67
+ * By default queries referenced by line number will be grouped
68
+ * Multiple terms can be grouped using speachmarks but this is optional
69
+ * [Comments](#comments) can be specified to make your search strategy easier to read in future
70
+ * [Templates](#templates) are supported allowing inserts of compound search terms which can be specific to different output engines
71
+
72
+
73
+ ## Plain-text phrases
74
+ To search for basic phrases simply specify the words within the search term with or without being enclosed in speachmarks. Specific search fields can be specified by appending it to the term in any of the following supported formats:
75
+
76
+ * `Term` (Generic search in all fields, polyglot will underline the word in blue: [Replacing Empty Field Tags](#replacing-empty-field-tags))
77
+ * `Term[ti]` (PubMed field specification, fields also supported: `tiab`, `ti`, `tw`, `ab`, `nm`, `sh`, `pt`, `la`)
78
+ * `Term.ti.` or `Term:ti` (Ovid MEDLINE field specification, fields also supported: `tw`, `ti,ab`, `ab,ti`, `ti`, `ab`, `mp`, `nm`, `pt`, `fs`, `sh`, `xm`, `lg`)
79
+
80
+
81
+ ## Mesh Headings
82
+ To search for a supported Mesh term use any of the following:
83
+
84
+ * `Term[Mesh]` (exploded Mesh heading, PubMed format)
85
+ * `Term[Mesh:NoExp]` (non-exploded Mesh heading, PubMed format)
86
+ * `Term[Majr]` or `Term[MeSH Major Topic]` (Major Mesh heading, PubMed format)
87
+ * `exp Term/` (exploded Mesh heading, Ovid MEDLINE format #1)
88
+ * `exp *Term/` (Major Mesh heading, Ovid MEDLINE format #1)
89
+ * `Term/` (non-exploded Mesh heading, Ovid MEDLINE format #1)
90
+ * `Term.xm.` (exploded Mesh heading, Ovid MEDLINE format #2)
91
+ * `Term.sh.` (non-exploded Mesh heading, Ovid MEDLINE format #2)
92
+
93
+
94
+ ## Logical Syntax
95
+ Any of the following keywords can be used to join multiple phrases together:
96
+
97
+ * `Term1 AND Term2`
98
+ * `Term1 OR Term2`
99
+ * `Term1 NOT Term2`
100
+ * `(Term1 OR Term2) AND (Term3 OR Term4)` (logical grouping using brackets)
101
+
102
+ All keywords are case insensitive (i.e. `and` works the same as `AND` or `And`).
103
+
104
+
105
+ ## Proximity searching
106
+ Similar to [Logical Syntax](#logical-syntax), proximity searching allows the searching of a secondary term within the range of the primary:
107
+
108
+ * `Term1 ADJ3 Term2` (Search for `Term2` within 3 words of `Term1`, Ovid MEDLINE format)
109
+ * `Term1 NEAR3 Term2` (Search for `Term2` within 3 words of `Term1`, Cochrane Library format)
110
+ * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, CINAHL format)
111
+ * `Term1 NEAR/3 Term2` (Search for `Term2` within 3 words of `Term1`, Embase and Web of Science formats)
112
+ * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, PsycInfo (Ebsco) format)
113
+ * `Term1 N3 Term2` (Search for `Term2` within 3 words of `Term1`, Business format)
114
+ * `Term1 AND Term2` (Search for `Term2` within 3 words of `Term1`, Lilacs format)
115
+
116
+
117
+ ## Line Referencing
118
+ There are two main methods to number lines, either leave the beginning of the line blank and use the numbers provided in the left hand side of the editor, or specify a custom number at the beginning of each line.
119
+ Automatic line expansion can be used by enabling the checkbox.
120
+ **If you specify a line number at the beginning of a line, all lines must be numbered.**
121
+
122
+ ![blank line number](https://user-images.githubusercontent.com/25999161/61197739-d3be5d00-a719-11e9-94ab-60f3bd00175a.png)
123
+
124
+ ![custom line number](https://user-images.githubusercontent.com/25999161/61197858-5c3cfd80-a71a-11e9-83ff-cda3adce3a76.png)
125
+
126
+ To reference a certain line simply insert the line number before or after [Logical Syntax](#logical-syntax). Any lines that are referenced will be automatically grouped
127
+
128
+ ```
129
+ 1. foo[ti]
130
+ 2. baz[tiab]
131
+ 3. 1 OR 2
132
+ 4. bar[ti]
133
+ 5. 3 AND 4
134
+ ```
135
+
136
+ ![output](https://user-images.githubusercontent.com/25999161/61197608-43801800-a719-11e9-8d61-b54ad5c50368.png)
137
+
138
+
139
+ ## Bracket Expansion
140
+ While Ovid Medline supports using field tags on groups, PubMed doesn't, so any time a group contains a field tag on the end, it will be expanded for any engines which do not support field tags on groups.
141
+
142
+ **e.g. Ovid to PubMed** `(foo or bar).ti. --> (foo[ti] or bar[ti])`
143
+
144
+
145
+ ## Replacing Empty Field Tags
146
+ Any time there is a phrase without a field tag (a generic search for all fields), a dashed blue underline will appear underneath it. Clicking on the word will bring up a dialogue box which will allow you to specify a field tag to replace the missing field tag for either just that word or all phrases with no field tags.
147
+
148
+ ![box](https://user-images.githubusercontent.com/25999161/61197578-07e54e00-a719-11e9-96b3-b64d0282fff3.png)
149
+
150
+
151
+ ## Tooltips
152
+ Any time a black dotted line appears underneath a word, hover over it to display a tooltip with more information. These tooltips will usually appear to inform the user when polyglot makes a decision on their behalf.
153
+
154
+ **e.g. When attempting to convert foo.ab. from and Ovid Medline Search to PubMed, because PubMed does not support searching the abstract field term by itself Polyglot translates it to the Title and Abstract field term.**
155
+
156
+ ![tooltip](https://user-images.githubusercontent.com/25999161/61197414-2e56b980-a718-11e9-91ff-64979e3ea765.png)
157
+
158
+
159
+ ## Templates
160
+ These are specified using the `<Template ID>` syntax.
161
+
162
+ For example the "RCT Filter" template (specified via `<RCT Filter>` in Polyglot) has a specific syntax in PubMed and Ovid MEDLINE and in some search engines is omitted all other. Using templates allows Polyglot to correctly swap the syntax based on the output engine.
163
+
164
+ | Template ID | Description |
165
+ |---------------|-------------------------------|
166
+ | `<rct filter>`| Standard Cochrane RCT Filter |
167
+ | `<sr filter>` | Standard Cochrane SR Filter |
168
+ | `<engine>` | The current output engine |
169
+
170
+
171
+ ## Comments
172
+ Comments allow you to add notes within your search strategy which will be removed from the output.
173
+ These allow you to write your query in a human-readable way without effecting the output in each search engine.
174
+
175
+ To use comments simply add a hash character (`#`) anywhere on a line. Any text *after* that character will be ignored until the next line.
176
+
177
+
178
+ # For Developers
179
+
180
+ ## Updating Polyglot
181
+ To update polyglot, update spreadsheet and then replace `data/v4.xlsx` with spreadsheet
182
+ Run `npm run preprocess` to update translations and republish
183
+ ## Input Output API
184
+ ```javascript
185
+ polyglot = require('sra-polyglot').default;
186
+
187
+ var queries = polyglot.translateAll('"Primary Health Care"[Mesh] OR Primary care OR Primary healthcare OR Family practice OR General practice\n\nAND\n\n"Treatment Failure"[Mesh] OR Treatment failure OR Treatment failures\n\nAND\n\n"Bacterial Infections"[Mesh] OR Bacteria OR Bacterial\n\nAND\n\n"Anti-Bacterial Agents"[Mesh] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic');
188
+
189
+ console.log(queries);
190
+ ```
191
+
192
+ Will output an object structure like:
193
+
194
+ ```json
195
+ {
196
+ "pubmed": "(\"Primary Health Care\"[MESH] OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(\"Treatment Failure\"[MESH] OR Treatment failure OR Treatment failures)\n\nAND\n\n(\"Bacterial Infections\"[MESH] OR Bacteria OR Bacterial)\n\nAND\n\n(\"Anti-Bacterial Agents\"[MESH] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
197
+ "ovid": "(exp Primary Health Care/ OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(exp Treatment Failure/ OR Treatment failure OR Treatment failures)\n\nAND\n\n(exp Bacterial Infections/ OR Bacteria OR Bacterial)\n\nAND\n\n(exp Anti-Bacterial Agents/ OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
198
+ "cochrane": "([mh \"Primary Health Care\"] OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n([mh \"Treatment Failure\"] OR Treatment failure OR Treatment failures)\n\nAND\n\n([mh \"Bacterial Infections\"] OR Bacteria OR Bacterial)\n\nAND\n\n([mh \"Anti-Bacterial Agents\"] OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
199
+ "embase": "('Primary Health Care'/exp OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n('Treatment Failure'/exp OR Treatment failure OR Treatment failures)\n\nAND\n\n('Bacterial Infections'/exp OR Bacteria OR Bacterial)\n\nAND\n\n('Anti-Bacterial Agents'/exp OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
200
+ "webofscience": "(Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n(Treatment failure OR Treatment failures)\n\nAND\n\n(Bacteria OR Bacterial)\n\nAND\n\n(Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
201
+ "cinahl": "((MH \"Primary Health Care+\") OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n((MH \"Treatment Failure+\") OR Treatment failure OR Treatment failures)\n\nAND\n\n((MH \"Bacterial Infections+\") OR Bacteria OR Bacterial)\n\nAND\n\n((MH \"Anti-Bacterial Agents+\") OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)",
202
+ "business": "((MH \"Primary Health Care+\") OR Primary care OR Primary healthcare OR Family practice OR General practice)\n\nAND\n\n((MH \"Treatment Failure+\") OR Treatment failure OR Treatment failures)\n\nAND\n\n((MH \"Bacterial Infections+\") OR Bacteria OR Bacterial)\n\nAND\n\n((MH \"Anti-Bacterial Agents+\") OR Antibacterial Agents OR Antibacterial Agent OR Antibiotics OR Antibiotic)"
203
+ }
204
+ ```
205
+
206
+ See the JSDoc of the [inline code](index.js) for more details on the supported APIs.
207
+
208
+ A demo is also available. To use this [follow the instructions in the demo directory](./demo/README.md).
209
+
210
+ ## Parsed Tree Object
211
+ This section is only intended for people who are interested in the inner working of the parsing tree used by Polyglot.
212
+
213
+ Each of the following sub-sections describes a node which can be contained within the compiled tree returned by `Polyglot.parse(query)`.
214
+
215
+ The result tree can then be fed into `Polyglot.engines.ENGINE.compile(tree)` to return the translated search.
216
+
217
+
218
+ ### group
219
+ A sub-grouping of nodes. This represents a lexical parentheses level.
220
+
221
+ | Property | Type | Description |
222
+ |----------|-------------|-----------------------------------------------------------------------------------------------|
223
+ | `field` | String Enum | The field to use for complex logical comparisons (see the `phrase` section for the full list) |
224
+ | `nodes` | Array | Sub-nodes to include within the search group |
225
+
226
+
227
+ ### joinAnd
228
+ A logical 'And' condition between the previous and next element.
229
+
230
+
231
+ ### joinNear
232
+ A proximity join between the previous and next element.
233
+
234
+ | Property | Type | Description |
235
+ |-------------|--------|--------------------------------------------------------------------|
236
+ | `proximity` | Number | The number of (usually) words to allow as a maximum proximity scan |
237
+
238
+
239
+ ### joinNot
240
+ A logical 'Not' condition between the previous and next element.
241
+
242
+
243
+ ### joinOr
244
+ A logical 'Or' condition between the previous and next element.
245
+
246
+
247
+ ### mesh
248
+ A valid Mesh heading.
249
+
250
+ | Property | Type | Description |
251
+ |-----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------|
252
+ | `content` | String | The Mesh heading to use |
253
+ | `recurse` | Boolean | Whether to recurse down child Mesh nodes when searching. This is only present if the input syntax supports it (Ovid MEDLINE specifically) |
254
+
255
+
256
+ ### phrase
257
+ A simple text phrase.
258
+
259
+ | Property | Type | Description |
260
+ |-----------|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
261
+ | `field` | String Enum: `title`, `abstract`, `title+abstract`, `practiceGuideline`, `floatingSubheading` | The field to use for simple phrase comparisons |
262
+ | `content` | String | If specified the string of text to search for in the field specified by `context`. Cannot be used with `nodes` |
263
+ | `nodes` | Array | If specified points to a group of nodes used to compile the search expression to be searched in the field specified by `context`. The `nodes` structure must contain exactly 1 element and it must be of a group type. Cannot be used with `content` |
264
+
265
+
266
+ ### raw
267
+ A string of text that should be passed from the input to the output.
268
+ This string can contain control characters such as line-feeds.
269
+
270
+
271
+ | Property | Type | Description |
272
+ |-----------|--------|--------------------------------|
273
+ | `content` | String | The string of text to preserve |
274
+
275
+
276
+ ### template
277
+ A meta template specified which Polyglot will insert into the output correctly based on the search engine.
278
+
279
+ These are specified using the `<Template ID>` syntax.
280
+
281
+ For example the "RCT Filter" template (specified via `<RCT Filter>` in Polyglot) has a specific syntax in PubMed and Ovid MEDLINE and in some search engines is omitted all other. Using templates allows Polyglot to correctly swap the syntax based on the output engine.
282
+
283
+
284
+ | Property | Type | Description |
285
+ |-----------|--------|--------------------------------------------------|
286
+ | `content` | String | The lower-case version of the template ID to use |