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 qualified Data.Map.Strict as Map
|
||||
import Unused.Util (groupBy)
|
||||
import Unused.Types (ParseResponse, TermMatch, resultsFromMatches, tmTerm)
|
||||
import Unused.Types (ParseResponse, TermMatchSet, TermMatch, resultsFromMatches, tmTerm)
|
||||
import Unused.LikelihoodCalculator
|
||||
import Unused.Parser.Internal
|
||||
|
||||
parseLines :: [LanguageConfiguration] -> String -> ParseResponse
|
||||
parseLines lcs =
|
||||
responseFromParse lcs . parse parseTermMatches "matches"
|
||||
fmap (matchesToMatchSet lcs) . parse parseTermMatches "matches"
|
||||
|
||||
responseFromParse :: [LanguageConfiguration] -> Either ParseError [TermMatch] -> ParseResponse
|
||||
responseFromParse lcs =
|
||||
fmap $ Map.fromList . map (second $ calculateLikelihood lcs . resultsFromMatches) . groupBy tmTerm
|
||||
matchesToMatchSet :: [LanguageConfiguration] -> [TermMatch] -> TermMatchSet
|
||||
matchesToMatchSet lcs =
|
||||
Map.fromList . map (second $ calculateLikelihood lcs . resultsFromMatches) . groupBy tmTerm
|
||||
|
Loading…
Reference in New Issue
Block a user