@iebh/polyglot 4.8.7 → 4.8.9

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.
@@ -319,10 +319,40 @@ var _default = {
319
319
  buffer += 'NOT';
320
320
  break;
321
321
  case 'raw':
322
- console.log("Here1", branch.content, engine, buffer);
323
322
  buffer += branch.content;
324
323
  break;
325
324
  case 'dollarOne':
325
+ console.log("Here1", branch, engine, buffer);
326
+ switch (engine) {
327
+ case 'PubMed full':
328
+ case 'PubMed abbreviation':
329
+ case 'Lilacs':
330
+ case 'Scopus (basic search)':
331
+ case 'Scopus (advanced search)':
332
+ case 'International HTA Database':
333
+ buffer += '*';
334
+ break;
335
+ case 'Ovid MEDLINE':
336
+ buffer += branch.content;
337
+ break;
338
+ case 'Cochrane Library':
339
+ case 'PsycInfo (Ovid)':
340
+ case 'ProQuest Health and Medical':
341
+ buffer += '?';
342
+ break;
343
+ case 'Embase (Elsevier)':
344
+ case 'Web of Science':
345
+ case 'WoS Advanced':
346
+ buffer += '$';
347
+ break;
348
+ case 'CINAHL (Ebsco)':
349
+ case 'SPORTDiscus':
350
+ case 'Business Source Ultimate':
351
+ case 'PsycInfo (Ebsco)':
352
+ buffer += '#';
353
+ break;
354
+ }
355
+ break;
326
356
  case 'template':
327
357
  console.log("Here2", branch.content, engine, buffer);
328
358
  buffer += _tools["default"].resolveTemplate(branch.content, engine);
@@ -138,20 +138,65 @@ var parse = function parse(query, options) {
138
138
  while (q.length) {
139
139
  var cropString = true; // Whether to remove one charcater from the beginning of the string (set to false if the lexical match handles this behaviour itself)
140
140
  var match;
141
- if (match = /\$1/.exec(q)) {
142
- // $1
141
+ if (match = /^(\$([2-9]+)) +(AND|OR|NOT)\s+/i.exec(q)) {
142
+ // $2 AND
143
+ branch.nodes.push({
144
+ type: 'dollarOtherNum',
145
+ ref: [match[2]],
146
+ cond: '',
147
+ nodes: []
148
+ });
149
+ offset += match[1].length;
150
+ q = q.substr(match[1].length);
151
+ cropString = false;
152
+ } else if (match = /^(AND|OR|NOT) +\$([2-9]+)\b/i.exec(q)) {
153
+ // AND 2$...
154
+ trimLastLeaf();
155
+ switch (match[2].toLowerCase()) {
156
+ case "and":
157
+ branch.nodes.push({
158
+ type: 'joinAnd'
159
+ });
160
+ break;
161
+ case "or":
162
+ branch.nodes.push({
163
+ type: 'joinOr'
164
+ });
165
+ break;
166
+ case "not":
167
+ branch.nodes.push({
168
+ type: 'joinNot'
169
+ });
170
+ break;
171
+ }
172
+ leaf = undefined;
173
+ cropString = false;
174
+ branch.nodes.push({
175
+ type: 'dollarOtherNum',
176
+ ref: [match[3]],
177
+ cond: '',
178
+ nodes: []
179
+ });
180
+ offset += match[1].length;
181
+ q = q.substr(match[1].length);
182
+ } else if (match = /^(\$1)(?:\s+(AND|OR|NOT))?/i.exec(q)) {
183
+ // $1/ $1 AND
143
184
  branch.nodes.push({
144
185
  type: 'dollarOne',
145
- content: match[0].toLowerCase()
186
+ ref: [match[2]],
187
+ cond: match[2] ? match[2].toUpperCase() : '',
188
+ nodes: []
146
189
  });
147
190
  offset += match[0].length;
148
191
  q = q.substr(match[0].length);
149
192
  cropString = false;
150
- } else if (match = /\$[2-9]/.exec(q)) {
151
- // $2 to $9
193
+ } else if (match = /^(AND|OR|NOT)\s+(\$1)/i.exec(q)) {
194
+ // AND 1$
152
195
  branch.nodes.push({
153
- type: 'dollarOtherNum',
154
- content: match[0].toLowerCase()
196
+ type: 'dollarOne',
197
+ ref: [match[2]],
198
+ cond: match[1].toUpperCase(),
199
+ nodes: []
155
200
  });
156
201
  offset += match[0].length;
157
202
  q = q.substr(match[0].length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/polyglot",
3
- "version": "4.8.7",
3
+ "version": "4.8.9",
4
4
  "description": "IEBH-SRA tool to convert between different medical database search formats",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {