<commit_before>module Drasil.GlassBR.Unitals where --whole file is used

import Language.Drasil
import Language.Drasil.ShortHands

import Control.Lens ((^.))
import Prelude hiding (log)

import Data.Drasil.Constraints (gtZeroConstr)
import Data.Drasil.Phrase (compoundNC)
import Data.Drasil.SentenceStructures (FoldType(..), SepType(Comma),
  displayConstrntsAsSet, foldlList, foldlSent, foldlsC)
import Data.Drasil.SI_Units (kilogram, metre, millimetre, pascal, second)

import Drasil.GlassBR.Concepts (aR, annealed, fullyT, glaPlane, glassTypeFac, 
  heatS, iGlass, lGlass, lResistance, lShareFac, loadDurFactor, nFL, responseTy, 
  stdOffDist)
import Drasil.GlassBR.References (astm2009, astm2012, astm2016)
import Drasil.GlassBR.Units (sFlawPU)

--FIXME: Many of the current terms can be separated into terms and defns?

{--}

glassBRSymbolsWithDefns :: [UnitalChunk]
glassBRSymbolsWithDefns = [modElas]

modElas :: UnitalChunk
modElas = uc' "modElas" (nounPhraseSP "modulus of elasticity of glass")
  "The ratio of tensile stress to tensile strain of glass." cE pascal

{--}

gbConstrained :: [ConstrainedChunk]

gbConstrained = (map cnstrw gbInputsWUncrtn) ++ 
  (map cnstrw gbInputsWUnitsUncrtn) ++ [cnstrw probBr, cnstrw probFail] 

plateLen, plateWidth, charWeight, standOffDist :: UncertQ
aspect_ratio, pbTol, tNT :: UncertainChunk
glass_type, nomThick :: ConstrainedChunk

{--}

defaultUncrt :: Double
defaultUncrt = 0.1

gbInputs :: [QuantityDict]
gbInputs = (map qw gbInputsWUnitsUncrtn) ++ (map qw gbInputsWUncrtn) ++ 
  (map qw gbInputsNoUncrtn) ++ (map qw sdVector)

--inputs with units and uncertainties
gbInputsWUnitsUncrtn :: [UncertQ]
gbInputsWUnitsUncrtn = [plateLen, plateWidth, standOffDist, charWeight]

--inputs with uncertainties and no units
gbInputsWUncrtn :: [UncertainChunk]
gbInputsWUncrtn = [aspect_ratio, pbTol, tNT]

--inputs with no uncertainties
gbInputsNoUncrtn :: [ConstrainedChunk]
gbInputsNoUncrtn = [glass_type, nomThick]

gbInputDataConstraints :: [UncertainChunk]
gbInputDataConstraints = (map uncrtnw gbInputsWUnitsUncrtn) ++ 
  (map uncrtnw gbInputsWUncrtn)

plateLen = uqcND "plateLen" (nounPhraseSP "plate length (long dimension)")
  lA metre Real 
  [ gtZeroConstr,
    physc $ UpFrom (Inc, sy plateWidth),
    sfwrc $ Bounded (Inc , sy dimMin) (Inc , sy dimMax)] (dbl 1.5) defaultUncrt

plateWidth = uqcND "plateWidth" (nounPhraseSP "plate width (short dimension)")
  lB metre Real
  [ physc $ Bounded (Exc, 0) (Inc, sy plateLen),
    sfwrc $ Bounded (Inc, sy dimMin) (Inc, sy dimMax)] (dbl 1.2) defaultUncrt

aspect_ratio = uvc "aspect_ratio" (aR ^. term)
  (Atomic "AR") Real
  [ physc $ UpFrom (Inc, 1), 
    sfwrc $ UpTo (Inc, sy arMax)] (dbl 1.5) defaultUncrt

pbTol = uvc "pbTol" (nounPhraseSP "tolerable probability of breakage") 
  (sub cP (Atomic "btol")) Real
  [ physc $ Bounded (Exc, 0) (Exc, 1)] (dbl 0.008) (0.001)


charWeight = uqcND "charWeight" (nounPhraseSP "charge weight") 
  lW kilogram Real
  [ gtZeroConstr,
    sfwrc $ Bounded (Inc, sy cWeightMin) (Inc, sy cWeightMax)]
    (dbl 42) defaultUncrt

