@iebh/polyglot 4.8.8 → 4.9.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.
@@ -319,10 +319,10 @@ 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
326
  switch (engine) {
327
327
  case 'PubMed full':
328
328
  case 'PubMed abbreviation':
@@ -333,7 +333,7 @@ var _default = {
333
333
  buffer += '*';
334
334
  break;
335
335
  case 'Ovid MEDLINE':
336
- buffer += branch.content;
336
+ buffer += '$1';
337
337
  break;
338
338
  case 'Cochrane Library':
339
339
  case 'PsycInfo (Ovid)':
@@ -138,20 +138,54 @@ 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
143
  branch.nodes.push({
144
- type: 'dollarOne',
145
- content: match[0].toLowerCase()
144
+ type: 'dollarOtherNum',
145
+ ref: [match[2]],
146
+ cond: '',
147
+ nodes: []
146
148
  });
147
- offset += match[0].length;
148
- q = q.substr(match[0].length);
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;
149
173
  cropString = false;
150
- } else if (match = /\$[2-9]/.exec(q)) {
151
- // $2 to $9
152
174
  branch.nodes.push({
153
175
  type: 'dollarOtherNum',
154
- content: match[0].toLowerCase()
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)\b/i.exec(q)) {
183
+ // $1
184
+ branch.nodes.push({
185
+ type: 'dollarOne',
186
+ ref: [match[2]],
187
+ cond: match[2] ? match[2].toUpperCase() : '',
188
+ nodes: []
155
189
  });
156
190
  offset += match[0].length;
157
191
  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.8",
3
+ "version": "4.9.0",
4
4
  "description": "IEBH-SRA tool to convert between different medical database search formats",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {