colada 0.7.0.0 → 0.8.0.0
raw patch · 2 files changed
+18/−10 lines, 2 filesdep ~swift-lda
Dependency ranges changed: swift-lda
Files
- Colada/WordClass.hs +15/−7
- colada.cabal +3/−3
Colada/WordClass.hs view
@@ -180,14 +180,20 @@ (get topicNum opts) (get alphasum opts) (get beta opts)- (get exponent opts)- Fold.forM_ bs $ \b -> do+ Fold.forM_ bs $ \b -> do + _ <- ST.stToIO . LDA.run m (get passes opts) . Fold.msum $ b + when (get progressive opts) $ do+ Fold.forM_ b $ \sent -> do+ ls <- ST.stToIO $ V.mapM (interpWordClasses m (get lambda opts)) sent+ f ls+ {- Fold.forM_ [1..get passes opts] $ \i -> do Fold.forM_ b $ \sent -> do _ <- ST.stToIO $ LDA.pass 1 m sent when (get progressive opts && i == get passes opts) $ do ls <- ST.stToIO $ V.mapM (interpWordClasses m (get lambda opts)) sent f ls+-} ST.stToIO $ LDA.finalize m lda <- sampler return (WordClass lda atomTabD atomTabW opts)@@ -219,7 +225,8 @@ where doc (d, ws) = do da <- Symbols.toAtomA . compress $ d was <- mapM (Symbols.toAtomB . compress) ws- return (da, U.fromList $ zip was (repeat Nothing))+ --return (da, U.fromList $ zip was (repeat Nothing))+ return (da, U.fromList was) -- | @summary m@ returns a textual summary of word classes found in -- model @m@@@ -259,8 +266,9 @@ -- | @interpWordClasses m lambda doc@ gives the class probabilities for -- word type in context @doc@ according to evolving model @m@. It -- interpolates the prior word type probability with the--- context-conditioned probabilities using alpha: --- P(d,w) = lambda * P(z|d) + (1-lambda) * P(z|d,w)+-- context-conditioned probabilities using lambda: +-- P(d,w) = lambda * P(z|d) + (1-lambda) * P(z|d,w).+-- This function does not mutate any weights of the model. interpWordClasses :: LDA.LDA s -> Double -> LDA.Doc @@ -296,7 +304,7 @@ (L.get wordTypeTable m) (L.get featureTable m) where dectx doc@(d, _) = if noctx - then (d, U.singleton (-1,Nothing)) --FIXME: ugly hack+ then (d, U.singleton (-1)) --FIXME: ugly hack else doc label' = do let fm = L.get ldaModel m@@ -319,7 +327,7 @@ . V.toList $ s' mapM (V.mapM fromAtom) ws- docToWs = U.map fst . snd+ docToWs = snd fromAtom (n,w) = do w' <- Symbols.fromAtomA w return (n, decompress w')
colada.cabal view
@@ -1,5 +1,5 @@ Name: colada-Version: 0.7.0.0+Version: 0.8.0.0 Synopsis: Colada implements incremental word class class induction using online LDA Description: Colada implements incremental word class class induction using @@ -27,7 +27,7 @@ , cmdargs >= 0.9 , bytestring >= 0.9 , mtl >= 2.0- , swift-lda >= 0.4 && <= 0.5+ , swift-lda >= 0.7 && < 0.8 Exposed-modules: Colada.WordClass , NLP.CoNLL Other-modules: Colada.Features@@ -50,7 +50,7 @@ , cmdargs >= 0.9 , bytestring >= 0.9 , mtl >= 2.0- , swift-lda >= 0.4 && <= 0.5+ , swift-lda >= 0.7 && < 0.8 Other-modules: Colada.WordClass , Colada.Features , NLP.CoNLL