tNT = uvc "tNT" (nounPhraseSP "TNT equivalent factor")
  (Atomic "TNT") Real
  [ gtZeroConstr ] (dbl 1.0) defaultUncrt

standOffDist = uqcND "standOffDist" (nounPhraseSP "stand off distance") 
  (Atomic "SD") metre Real
  [ gtZeroConstr,
    sfwrc $ Bounded (Inc, sy sdMin) (Inc, sy sdMax)]
  (dbl 45) defaultUncrt
--FIXME: ^ incorporate definition in here?

nomThick = cuc "nomThick" 
  (nounPhraseSent $ S "nominal thickness" +:+ displayConstrntsAsSet 
    nomThick (map show nominalThicknesses))
  lT millimetre ({-DiscreteD nominalThicknesses-} Rational) 
  [enumc nominalThicknesses] 8

-- the S "glass type" is supposed to be using "phrase glassTy"
-- but the problem is still the Capitalization issue with new 
-- constructor `Ch` of generating the sentence. So for the sentence
-- only "S" can be capitalized 
glass_type  = cvc "glass_type" (nounPhraseSent $ S "glass type" +:+ 
    displayConstrntsAsSet glass_type (map (getAccStr . snd) glassType))
  lG ({-DiscreteS (map (getAccStr . snd) glassType)-} String)
  [EnumeratedStr Software $ map (getAccStr . snd) glassType] Nothing

{--}

gbOutputs :: [QuantityDict]
gbOutputs = map qw [isSafePb, isSafeLR] ++ map qw [probBr] 

probBr :: ConstrainedChunk
probBr = cvc "probBr" (nounPhraseSP "probability of breakage")
  (sub cP lB) Rational
  [ physc $ Bounded (Exc,0) (Exc,1)] (Just $ dbl 0.4)

gbTMSymbols :: [QuantityDict]
gbTMSymbols = map qw [probFail, probFail] ++ map qw [is_safeProb, is_safeLoad] 
<commit_msg>Fixing gbTMSymbols in GlassBR unitals, bug that caused it to deviate from stable.<commit_after>module Drasil.GlassBR.Unitals where --whole file is used

import Language.Drasil
import Language.Drasil.ShortHands

import Control.Lens ((^.))
import Prelude hiding (log)

import Data.Drasil.Constraints (gtZeroConstr)
import Data.Drasil.Phrase (compoundNC)
import Data.Drasil.SentenceStructures (FoldType(..), SepType(Comma),
  displayConstrntsAsSet, foldlList, foldlSent, foldlsC)
import Data.Drasil.SI_Units (kilogram, metre, millimetre, pascal, second)

import Drasil.GlassBR.Concepts (aR, annealed, fullyT, glaPlane, glassTypeFac, 
  heatS, iGlass, lGlass, lResistance, lShareFac, loadDurFactor, nFL, responseTy, 
  stdOffDist)
import Drasil.GlassBR.References (astm2009, astm2012, astm2016)
import Drasil.GlassBR.Units (sFlawPU)

--FIXME: Many of the current terms can be separated into terms and defns?

{--}

glassBRSymbolsWithDefns :: [UnitalChunk]
glassBRSymbolsWithDefns = [modElas]

modElas :: UnitalChunk
modElas = uc' "modElas" (nounPhraseSP "modulus of elasticity of glass")
  "The ratio of tensile stress to tensile strain of glass." cE pascal

{--}

gbConstrained :: [ConstrainedChunk]

gbConstrained = (map cnstrw gbInputsWUncrtn) ++ 
  (map cnstrw gbInputsWUnitsUncrtn) ++ [cnstrw probBr, cnstrw probFail] 

plateLen, plateWidth, charWeight, standOffDist :: UncertQ
aspect_ratio, pbTol, tNT :: UncertainChunk
glass_type, nomThick :: ConstrainedChunk

{--}

defaultUncrt :: Double
defaultUncrt = 0.1

gbInputs :: [QuantityDict]
gbInputs = (map qw gbInputsWUnitsUncrtn) ++ (map qw gbInputsWUncrtn) ++ 
  (map qw gbInputsNoUncrtn) ++ (map qw sdVector)

--inputs with units and uncertainties
gbInputsWUnitsUncrtn :: [UncertQ]
gbInputsWUnitsUncrtn = [plateLen, plateWidth, standOffDist, charWeight]

