concraft 0.14.1 → 0.14.2
raw patch · 2 files changed
+34/−32 lines, 2 filesdep ~crf-chain1-constraineddep ~crf-chain2-tiersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: crf-chain1-constrained, crf-chain2-tiers
API changes (from Hackage documentation)
- NLP.Concraft.DAG.Morphosyntax.Accuracy: [discardProb0] :: AccCfg x -> Bool
- NLP.Concraft.DAG.Disamb: Disamb :: [Tier] -> SchemaConf -> CRF Ob Atom -> t -> Tag -> Disamb t
+ NLP.Concraft.DAG.Disamb: Disamb :: [Tier] -> SchemaConf -> CRF Ob Atom -> (t -> Tag) -> Disamb t
- NLP.Concraft.DAG.Disamb: TrainConf :: [Tier] -> SchemaConf -> SgdArgs -> Bool -> t -> Tag -> TrainConf t
+ NLP.Concraft.DAG.Disamb: TrainConf :: [Tier] -> SchemaConf -> SgdArgs -> Bool -> (t -> Tag) -> TrainConf t
- NLP.Concraft.DAG.DisambSeg: Disamb :: [Tier] -> SchemaConf -> CRF Ob Atom -> t -> Tag -> Disamb t
+ NLP.Concraft.DAG.DisambSeg: Disamb :: [Tier] -> SchemaConf -> CRF Ob Atom -> (t -> Tag) -> Disamb t
- NLP.Concraft.DAG.DisambSeg: TrainConf :: [Tier] -> SchemaConf -> SgdArgs -> Bool -> t -> Tag -> TrainConf t
+ NLP.Concraft.DAG.DisambSeg: TrainConf :: [Tier] -> SchemaConf -> SgdArgs -> Bool -> (t -> Tag) -> TrainConf t
- NLP.Concraft.DAG.Guess: Guesser :: SchemaConf -> CRF Ob s -> s -> Set t -> t -> s -> s -> t -> Guesser t s
+ NLP.Concraft.DAG.Guess: Guesser :: SchemaConf -> CRF Ob s -> s -> Set t -> (t -> s) -> (s -> t) -> Guesser t s
- NLP.Concraft.DAG.Guess: TrainConf :: SchemaConf -> SgdArgs -> Bool -> R0T -> t -> t -> s -> s -> t -> t -> t -> Bool -> TrainConf t s
+ NLP.Concraft.DAG.Guess: TrainConf :: SchemaConf -> SgdArgs -> Bool -> R0T -> t -> (t -> s) -> (s -> t) -> (t -> t) -> Bool -> TrainConf t s
- NLP.Concraft.DAG.Morphosyntax.Accuracy: AccCfg :: Bool -> Bool -> Set x -> Tagset -> Bool -> Bool -> Bool -> Bool -> Bool -> AccCfg x
+ NLP.Concraft.DAG.Morphosyntax.Accuracy: AccCfg :: Bool -> Bool -> Set x -> Tagset -> Bool -> Bool -> Bool -> Bool -> AccCfg x
- NLP.Concraft.DAG.Segmentation: computeAmbiStats :: (Word w) => AmbiCfg -> [Sent w t] -> AmbiStats
+ NLP.Concraft.DAG.Segmentation: computeAmbiStats :: Word w => AmbiCfg -> [Sent w t] -> AmbiStats
- NLP.Concraft.DAG.Segmentation: computeFreqs :: (Word w) => [Sent w t] -> Map Text (Int, Int)
+ NLP.Concraft.DAG.Segmentation: computeFreqs :: Word w => [Sent w t] -> Map Text (Int, Int)
- NLP.Concraft.DAG.Segmentation: findPath :: (Word b) => PathTyp -> DAG a b -> Set EdgeID
+ NLP.Concraft.DAG.Segmentation: findPath :: Word b => PathTyp -> DAG a b -> Set EdgeID
- NLP.Concraft.DAG.Segmentation: pickPath :: (Word b) => PathTyp -> DAG a b -> DAG a b
+ NLP.Concraft.DAG.Segmentation: pickPath :: Word b => PathTyp -> DAG a b -> DAG a b
- NLP.Concraft.DAGSeg: disambPath :: (Ord t) => [(EdgeID, Set t)] -> Anno t Double -> Anno t Bool
+ NLP.Concraft.DAGSeg: disambPath :: Ord t => [(EdgeID, Set t)] -> Anno t Double -> Anno t Bool
- NLP.Concraft.Morphosyntax.WMap: trim :: (Ord a) => Int -> WMap a -> WMap a
+ NLP.Concraft.Morphosyntax.WMap: trim :: Ord a => Int -> WMap a -> WMap a
Files
concraft.cabal view
@@ -1,5 +1,5 @@ name: concraft-version: 0.14.1+version: 0.14.2 synopsis: Morphological disambiguation based on constrained CRFs description: A morphological disambiguation library based on@@ -37,8 +37,8 @@ , monad-ox >= 0.3 && < 0.4 , sgd >= 0.4.0 && < 0.5 , tagset-positional >= 0.3 && < 0.4- , crf-chain1-constrained >= 0.5 && < 0.6- , crf-chain2-tiers >= 0.5 && < 0.6+ , crf-chain1-constrained >= 0.6 && < 0.7+ , crf-chain2-tiers >= 0.6 && < 0.7 , monad-codec >= 0.2 && < 0.3 , data-lens >= 2.10 && < 2.12 , transformers >= 0.2 && < 0.6
src/NLP/Concraft/DAG/Morphosyntax/Accuracy.hs view
@@ -61,9 +61,9 @@ -- ^ If weak, there has to be an overlap in the tags assigned to a given -- segment in both datasets. Otherwise, the two sets of tags have to be -- identical.- , discardProb0 :: Bool- -- ^ Whether sentences with near 0 probability should be discarded from- -- evaluation.+-- , discardProb0 :: Bool+-- -- ^ Whether sentences with near 0 probability should be discarded from+-- -- evaluation. , verbose :: Bool -- ^ Print information about compared elements }@@ -105,14 +105,14 @@ -> Sent w (P.Tag, x) -- ^ Gold (reference) DAG -> Sent w (P.Tag, x) -- ^ Tagged (to compare) DAG -> Stats-goodAndBad cfg dag1 dag2- | discardProb0 cfg && (dagProb dag1 < eps || dagProb dag2 < eps) = zeroStats- | otherwise =- -- By using `DAG.zipE'`, we allow the DAGs to be slighly different in terms- -- of their edge sets.- F.foldl' addStats zeroStats- . DAG.mapE gather- $ dag+goodAndBad cfg dag1 dag2 =+-- | discardProb0 cfg && (dagProb dag1 < eps || dagProb dag2 < eps) = zeroStats+-- | otherwise =+ -- By using `DAG.zipE'`, we allow the DAGs to be slighly different in terms+ -- of their edge sets.+ F.foldl' addStats zeroStats+ . DAG.mapE gather+ $ dag where eps = 1e-9 @@ -226,24 +226,26 @@ ------------------------------------------------------ --- | Compute the probability of the DAG, based on the probabilities assigned to--- different edges and their labels.-dagProb :: Sent w t -> Double-dagProb dag = sum- [ fromEdge edgeID- | edgeID <- DAG.dagEdges dag- , DAG.isInitialEdge edgeID dag ]- where- fromEdge edgeID- = edgeProb edgeID- * fromNode (DAG.endsWith edgeID dag)- edgeProb edgeID =- let Seg{..} = DAG.edgeLabel edgeID dag- in sum . map snd . M.toList $ unWMap tags- fromNode nodeID =- case DAG.outgoingEdges nodeID dag of- [] -> 1- xs -> sum (map fromEdge xs)+-- -- | Compute the probability of the DAG, based on the probabilities assigned to+-- -- different edges and their labels.+-- WARNING: the `dagProb` is most likely not correct, see the `crf-chain1-constrained`+-- library for a correct version.+-- dagProb :: Sent w t -> Double+-- dagProb dag = sum+-- [ fromEdge edgeID+-- | edgeID <- DAG.dagEdges dag+-- , DAG.isInitialEdge edgeID dag ]+-- where+-- fromEdge edgeID+-- = edgeProb edgeID+-- * fromNode (DAG.endsWith edgeID dag)+-- edgeProb edgeID =+-- let Seg{..} = DAG.edgeLabel edgeID dag+-- in sum . map snd . M.toList $ unWMap tags+-- fromNode nodeID =+-- case DAG.outgoingEdges nodeID dag of+-- [] -> 1+-- xs -> sum (map fromEdge xs) -- -- | Filter out the sentences with ~0 probability.