Skip to content

Commit

Permalink
buck rules for regenerating classifiers + support dir prefix
Browse files Browse the repository at this point in the history
Summary: as title

Reviewed By: kamaljoshi

Differential Revision: D61641528

fbshipit-source-id: 8628dae4d62688bae38b038c00754ec0325f0e3b
  • Loading branch information
Julien Odent authored and facebook-github-bot committed Aug 22, 2024
1 parent 99b8c69 commit 6f9bff5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions exe/Duckling/Ranking/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Duckling.Ranking.Generate
import Data.HashSet (HashSet)
import Language.Haskell.Exts as F
import Prelude
import System.Environment (getArgs)
import qualified Data.HashMap.Strict as HashMap
import qualified Data.HashSet as HashSet
import qualified Data.Text as Text
Expand Down Expand Up @@ -87,9 +88,19 @@ regenLangClassifiers lang = do
mapM_ (regenClassifiers . makeLocale lang . Just)
$ HashMap.lookupDefault HashSet.empty lang allLocales

getPath :: String -> IO (String)
getPath moduleName = do
args <- getArgs
let
prefix = case args of
[] -> ""
(x:_) -> (x :: String)
return $ prefix ++ "Duckling/Ranking/Classifiers/" ++ moduleName ++ ".hs"

-- | Run this function to overwrite the file with Classifiers data
regenClassifiers :: Locale -> IO ()
regenClassifiers locale = do
filepath <- getPath moduleName
putStrLn $ "Regenerating " ++ filepath ++ "..."
writeFile filepath $
(headerComment ++) $
Expand All @@ -98,8 +109,6 @@ regenClassifiers locale = do
where
moduleName = show locale

filepath = "Duckling/Ranking/Classifiers/" ++ moduleName ++ ".hs"

rules = rulesFor locale . HashSet.singleton $ Seal Time

-- | The trained classifier to write out
Expand Down

0 comments on commit 6f9bff5

Please sign in to comment.