--inputs with uncertainties and no units
gbInputsWUncrtn :: [UncertainChunk]
gbInputsWUncrtn = [aspect_ratio, pbTol, tNT]

--inputs with no uncertainties
gbInputsNoUncrtn :: [ConstrainedChunk]
gbInputsNoUncrtn = [glass_type, nomThick]

gbInputDataConstraints :: [UncertainChunk]
gbInputDataConstraints = (map uncrtnw gbInputsWUnitsUncrtn) ++ 
  (map uncrtnw gbInputsWUncrtn)

plateLen = uqcND "plateLen" (nounPhraseSP "plate length (long dimension)")
  lA metre Real 
  [ gtZeroConstr,
    physc $ UpFrom (Inc, sy plateWidth),
    sfwrc $ Bounded (Inc , sy dimMin) (Inc , sy dimMax)] (dbl 1.5) defaultUncrt

plateWidth = uqcND "plateWidth" (nounPhraseSP "plate width (short dimension)")
  lB metre Real
  [ physc $ Bounded (Exc, 0) (Inc, sy plateLen),
    sfwrc $ Bounded (Inc, sy dimMin) (Inc, sy dimMax)] (dbl 1.2) defaultUncrt

aspect_ratio = uvc "aspect_ratio" (aR ^. term)
  (Atomic "AR") Real
  [ physc $ UpFrom (Inc, 1), 
    sfwrc $ UpTo (Inc, sy arMax)] (dbl 1.5) defaultUncrt

pbTol = uvc "pbTol" (nounPhraseSP "tolerable probability of breakage") 
  (sub cP (Atomic "btol")) Real
  [ physc $ Bounded (Exc, 0) (Exc, 1)] (dbl 0.008) (0.001)


charWeight = uqcND "charWeight" (nounPhraseSP "charge weight") 
  lW kilogram Real
  [ gtZeroConstr,
    sfwrc $ Bounded (Inc, sy cWeightMin) (Inc, sy cWeightMax)]
    (dbl 42) defaultUncrt

tNT = uvc "tNT" (nounPhraseSP "TNT equivalent factor")
  (Atomic "TNT") Real
  [ gtZeroConstr ] (dbl 1.0) defaultUncrt

standOffDist = uqcND "standOffDist" (nounPhraseSP "stand off distance") 
  (Atomic "SD") metre Real
  [ gtZeroConstr,
    sfwrc $ Bounded (Inc, sy sdMin) (Inc, sy sdMax)]
  (dbl 45) defaultUncrt
--FIXME: ^ incorporate definition in here?

nomThick = cuc "nomThick" 
  (nounPhraseSent $ S "nominal thickness" +:+ displayConstrntsAsSet 
    nomThick (map show nominalThicknesses))
  lT millimetre ({-DiscreteD nominalThicknesses-} Rational) 
  [enumc nominalThicknesses] 8

-- the S "glass type" is supposed to be using "phrase glassTy"
-- but the problem is still the Capitalization issue with new 
-- constructor `Ch` of generating the sentence. So for the sentence
-- only "S" can be capitalized 
glass_type  = cvc "glass_type" (nounPhraseSent $ S "glass type" +:+ 
    displayConstrntsAsSet glass_type (map (getAccStr . snd) glassType))
  lG ({-DiscreteS (map (getAccStr . snd) glassType)-} String)
  [EnumeratedStr Software $ map (getAccStr . snd) glassType] Nothing

{--}

gbOutputs :: [QuantityDict]
gbOutputs = map qw [isSafePb, isSafeLR] ++ map qw [probBr] 

probBr :: ConstrainedChunk
probBr = cvc "probBr" (nounPhraseSP "probability of breakage")
  (sub cP lB) Rational
  [ physc $ Bounded (Exc,0) (Exc,1)] (Just $ dbl 0.4)

gbTMSymbols :: [QuantityDict]
gbTMSymbols = map qw [probFail, pbTolfail] ++ map qw [is_safeProb, is_safeLoad] 

{'fraction_non_alphanumeric': 0.11022590854523627, 'fraction_numerical': 0.009385572410782495, 'mean_word_length': 4.859335038363171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1878200', 'n_tokens_mistral': 3693, 'n_tokens_neox': 3481, 'n_words': 960}