mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Operate on purer data sets
This commit is contained in:
parent
db10b79f93
commit
fb1198dc2f
@ -6,14 +6,14 @@ module Unused.Parser
|
|||||||
import Data.Bifunctor (second)
|
import Data.Bifunctor (second)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Unused.Util (groupBy)
|
import Unused.Util (groupBy)
|
||||||
import Unused.Types (ParseResponse, TermMatch, resultsFromMatches, tmTerm)
|
import Unused.Types (ParseResponse, TermMatchSet, TermMatch, resultsFromMatches, tmTerm)
|
||||||
import Unused.LikelihoodCalculator
|
import Unused.LikelihoodCalculator
|
||||||
import Unused.Parser.Internal
|
import Unused.Parser.Internal
|
||||||
|
|
||||||
parseLines :: [LanguageConfiguration] -> String -> ParseResponse
|
parseLines :: [LanguageConfiguration] -> String -> ParseResponse
|
||||||
parseLines lcs =
|
parseLines lcs =
|
||||||
responseFromParse lcs . parse parseTermMatches "matches"
|
fmap (matchesToMatchSet lcs) . parse parseTermMatches "matches"
|
||||||
|
|
||||||
responseFromParse :: [LanguageConfiguration] -> Either ParseError [TermMatch] -> ParseResponse
|
matchesToMatchSet :: [LanguageConfiguration] -> [TermMatch] -> TermMatchSet
|
||||||
responseFromParse lcs =
|
matchesToMatchSet lcs =
|
||||||
fmap $ Map.fromList . map (second $ calculateLikelihood lcs . resultsFromMatches) . groupBy tmTerm
|
Map.fromList . map (second $ calculateLikelihood lcs . resultsFromMatches) . groupBy tmTerm
|
||||||
|
Loading…
Reference in New Issue
Block a user