{-# LANGUAGE OverloadedStrings #-}
module NLP.Minimorph.Util
( tTakeEnd, tDropEnd, (<>), (<+>), tshow )
where
import Data.Monoid ((<>))
import Data.Text (Text)
import qualified Data.Text as T
tTakeEnd :: Int -> Text -> Text
tTakeEnd n t = T.drop (T.length t - n) t
tDropEnd :: Int -> Text -> Text
tDropEnd n x = T.take (T.length x - n) x
infixr 6 <+>
(<+>) :: Text -> Text -> Text
t1 <+> t2 | T.null t1 = t2
| T.null t2 = t1
| otherwise = t1 <> " " <> t2
tshow :: Show a => a -> Text
tshow = T.pack . show