Forbid capital letters in various sentence and noun phrase constructors
I'm sure there is an example that breaks my simple-minded approach, but my first instinct is for everything (even Crawford) to be lowercase in the data. The generator knows that Crawford is a proper noun, so it adds the capital at generation time. The exception would be acronyms that use funky capitalization, like LaTeX.
Originally posted by @smiths in https://github.com/JacquesCarette/Drasil/issues/3692#issuecomment-1947523602
#3534 is the original issue, where @samm82 found some problematic sentence and/or noun phrase entries that carried capital letters. We really want Drasil to do the capitalization for us, purely on its own. We need to do that by enriching the data as much as we can, trying to minimize the raw capital letters we enter. To do this, we can add a simple error case in all of our sentence and noun phrase constructors so that we strictly forbid capital letter entry.
You can find a few examples of these problematic string entries that would need to be fixed using grep or rg commands, similar to how I did in my comment on #3692.
@samm82 @balacij Can you give me some help? Here is my modified code:
-- | The commonIdea smart constructor requires a chunk id ('String'), a
-- term ('NP'), an abbreviation ('String'), and a domain (['UID']).
commonIdea :: String -> NP -> String -> [UID] -> CI
commonIdea s np = CI (nc s (nounPhrase (capitalize (phraseNP np))))
Here is the error:
drasil-lang > lib\Language\Drasil\Chunk\CommonIdea.hs:46:53: error: [GHC-88464]
drasil-lang > Variable not in scope: phrase :: NP -> String
drasil-lang > Suggested fix:
drasil-lang > Perhaps use one of these:
drasil-lang > data constructor ‘Phrase’ (imported from Language.Drasil.NounPhrase.Core),
drasil-lang > ‘phraseNP’ (imported from Language.Drasil.NounPhrase)
drasil-lang > |
drasil-lang > 46 | commonIdea s np = CI (nc s (nounPhrase (capitalize (phrase np))))
drasil-lang > | ^^^^^^
Progress 1/12
Error: [S-7282]
Stack failed to execute the build plan.
While executing the build plan, Stack encountered the error:
[S-7011]
While building package drasil-lang-0.1.60.0 (scroll up to its section to
see the error) using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_9p6GVs8J_3.10.3.0_ghc-9.6.6.exe --verbose=1 --builddir=.stack-work\dist\2bf92870 build lib:drasil-lang --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
make: *** [Makefile:309: glassbr_gen] Error 1
My reasoning is, to transfer NP to String first, then use the capitalize function, then use NounPhrase to return to NP type.
I thought there were combinators for capitalizing a NP? In any case: we should never round-trip to String. That is a Drasil anti-pattern.