-
Notifications
You must be signed in to change notification settings - Fork 26
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
Detect and complain if the same symbol is used for two or more concepts within the same document #1916
Comments
@smiths |
I'm sorry @muhammadaliog3, but I do not know the answer to your question. Maybe you can find it by looking at the code documentation: https://jacquescarette.github.io/Drasil/docs/index.html Alternatively, this is likely a question that @JacquesCarette or @bmaclach could answer. |
First, you should really investigate if that If it is, then there are various 'rendering' functions in If you tell us the context more precisely, we can direct you to the proper functions. Often, wishing to print a |
@JacquesCarette I do not believe that in the error we should simply print "Duplicate symbols found", rather we should at the very least say "Duplicate symbols found. See the following descriptions: (description_1,description_2,description_3,description_4)". These descriptions are stored as a list of sentences. I can fold the sentences into one sentence, but to print the error I still need to convert that one sentence to a string. This is the code by the way, the line with ----HERE------------ is where I print the error. table :: (Quantity s, MayHaveUnit s) => Stage -> [s] -> (s -> Sentence) -> LabelledContent
table st ls f
|noDuplicate = llcc symbTableRef $
Table [atStart symbol_, atStart description, atStart' unit_]
(mkTable [P . (`symbol` st), f, toSentence]
$ filteredChunks)
(titleize tOfSymb) True
|otherwise = error $ "Duplicate Symbols" ++ foldlSentCol descDuplicates ---HERE----------------
where
filteredChunks = filter (`hasStageSymbol`st) ls
symbolsCol = map (P . (`symbol` st)) $ filteredChunks
descCol = map (f) $ filteredChunks
symDescPair = zip symbolsCol descCol
symDuplicates = symbolsCol \\ (nub symbolsCol) --if you did not know (\\) is the difference between lists
noDuplicate = symDuplicates == []
descDuplicates = [snd x | x <- symDescPair, fst x `elem` symDuplicates] |
That's a nice piece of Haskell. I would prefer if the error was even more verbose & precise: it should give an error for each UID/symbol/description tuple that is duplicate. So an error for |
But to print the errors you mentioned I would need to convert a sentence to a string. I still do not know how to do that. |
Oh, because of the descriptions? Ok, skip those. Just do the UIDs and symbols then. |
This issue came up during the discussion in #1901.
Symbols are routinely used for different meanings in science and engineering. However, if the same symbol has more than one meaning in the same document, this is a problem. Drasil should prevent the user from making this mistake by automatically detecting if a symbol is use for more than one purpose within the same document.
The text was updated successfully, but these errors were encountered: