-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade dictionary implementation in core (#297)
- Loading branch information
1 parent
9e212c9
commit a322f9b
Showing
16 changed files
with
2,561 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(ns acc-text.nlg.dictionary.impl | ||
(:require [acc-text.nlg.dictionary.item :as dict-item] | ||
[acc-text.nlg.dictionary.lang.eng :as eng] | ||
[acc-text.nlg.dictionary.lang.other :as other])) | ||
|
||
(defmulti resolve-dict-item ::dict-item/language) | ||
|
||
(defmethod resolve-dict-item "Eng" [dict-item] | ||
(eng/resolve-dict-item dict-item)) | ||
|
||
(defmethod resolve-dict-item :default [dict-item] | ||
(other/resolve-dict-item dict-item)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(ns acc-text.nlg.dictionary.lang.other | ||
(:require [acc-text.nlg.dictionary.item :as dict-item] | ||
[acc-text.nlg.dictionary.item.form :as dict-item-form] | ||
[clojure.string :as str])) | ||
|
||
(defn escape-string [s] | ||
(str/replace s #"\"" "\\\\\"")) | ||
|
||
(defn join-forms [forms] | ||
(->> forms | ||
(map #(format "\"%s\"" (escape-string (::dict-item-form/value %)))) | ||
(str/join " "))) | ||
|
||
(defmulti resolve-dict-item (fn [{::dict-item/keys [language category]}] | ||
(str/join "/" [language category]))) | ||
|
||
(defmethod resolve-dict-item :default [{::dict-item/keys [language category]}] | ||
(throw (Exception. (format "Don't know how to resolve dictionary item category `%s` for language `%s`" category language)))) | ||
|
||
(defmethod resolve-dict-item "Spa/N" [{::dict-item/keys [forms attributes]}] | ||
(if (contains? attributes "Gender") | ||
(format "(ParadigmsSpa.mkN %s ParadigmsSpa.%s)" (join-forms forms) (get attributes "Gender")) | ||
(format "(ParadigmsSpa.mkN %s)" (join-forms forms)))) | ||
|
||
(defmethod resolve-dict-item "Spa/V" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsSpa.mkV %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Spa/A" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsSpa.mkA %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Spa/Adv" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsSpa.mkAdv %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Spa/AdV" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsSpa.mkAdV %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Ger/V" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsGer.mkV %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Rus/A" [{::dict-item/keys [forms]}] | ||
(format "(ParadigmsRus.mkA %s)" (join-forms forms))) | ||
|
||
(defmethod resolve-dict-item "Rus/N" [{::dict-item/keys [forms attributes]}] | ||
(format "(ParadigmsRus.mkN %s MorphoRus.%s MorphoRus.%s)" | ||
(join-forms (if (= 1 (count forms)) (repeat 13 (first forms)) forms)) | ||
(get attributes "Gender" "Masc") | ||
(get attributes "Animacy" "Inanimate"))) | ||
|
||
(defmethod resolve-dict-item "Rus/V" [{::dict-item/keys [forms attributes]}] | ||
(format "(ParadigmsRus.mkV MorphoRus.%s %s)" (get attributes "Aspect") (join-forms forms))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.