Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added inThe operator at a higher level #2473

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/drasil-utils/Utils/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ module Utils.Drasil (
-- Phrase
and_, and_', andRT, compoundNC, compoundNC', compoundNC'', compoundNC''',
compoundNCP1, compoundNCPlPh, for, for', of_, of_',
of_'', of__, ofA, ofN_, the, the', the'', with, ofThe',
of_'', of__, ofA, ofN_, the, the', the'', inThe', with, ofThe',
-- Sentence
--andIts, andThe, fromThe, inThe, isExpctdToHv, isThe, ofGiv, ofGiv', ofThe, the_ofThe, the_ofThe',
--sOf, sOfA, sOr, sVersus, sAnd, sAre, sIn, sIs, toThe, sFor, sFor', sFor'', forTT, forTT'
-- Concepts
insertStringNP, prependStringNP, insertSentNP, prependSentNP,
theNP, theNP', aNP, aNP', ofTheNP, ofTheNP', ofTheNP'', the_ofTheNP, the_ofTheNP', the_ofTheNP'',
theNP, theNP', aNP, aNP', ofTheNP, ofTheNP', ofTheNP'', inTheNP, inTheNP', inTheNP'', the_ofTheNP, the_ofTheNP', the_ofTheNP'',
forNP, forNP', forNP'', ofNP, ofNP', ofNP'', ofNP''', withNP, andNP, andNP', andNP'', andNP'''
) where

Expand Down
12 changes: 11 additions & 1 deletion code/drasil-utils/Utils/Drasil/Concepts.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Utils.Drasil.Concepts (insertStringNP, prependStringNP, insertSentNP, prependSentNP,
theNP, theNP', aNP, aNP', ofTheNP, ofTheNP', ofTheNP'', the_ofTheNP, the_ofTheNP', the_ofTheNP'',
theNP, theNP', aNP, aNP', ofTheNP, ofTheNP', ofTheNP'', inTheNP, inTheNP', inTheNP'', the_ofTheNP, the_ofTheNP', the_ofTheNP'',
forNP, forNP', forNP'', ofNP, ofNP', ofNP'', ofNP''', withNP, andNP, andNP', andNP'', andNP''' )where

import Language.Drasil
Expand Down Expand Up @@ -47,6 +47,16 @@ ofTheNP' t1 t2 = nounPhrase'' (phraseNP t1 `ofThe` phraseNP t2) (pluralNP t1 `of
ofTheNP'' :: (NP -> Sentence) -> (NP -> Sentence) -> NP -> NP -> NP
ofTheNP'' f1 f2 t1 t2 = nounPhrase'' (phraseNP t1 `ofThe` phraseNP t2) (f1 t1 `ofThe` f2 t2) CapFirst CapWords

-- | Inserts "in the" between two 'NP's
inTheNP :: NP -> NP -> NP
inTheNP = insertStringNP "in the"
-- | Similar to 'ofTheNP', but the plural case is now @pluralNP t1 `inThe` phraseNP t2@
inTheNP' :: NP -> NP -> NP
inTheNP' t1 t2 = nounPhrase'' (phraseNP t1 `inThe` phraseNP t2) (pluralNP t1 `inThe` phraseNP t2) CapFirst CapWords
-- | Similar to 'ofTheNP', but accepts two functions for the plural case
inTheNP'' :: (NP -> Sentence) -> (NP -> Sentence) -> NP -> NP -> NP
inTheNP'' f1 f2 t1 t2 = nounPhrase'' (phraseNP t1 `inThe` phraseNP t2) (f1 t1 `inThe` f2 t2) CapFirst CapWords

-- | Prepends "the" and inserts "of the"
the_ofTheNP :: NP -> NP -> NP
the_ofTheNP t1 t2 = theNP t1 `ofTheNP` t2
Expand Down
11 changes: 10 additions & 1 deletion code/drasil-utils/Utils/Drasil/Phrase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@ the' t = nounPhrase'' (S "the" +:+ titleize t) (S "the" +:+ titleize' t) CapWord

-- | A customizable version of 'the'
the'' :: (t -> Sentence) -> t -> NP
the'' f t = nounPhrase''(S "the" +:+ f t) (S "the" +:+ f t) CapFirst CapWords
the'' f t = nounPhrase'' (S "the" +:+ f t) (S "the" +:+ f t) CapFirst CapWords

-- | Creates a noun phrase by combining two 'NamedIdea's with the words "in the" between
-- their terms. Plural is defaulted to @(plural t1) "in the" (phrase t2)@
inThe' :: (NamedIdea c, NamedIdea d) => c -> d -> NP
inThe' t1 t2 = nounPhrase''
(phrase t1 +:+ S "in the" +:+ phrase t2)
(plural t1 +:+ S "in the" +:+ phrase t2)
(Replace (atStart t1 +:+ S "in the" +:+ phrase t2))
(Replace (titleize t1 +:+ S "in the" +:+ titleize t2))

-- | Combinator for combining two 'NamedChunk's into one.
-- /Does not preserve abbreviations/
Expand Down