diff --git a/src/Roux.hs b/src/Roux.hs index 792fd66..b302cbd 100644 --- a/src/Roux.hs +++ b/src/Roux.hs @@ -4,5 +4,5 @@ module Roux ( module X, ) where -import Roux.Server (app) import Data.CookLang as X +import Roux.Server (app) diff --git a/src/Roux/Html.hs b/src/Roux/Html.hs index f2a6b77..813c5b8 100644 --- a/src/Roux/Html.hs +++ b/src/Roux/Html.hs @@ -28,8 +28,8 @@ import qualified Text.Blaze.Html.Renderer.Utf8 as R import Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes as A -import qualified Roux.RecipeIndex as Idx import Data.CookLang +import qualified Roux.RecipeIndex as Idx -- --------------------------------------------------------------------------- -- Sort mode for the index page diff --git a/src/Roux/NYTimes.hs b/src/Roux/NYTimes.hs index c893860..2a81522 100644 --- a/src/Roux/NYTimes.hs +++ b/src/Roux/NYTimes.hs @@ -254,8 +254,9 @@ ingredientGroupToSection group = , sectionBody = SecStep step :| [] } --- | Convert a single NYT ingredient into Cooklang step items. --- Produces something like: @ingredient{quantity} — rest of description +{- | Convert a single NYT ingredient into Cooklang step items. +Produces something like: @ingredient{quantity} — rest of description +-} ingredientToStepItems :: NYTIngredientItem -> [StepItem] ingredientToStepItems item = let quantity = nytIngredientQuantity item @@ -265,7 +266,9 @@ ingredientToStepItems item = name = extractIngredientName fullText qty = parseNYTQuantity quantity in if T.null quantity - then [ StepText ", ", StepIngredient (Ingredient (simplifyText fullText) Nothing Nothing) + then + [ StepText ", " + , StepIngredient (Ingredient (simplifyText fullText) Nothing Nothing) ] else [ StepText ", " @@ -334,21 +337,47 @@ parseNYTQuantity t } Nothing -> Nothing --- | Try to extract the core ingredient name from a descriptive text. --- E.g. @"tablespoons neutral oil, like canola or grapeseed"@ -> @"oil"@ --- This is a heuristic; for complex cases the full text is used. +{- | Try to extract the core ingredient name from a descriptive text. +E.g. @"tablespoons neutral oil, like canola or grapeseed"@ -> @"oil"@ +This is a heuristic; for complex cases the full text is used. +-} extractIngredientName :: Text -> Text extractIngredientName t = let cleaned = simplifyText t toks = T.words cleaned -- Filter out common unit/quantity words to find the core ingredient skipWords = - [ "tablespoons", "tablespoon", "teaspoons", "teaspoon" - , "cups", "cup", "ounces", "ounce", "pounds", "pound" - , "grams", "gram", "cloves", "clove", "slices", "slice" - , "large", "medium", "small", "fresh", "dried", "minced" - , "chopped", "diced", "peeled", "grated", "crushed" - , "ground", "whole", "skinless", "boneless" + [ "tablespoons" + , "tablespoon" + , "teaspoons" + , "teaspoon" + , "cups" + , "cup" + , "ounces" + , "ounce" + , "pounds" + , "pound" + , "grams" + , "gram" + , "cloves" + , "clove" + , "slices" + , "slice" + , "large" + , "medium" + , "small" + , "fresh" + , "dried" + , "minced" + , "chopped" + , "diced" + , "peeled" + , "grated" + , "crushed" + , "ground" + , "whole" + , "skinless" + , "boneless" ] meaningful = dropWhile (`elem` skipWords) toks in case meaningful of @@ -377,7 +406,7 @@ breakOn delim t = _ -> (t, T.empty) -- | Simple read wrapper. -readMaybe :: Read a => String -> Maybe a +readMaybe :: (Read a) => String -> Maybe a readMaybe s = case reads s of [(x, "")] -> Just x _ -> Nothing diff --git a/src/Roux/RecipeIndex.hs b/src/Roux/RecipeIndex.hs index 3ac4904..f9a4501 100644 --- a/src/Roux/RecipeIndex.hs +++ b/src/Roux/RecipeIndex.hs @@ -9,8 +9,8 @@ import qualified Data.Text as T import System.Directory (listDirectory) import System.FilePath (takeBaseName, takeExtension, ()) -import Roux.Parser (parseCookFile) import Data.CookLang +import Roux.Parser (parseCookFile) -- | Metadata about a single recipe discovered on disk. data RecipeInfo = RecipeInfo diff --git a/src/Roux/Types.hs b/src/Roux/Types.hs index e175cfa..89feac5 100644 --- a/src/Roux/Types.hs +++ b/src/Roux/Types.hs @@ -1,5 +1,4 @@ -{- | Re-exports all types from 'Data.CookLang' for backward compatibility. --} +-- | Re-exports all types from 'Data.CookLang' for backward compatibility. module Roux.Types (module X) where import Data.CookLang as X diff --git a/test/Roux/NYTimesSpec.hs b/test/Roux/NYTimesSpec.hs index 34f29f1..b422f9a 100644 --- a/test/Roux/NYTimesSpec.hs +++ b/test/Roux/NYTimesSpec.hs @@ -3,8 +3,8 @@ module Roux.NYTimesSpec (spec) where import qualified Data.Text.IO as TIO import Test.Hspec (Spec, describe, it, shouldBe, shouldSatisfy) -import Roux.NYTimes import Data.CookLang +import Roux.NYTimes spec :: Spec spec = do diff --git a/test/Roux/ParserSpec.hs b/test/Roux/ParserSpec.hs index 9125dd2..9fff363 100644 --- a/test/Roux/ParserSpec.hs +++ b/test/Roux/ParserSpec.hs @@ -6,8 +6,8 @@ import Data.Ratio ((%)) import qualified Data.Text.IO as TIO import Test.Hspec (Spec, describe, expectationFailure, it, shouldBe) -import Roux.Parser (parseCookFile) import Data.CookLang +import Roux.Parser (parseCookFile) spec :: Spec spec = do