Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parse(query: string, referenceDate: Date = new Date()): ModelResult[] {
query = QueryProcessor.preProcess(query);
let parseDates = new Array();
try {
let extractResults = this.extractor.extract(query, referenceDate);
for (let result of extractResults) {
let parseResult = this.parser.parse(result, referenceDate);
if (Array.isArray(parseResult.value)) {
parseDates.push(...parseResult.value);
}
else {
parseDates.push(parseResult);
}
}
}
catch (err) {
// Nothing to do. Exceptions in parse should not break users of recognizers.
parse(query: string): ModelResult[] {
let parseResults = new Array();
query = QueryProcessor.preProcess(query);
try {
let extractResults = this.extractor.extract(query);
parseResults = extractResults.map(r => this.parser.parse(r));
}
catch (err) {
// Nothing to do. in result process should not affect other extracted entities.
// No result.
}
finally {
return parseResults
.map(o => o as ParseResult)
.map(o => ({
start: o.start,
end: o.start + o.length - 1,
resolution: {
parse(query: string): ModelResult[] {
query = QueryProcessor.preProcess(query, true);
let parseNums: ParseResult[];
try {
let extractResults = this.extractor.extract(query);
parseNums = extractResults.map(r => this.parser.parse(r));
}
catch (err) {
// Nothing to do. Exceptions in result process should not affect other extracted entities.
// No result.
}
finally {
return parseNums
.map(o => o as ParseResult)
.map(o => ({
start: o.start,
end: o.start + o.length - 1,
parse(query: string): ModelResult[] {
query = QueryProcessor.preProcess(query, true);
let extractionResults = new Array();
try {
for (let kv of this.extractorParsersMap.entries()) {
let extractor = kv[0];
let parser = kv[1];
let extractResults = extractor.extract(query);
let parseResults: ParseResult[] = [];
for (let i = 0; i < extractResults.length; i++) {
let r = parser.parse(extractResults[i]);
if (r.value !== null) {
if (r.value instanceof Array) {
for (let j = 0; j < r.value.length; j++) {
parseResults.push(r.value[j]);
}