Open halonazhao opened 6 years ago
You are correct that Ref
should contain the UID
, at least if things stay as is.
However, your second suggestion (filling in the reference field while converting DocSec
to Document
) is probably the even better 'solution'. Though Ref
might still need that change.
Overall, we should think that:
DocLang
is really the document-author level language that should be used as much as possible.Document
is a layout language, but quite abstract, which is intermediate before we move to a specific layout language in drasil-printers
.In other words, DocLang
should evolve to be the language we use to describe the contents we want in a particular document. Then, perhaps along with some 'style' options, we want to render that to a Document
, which starts the process of translating from content to layout.
References are 'content-full' things.
When I was working with TM, I feel there is one thing odd which is where the UID of the TM comes from. https://github.com/JacquesCarette/Drasil/blob/350662104824b07b3b2d93a45d8fbd448be837ba/code/drasil-lang/Language/Drasil/Chunk/Theory.hs#L33-L43 https://github.com/JacquesCarette/Drasil/blob/350662104824b07b3b2d93a45d8fbd448be837ba/code/drasil-lang/Language/Drasil/Chunk/Theory.hs#L58-L65 Currently the uid is from conceptChunk, but why goes so long way back there instead of using TheoryChunk's uid. @JacquesCarette
You're right, this is a bit weird. I am not even sure why TheoryChunk
and TheoryModel
are separate.
It feels to me like TheoryChunk
should not have a UID
at all, and so not exist in the system 'raw', but always inside a TheoryModel
. @szymczdm ?
I believe TheoryChunk
was originally intended as an encoding for any kind of abstract theories. It definitely feels like somewhere along the way it was updated to include some referencing information that, without taking a deeper look seems out of place, and TheoryModel
was meant to take a TheoryChunk
and make it more concrete by giving it a label, definition, etc.
Right. So it seems to be that we should remove UID
from TheoryChunk
and in fact not let TheoryChunk
really exist outside of TheoryModel
.
To fill the reference field for TM, DD, GD, IM, my thought of the working flow is basically like below:
To build a
LabelMap = Map.Map UID Lable
likeSymbMap
,UnitMap
inChunkDB
. This label map should be manually generated when we created all the labels.Since the reference relations should be collected only from
Sentence
and the references inSentence
are made by usingmakeRef
and further callingcustomRef
to generate better names. The problem here is as below: https://github.com/JacquesCarette/Drasil/blob/9350be2696084ad959bbc1c5122d7313f95162ea/code/drasil-lang/Language/Drasil/Reference.hs#L320-L321 https://github.com/JacquesCarette/Drasil/blob/9350be2696084ad959bbc1c5122d7313f95162ea/code/drasil-lang/Language/Drasil/Reference.hs#L329-L343 https://github.com/JacquesCarette/Drasil/blob/9350be2696084ad959bbc1c5122d7313f95162ea/code/drasil-lang/Language/Drasil/Spec.hs#L21-L34By matching
Ref
fromSentence
, only theshortname
can help detecting which label we are referring. If using 'shortname' to look up a label in database, we may have to have a label map at typeMap.Map ShortName Lable
, which has conflicts with the first step of design. And I think that we alway wantUID
to be the index to the database. So we may want to expand theRef
structure inSentence
to includeUID
and now we only reference things using label and labels always haveUIDs
.Once we get the first two steps done, we will have to traverse
SSDSec
inDocSec
. Then I will create a map to record all the reference relation between all DDs, Assumptions, IMs, GDs, TMs. I will take TM as an example.TMs :: Fields -> [TheoryModel] -> SCSSub
So I will get allTheoryModel
with their labels. The labels will be made index in the map and the referenced labels collected from sentence from each TM will be a list of labels in the map. So the mao will beReferenceMap = Map.Map Lable [Label]
.When I get the whole SSD section traversed, the ReferenceMap will be filled up. The next step should be filling the
RefBy
field.The problem here is that when we are able to traverse the all the chunks to fill ReferenceMap, that would mean we already have TMs, IMs, DDs built. All the informations has been filled in to TMs, IMs, DDs but references because we temporarily left it empty. when I want to fill the collected references in, it sort of has to rebuild all the TMs, IMs and DDs again to fill the reference informations in. This way would only does changes on
DocSec
.There is another way I can think is filling the reference field while converting
DocSec
toDocument
. https://github.com/JacquesCarette/Drasil/blob/9350be2696084ad959bbc1c5122d7313f95162ea/code/drasil-docLang/Drasil/DocumentLanguage/Definitions.hs#L80-L92 when converting the TMs, I fill the references directly to the field since during this process, the TM itself's label is available to check the referring labels.This is basically my thought. Could you go through and give some ideas? @JacquesCarette