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

Add ShortName to ConceptChunk. #658

Merged
merged 1 commit into from
Jun 14, 2018
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
12 changes: 6 additions & 6 deletions code/Language/Drasil/Chunk/Concept.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Control.Lens ((^.))
dcc :: String -> NP -> String -> ConceptChunk
-- | Smart constructor for creating concept chunks given an id,
-- 'NounPhrase' ('NP') and definition (as String).
dcc i ter des = ConDict (mkIdea i ter Nothing) (DAD (S des) [])
dcc i ter des = ConDict (mkIdea i ter Nothing) (DAD (S des) []) Nothing
-- ^ Concept domain tagging is not yet implemented in this constructor.

-- | Identical to 'dcc', but adds an abbreviation (String)
Expand All @@ -29,7 +29,7 @@ dcc' i t d a = ComConDict (commonIdea i t a) (S d) []

-- | Similar to 'dcc', except the definition is a 'Sentence'
dccWDS :: String -> NP -> Sentence -> ConceptChunk
dccWDS i t d = ConDict (mkIdea i t Nothing) (DAD d [])
dccWDS i t d = ConDict (mkIdea i t Nothing) (DAD d []) Nothing

-- | Similar to 'dcc', except the definition is a 'Sentence' and adds
-- an abbreviation (String)
Expand All @@ -38,16 +38,16 @@ dccWDS' i t d a = ComConDict (commonIdea i t a) d []

-- | Constructor for 'ConceptChunk'. Does not allow concept domain tagging.
cc :: Idea c => c -> String -> ConceptChunk
cc n d = ConDict (nw n) (DAD (S d) [])
cc n d = ConDict (nw n) (DAD (S d) []) Nothing

-- | Same as cc, except definition is a 'Sentence'
cc' :: Idea c => c -> Sentence -> ConceptChunk
cc' n d = ConDict (nw n) (DAD d [])
cc' n d = ConDict (nw n) (DAD d []) Nothing

-- | Constructor for 'ConceptChunk'. Allows explicit tagging.
ccs :: (Idea c, Concept d) => c -> Sentence -> [d] -> ConceptChunk --Explicit tagging
ccs n d l = ConDict (nw n) (DAD d $ map (\x -> x ^. uid) l)
ccs n d l = ConDict (nw n) (DAD d $ map (\x -> x ^. uid) l) Nothing

-- | For projecting out to the ConceptChunk data-type
cw :: Concept c => c -> ConceptChunk
cw c = ConDict (nw c) $ DAD (c ^. defn) (c ^. cdom)
cw c = ConDict (nw c) (DAD (c ^. defn) (c ^. cdom)) Nothing
12 changes: 10 additions & 2 deletions code/Language/Drasil/Chunk/Concept/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Language.Drasil.Chunk.CommonIdea (CI)
import Language.Drasil.UID (UID)
import Language.Drasil.Classes (HasUID(uid), NamedIdea(term), Idea(getA),
Definition(defn), ConceptDomain(cdom), Concept, CommonIdea(abrv))
import Language.Drasil.Chunk.ShortName (HasShortName(shortname), ShortName)

import Control.Lens (makeLenses, (^.), view)

Expand All @@ -17,8 +18,11 @@ data DefnAndDomain = DAD { _defn' :: Sentence, _cdom' :: [UID]}
makeLenses ''DefnAndDomain

-- | The ConceptChunk datatype is a Concept
-- ConDict is not exported, nor are _idea and _dad
data ConceptChunk = ConDict { _idea :: IdeaDict, _dad :: DefnAndDomain }
-- ConDict is not exported, nor are _idea, _dad, and _sn.
data ConceptChunk = ConDict { _idea :: IdeaDict
, _dad :: DefnAndDomain
, _sn :: Maybe ShortName
}
makeLenses ''ConceptChunk

instance Definition DefnAndDomain where defn = defn'
Expand All @@ -31,6 +35,10 @@ instance Idea ConceptChunk where getA = getA . view idea
instance Definition ConceptChunk where defn = dad . defn'
instance ConceptDomain ConceptChunk where cdom = dad . cdom'
instance Concept ConceptChunk where
instance HasShortName ConceptChunk where
shortname x = maybe
(error $ "No ShortName found for ConceptChunk: " ++ (view uid x)) id $
view sn x

data CommonConcept = ComConDict { _comm :: CI, _def :: Sentence, _dom :: [UID]}
makeLenses ''CommonConcept
Expand Down