Numbers & Time
Extracts values of numbers, dates and times, along with the corresponding span in the text. Also identifies the number type (Money, Quantity, Ordinals, etc.) and the Date/Time type (Date, Duration, Time)
I bought this land DATE
{
"date_time": "2012-08-17T00:00",
"timezone": "US/Eastern",
"precision": "DAY"
}
ten years ago for MONEY two thousands bucks. DATE Now I can sell it for MONEY a hundred grand.
"date_time": "2012-08-17T00:00",
"timezone": "US/Eastern",
"precision": "DAY"
}
Use Numbers & Time Skill to extract numbers and time from:
Benchmarks
Coming soon...
Output labels
Date & Time labels
- DATE - Specific date & time: "let's meet next Monday at 3pm"->'2022-09-02T15:00'
- TIME - Specific time, with unspecified date: "let's meet at 3pm"->'15:00'
- DURATION - A time duration, unspecified date or time: "let's meet for 3 hours"->'0.3:00:00'
Numbers labels
Parameters
Name | Type | Description | Default |
---|---|---|---|
reference_time | yyyy-mm-ddTHH:MM formatted string | The time & date are used for relative dates calculations. For example, if reference_time is set to January 1st, 1990, then any mention of tomorrow will be calculated as January 2nd, 1990. | The current date & time will be used |
Request
curl -X POST \
'https://api.oneai.com/api/v0/pipeline' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'api-key: <YOUR-API-KEY-HERE>' \
-d '{
"input": "I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand.",
"input_type": "article",
"steps": [
{
"skill": "numbers"
}
]
}'
const { OneAI } = require("oneai");
const oneai = new OneAI("<YOUR-API-KEY-HERE>");
const text = "I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand.";
const pipeline = new oneai.Pipeline(
oneai.skills.numbers(),
);
pipeline.run(text).then(console.log);
import oneai
oneai.api_key = "<YOUR-API-KEY-HERE>"
text = "I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand."
pipeline = oneai.Pipeline(
steps = [
oneai.skills.Numbers(),
]
)
output = pipeline.run(text)
Response
{
"input_text": "I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand.",
"status": "success",
"output": [
{
"text_generated_by_step_name": "input",
"text_generated_by_step_id": 0,
"text": "I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand.",
"labels": [
{
"type": "number",
"skill": "numbers",
"name": "DATE",
"value": "2012-08-17",
"data": {
"date_time": "2012-08-17T00:00",
"timezone": null,
"precision": "DAY"
},
"span_text": "ten years ago",
"span": [
19,
32
],
"output_spans": [
{
"section": 0,
"start": 19,
"end": 32
}
]
},
{
"type": "number",
"skill": "numbers",
"name": "MONEY",
"value": "2",
"data": {
"numeric_value": 2
},
"span_text": "two thousands bucks",
"span": [
37,
56
],
"output_spans": [
{
"section": 0,
"start": 37,
"end": 56
}
]
},
{
"type": "number",
"skill": "numbers",
"name": "DATE",
"value": "2022-08-17",
"data": {
"date_time": "2022-08-17T00:00",
"timezone": null,
"precision": "DAY"
},
"span_text": "Now",
"span": [
58,
61
],
"output_spans": [
{
"section": 0,
"start": 58,
"end": 61
}
]
},
{
"type": "number",
"skill": "numbers",
"name": "MONEY",
"value": "1,100",
"data": {
"numeric_value": 1100
},
"span_text": "a hundred grand",
"span": [
80,
95
],
"output_spans": [
{
"section": 0,
"start": 80,
"end": 95
}
]
}
]
}
],
"stats": {
"concurrency_wait_time": 0,
"total_running_jobs": 1,
"total_waiting_jobs": 0
}
}
{
text: 'I bought this land ten years ago for two thousands bucks. Now I can sell it for a hundred grand.',
numbers: [
{
type: 'number',
skill: 'numbers',
name: 'DATE',
value: '2012-08-23',
data: {
date_time: '2012-08-23T00:00',
timezone: null,
precision: 'DAY'
},
span_text: 'ten years ago',
span: [ 19, 32 ],
output_spans: [ { section: 0, start: 19, end: 32 } ]
},
{
type: 'number',
skill: 'numbers',
name: 'MONEY',
value: '2',
data: { numeric_value: 2 },
span_text: 'two thousands bucks',
span: [ 37, 56 ],
output_spans: [ { section: 0, start: 37, end: 56 } ]
},
{
type: 'number',
skill: 'numbers',
name: 'DATE',
value: '2022-08-23',
data: {
date_time: '2022-08-23T00:00',
timezone: null,
precision: 'DAY'
},
span_text: 'Now',
span: [ 58, 61 ],
output_spans: [ { section: 0, start: 58, end: 61 } ]
},
{
type: 'number',
skill: 'numbers',
name: 'MONEY',
value: '1,100',
data: { numeric_value: 1100 },
span_text: 'a hundred grand',
span: [ 80, 95 ],
output_spans: [ { section: 0, start: 80, end: 95 } ]
}
]
}
Updated about 1 month ago