Skip to content

Commit

Permalink
Email: restrict domain extensions to letters when spelling out
Browse files Browse the repository at this point in the history
Summary: We would parse things like "tonight at 6.40".

Reviewed By: blandinw

Differential Revision: D6066926

fbshipit-source-id: d18a8c6
  • Loading branch information
patapizza authored and facebook-github-bot committed Oct 16, 2017
1 parent 305358b commit 0e95062
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Duckling/Email/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module Duckling.Email.Corpus
, negativeCorpus
) where

import Prelude
import Data.String
import Prelude

import Duckling.Email.Types
import Duckling.Testing.Types
Expand Down
10 changes: 10 additions & 0 deletions Duckling/Email/EN/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

module Duckling.Email.EN.Corpus
( corpus
, negativeCorpus
) where

import Data.String
Expand All @@ -18,6 +19,15 @@ import Prelude
import Duckling.Email.Types
import Duckling.Testing.Types

negativeCorpus :: NegativeCorpus
negativeCorpus = (testContext, examples)
where
examples =
[ "fitness at 6.40"
, "class at 12.00"
, "tonight at 9.15"
]

corpus :: Corpus
corpus = (testContext, allExamples)

Expand Down
6 changes: 3 additions & 3 deletions Duckling/Email/EN/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ module Duckling.Email.EN.Rules
( rules ) where

import Data.String
import qualified Data.Text as Text
import Prelude
import qualified Data.Text as Text

import Duckling.Dimensions.Types
import Duckling.Email.Types (EmailData (..))
import qualified Duckling.Email.Types as TEmail
import Duckling.Regex.Types
import Duckling.Types
import qualified Duckling.Email.Types as TEmail

ruleEmailSpelledOut :: Rule
ruleEmailSpelledOut = Rule
{ name = "email spelled out"
, pattern =
[ regex "([\\w\\._+-]+) at ([\\w_-]+(\\.[\\w_-]+)+)"
[ regex "([\\w\\._+-]+) at ([\\w_-]+(\\.[a-zA-Z]+)+)"
]
, prod = \xs -> case xs of
(Token RegexMatch (GroupMatch (m1:m2:_)):_) ->
Expand Down
1 change: 1 addition & 0 deletions tests/Duckling/Email/EN/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ import Duckling.Testing.Asserts
tests :: TestTree
tests = testGroup "Email Tests"
[ makeCorpusTest [This Email] corpus
, makeNegativeCorpusTest [This Email] negativeCorpus
]

0 comments on commit 0e95062

Please sign in to comment.