@iebh/polyglot 4.8.8 → 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,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':
|
package/lib/modules/parse.js
CHANGED
|
@@ -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 =
|
|
142
|
-
// $
|
|
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
|
-
|
|
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 =
|
|
151
|
-
//
|
|
193
|
+
} else if (match = /^(AND|OR|NOT)\s+(\$1)/i.exec(q)) {
|
|
194
|
+
// AND 1$
|
|
152
195
|
branch.nodes.push({
|
|
153
|
-
type: '
|
|
154
|
-
|
|
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);
|