facebook / facebook/duckling

Chinese Time-Interval not work

Open
#744 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
4.3k
Forks
739
PR merge metrics
No merged PRs in 30d

Description

time request with lang en_US

request

curl --location 'http://0.0.0.0:8000/parse' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'locale=en_US' \
--data-urlencode 'text="today 2PM to today 3PM"' \
--data-urlencode 'dims="["time"]"'

response

[
    {
        "body": "today 2PM to today 3PM",
        "start": 1,
        "value": {
            "values": [
                {
                    "to": {
                        "value": "2024-12-03T16:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "from": {
                        "value": "2024-12-03T14:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "type": "interval"
                }
            ],
            "to": {
                "value": "2024-12-03T16:00:00.000-08:00",
                "grain": "hour"
            },
            "from": {
                "value": "2024-12-03T14:00:00.000-08:00",
                "grain": "hour"
            },
            "type": "interval"
        },
        "end": 23,
        "dim": "time",
        "latent": false
    }
]

time request with lang zh_CN

request

curl --location 'http://0.0.0.0:8000/parse' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'locale=zh_CN' \
--data-urlencode 'text="明天下午2点到明天下午3点"' \
--data-urlencode 'dims="["time"]"'

response

[
    {
        "body": "明天下午2点",
        "start": 1,
        "value": {
            "values": [
                {
                    "value": "2024-12-04T14:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                }
            ],
            "value": "2024-12-04T14:00:00.000-08:00",
            "grain": "hour",
            "type": "value"
        },
        "end": 7,
        "dim": "time",
        "latent": false
    },
    {
        "body": "明天下午3点",
        "start": 8,
        "value": {
            "values": [
                {
                    "value": "2024-12-04T15:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                }
            ],
            "value": "2024-12-04T15:00:00.000-08:00",
            "grain": "hour",
            "type": "value"
        },
        "end": 14,
        "dim": "time",
        "latent": false
    }
]

expected response

[
    {
        "body": "明天下午2点到明天下午3点",
        "start": 1,
        "value": {
            "values": [
                {
                    "to": {
                        "value": "2024-12-04T16:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "from": {
                        "value": "2024-12-04T14:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "type": "interval"
                }
            ],
            "to": {
                "value": "2024-12-04T16:00:00.000-08:00",
                "grain": "hour"
            },
            "from": {
                "value": "2024-12-04T14:00:00.000-08:00",
                "grain": "hour"
            },
            "type": "interval"
        },
        "end": 23,
        "dim": "time",
        "latent": false
    }
]

request

curl --location 'http://0.0.0.0:8000/parse' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'locale=zh_CN' \
--data-urlencode 'text="明天上午9点到明天上午11点"' \
--data-urlencode 'dims="["time"]"'

response

[
    {
        "body": "明天",
        "start": 1,
        "value": {
            "values": [
                {
                    "value": "2024-12-04T00:00:00.000-08:00",
                    "grain": "day",
                    "type": "value"
                }
            ],
            "value": "2024-12-04T00:00:00.000-08:00",
            "grain": "day",
            "type": "value"
        },
        "end": 3,
        "dim": "time",
        "latent": false
    },
    {
        "body": "9点",
        "start": 5,
        "value": {
            "values": [
                {
                    "value": "2024-12-03T09:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                },
                {
                    "value": "2024-12-03T21:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                },
                {
                    "value": "2024-12-04T09:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                }
            ],
            "value": "2024-12-03T09:00:00.000-08:00",
            "grain": "hour",
            "type": "value"
        },
        "end": 7,
        "dim": "time",
        "latent": false
    },
    {
        "body": "明天",
        "start": 8,
        "value": {
            "values": [
                {
                    "value": "2024-12-04T00:00:00.000-08:00",
                    "grain": "day",
                    "type": "value"
                }
            ],
            "value": "2024-12-04T00:00:00.000-08:00",
            "grain": "day",
            "type": "value"
        },
        "end": 10,
        "dim": "time",
        "latent": false
    },
    {
        "body": "11点",
        "start": 12,
        "value": {
            "values": [
                {
                    "value": "2024-12-03T11:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                },
                {
                    "value": "2024-12-03T23:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                },
                {
                    "value": "2024-12-04T11:00:00.000-08:00",
                    "grain": "hour",
                    "type": "value"
                }
            ],
            "value": "2024-12-03T11:00:00.000-08:00",
            "grain": "hour",
            "type": "value"
        },
        "end": 15,
        "dim": "time",
        "latent": false
    }
]

expected response

[
    {
        "body": "明天上午9点到明天上午11点",
        "start": 1,
        "value": {
            "values": [
                {
                    "to": {
                        "value": "2024-12-04T09:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "from": {
                        "value": "2024-12-04T11:00:00.000-08:00",
                        "grain": "hour"
                    },
                    "type": "interval"
                }
            ],
            "to": {
                "value": "2024-12-04T09:00:00.000-08:00",
                "grain": "hour"
            },
            "from": {
                "value": "2024-12-04T11:00:00.000-08:00",
                "grain": "hour"
            },
            "type": "interval"
        },
        "end": 23,
        "dim": "time",
        "latent": false
    }
]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the zh_CN /parse requests first, then trace the locale's time parsing and interval-combination rules. Done means both Chinese examples produce one interval entity with the expected endpoints, matching the existing en_US behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
internationalization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.