Skip to content

Commit

Permalink
refactor: SKK辞書の註釈削除処理を関数として抽出
Browse files Browse the repository at this point in the history
  • Loading branch information
emanon001 committed Mar 12, 2023
1 parent b14a2c3 commit e6c66cd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/SkkDict.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ fromDictString dictStr =
_ :: [] ->
Nothing

key :: henkanList ->
key :: conversionList ->
Just
( String.trim key
, List.map (String.split ";" >> List.head) henkanList
|> List.map (Maybe.withDefault "")
, List.map removeAnnotation conversionList
|> Maybe.Extra.values
|> List.filter (not << String.isEmpty)
)

_ ->
Nothing

removeAnnotation : String -> Maybe String
removeAnnotation s =
(String.split ";" >> List.head) s

buildDict : List String -> SkkDict
buildDict lines =
List.filterMap toEntry lines |> Dict.fromList
Expand Down

0 comments on commit e6c66cd

Please sign in to comment.