# Duckling mistaking id for datetime

**URL:** <https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475>\
**Category:** Feedback on Rasa Open Source\
**Created:** [September 4, 2021, 11:33am UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475 "2021-09-04T11:33:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polaris000](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/polaris000/32/18422_2.png) [@Polaris000](https://forum.rasa.com/u/Polaris000)\
**Post date:** [September 4, 2021, 11:33am UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/1 "2021-09-04T11:33:46Z")

</div>

In my bot, I’m using CRF for entity extraction along with DIET for intent classification. I’m also using Duckling to extract time-based entities. The issue arises when there’s an entity with MongoDB object ID. What’s happening is that though CRF is correctly extracting the entity, Duckling is sometimes mistaking it to be a datetime.

I tried adding a prefix to the entity and added regex for it. The user message would look like this:

```auto
some_text MONGOID//612a1731af13ee4e235e5ead

```

Duckling sometimes sees this as a datetime. It extracts the “1731” as year, etc. Specifically, this is the result:

```auto
{
	'start': 99,
	'end': 107,
	'text': '612a1731',
	'value': '1731-01-01T06:12:00.000-07:53',
	'confidence': 1.0,
	'additional_info': {
		'values': [{
			'value': '1731-01-01T06:12:00.000-07:53',
			'grain': 'minute',
			'type': 'value'
		}, {
			'value': '1731-01-02T06:12:00.000-07:53',
			'grain': 'minute',
			'type': 'value'
		}, {
			'value': '1731-01-03T06:12:00.000-07:53',
			'grain': 'minute',
			'type': 'value'
		}],
		'value': '1731-01-01T06:12:00.000-07:53',
		'grain': 'minute',
		'type': 'value'
	},
	'entity': 'time',
	'extractor': 'DucklingEntityExtractor'
}

```

My pipeline is this:

```auto
pipeline:
   - name: WhitespaceTokenizer
   - name: RegexFeaturizer
   - name: LexicalSyntacticFeaturizer
   - name: CountVectorsFeaturizer
     analyzer: char_wb
     min_ngram: 1
     max_ngram: 4
   - name: CRFEntityExtractor
     "BILOU_flag": True
     "features": [["low", "title", "upper"],[
      "bias",
      "low",
      "prefix5",
      "prefix2",
      "suffix5",
      "suffix3",
      "suffix2",
      "upper",
      "title",
      "digit",
      "pattern",],["low", "title", "upper"]]
     "max_iterations": 50
     "featurizers": []
   - name: DucklingEntityExtractor
     url: "http://localhost:8000"
     locale: "en_US"
     dimensions: ["time", "duration", "ordinal"]
   - name: DIETClassifier
     epochs: 500
     entity_recognition: False
     constrain_similarities: true
   - name: EntitySynonymMapper
   - name: FallbackClassifier
     threshold: 0.7
     ambiguity_threshold: 0.1

```

Since there’s no issue in my trainable components like CRF or DIET, and I can’t exactly train Duckling, any suggestions for what I can do?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [September 6, 2021, 10:07pm UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/2 "2021-09-06T22:07:04Z")

</div>

If duckling mistaking the entity is the only problem you have, try to add “number” to the dimensions of duckling in the pipeline. This way “1731” will be extracted as a number, not a datetime.

---

<div class="post-metadata">

**Author:** ![Polaris000](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/polaris000/32/18422_2.png) [@Polaris000](https://forum.rasa.com/u/Polaris000)\
**Post date:** [September 7, 2021, 9:43am UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/3 "2021-09-07T09:43:23Z")

</div>

Thanks for responding @Gehova. That would be one solution, but is there some way to prevent Duckling from extracting anything here in the first place? The mongoid above is neither a datetime nor a numeric value.

Can I maybe build a custom component that would pre-extract such entities before Duckling is able to extract an incorrect value?

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [September 7, 2021, 3:49pm UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/4 "2021-09-07T15:49:04Z")

</div>

If the CRT can detect the mongoid correctly you can customize the Duckling component to eliminate the mongoid from the text before sending it to the Duckling server.

---

<div class="post-metadata">

**Author:** ![Polaris000](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/polaris000/32/18422_2.png) [@Polaris000](https://forum.rasa.com/u/Polaris000)\
**Post date:** [September 8, 2021, 4:59am UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/5 "2021-09-08T04:59:29Z")

</div>

That could work. Could you tell me how I can go about doing this?

---

<div class="post-metadata">

**Author:** ![Polaris000](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/polaris000/32/18422_2.png) [@Polaris000](https://forum.rasa.com/u/Polaris000)\
**Post date:** [September 18, 2021, 11:19am UTC](https://forum.rasa.com/t/duckling-mistaking-id-for-datetime/47475/6 "2021-09-18T11:19:22Z")

</div>

Hey @Gehova . Could you get back to me on this? Thanks.
