Skip to content

Commit

Permalink
fix(temperature): end parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaudiuCeia committed Jul 22, 2022
1 parent b384957 commit 3482064
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Temperature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
space,
skip1,
} from "combine/mod.ts";
import { EntityLanguage, __ } from "./common.ts";
import { EntityLanguage, __, dot } from "./common.ts";
import { ent, Entity } from "./Entity.ts";
import { Quantity, QuantityEntity } from "./Quantity.ts";

Expand Down Expand Up @@ -122,5 +122,5 @@ export const Temperature = createLanguage<TemperatureEntityLanguage>({
a
)
),
parser: (s) => any(s.BelowZero, s.Celsius, s.Fahrenheit, s.Unspecified),
parser: (s) => dot(any(s.BelowZero, s.Celsius, s.Fahrenheit, s.Unspecified)),
});
23 changes: 23 additions & 0 deletions tests/Temperature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,26 @@ Deno.test("below zero", () => {
]);
}
});

Deno.test("No false positive for temperature", () => {
const res = Duckling().extract({
text: `In 1837 Charles Babbage first described his Analytical Engine`,
index: 0,
});

assertEquals(res.success, true);

if (res.success) {
assertEquals(res.value, [
{
end: 7,
kind: "quantity",
start: 3,
text: "1837",
value: {
amount: 1837,
},
},
]);
}
});

0 comments on commit 3482064

Please sign in to comment.