packages feed

casa-abbreviations-and-acronyms 0.0.5 → 0.0.6

raw patch · 4 files changed

+173/−27 lines, 4 filesnew-component:exe:pre-process-casa-abbreviations-and-acronyms

Files

casa-abbreviations-and-acronyms.cabal view
@@ -1,7 +1,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                  casa-abbreviations-and-acronyms-version:               0.0.5+version:               0.0.6 synopsis:              CASA Abbreviations and Acronyms description:          <<http://i.imgur.com/uZnp9ke.png>>@@ -45,6 +45,24 @@                        , these             >= 0.7.4   && < 0.8    hs-source-dirs:      src/library++  default-language:    Haskell2010++  ghc-options:         -Wall++executable pre-process-casa-abbreviations-and-acronyms                       +  build-depends:         base              >= 4.8     && < 4.12+                       , wreq              >= 0.5     && < 0.6+                       , lens              >= 4.15    && < 4.17+                       , containers        >= 0.5     && < 0.6+                       , fuzzy             >= 0.1.0.0 && < 0.2+                       , monoid-subclasses >= 0.4     && < 0.5+                       , wreq              >= 0.5     && < 0.6+                       , bytestring        >= 0.10    && < 0.11++  main-is:             AbbreviationsAndAcronymsGenerate.hs+                       +  hs-source-dirs:      src/pre-process    default-language:    Haskell2010 
changelog.md view
@@ -1,3 +1,8 @@+0.0.6++* fix extraneous spaces.+* export each acronym.+ 0.0.5  * Remove leading and trailing space from acronym parts.
src/library/Data/Aviation/Casa/AbbreviationsAndAcronyms/Acronym.hs view
@@ -1,12 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleInstances #-} -module Data.Aviation.Casa.AbbreviationsAndAcronyms.Acronym(-  Acronym(..)-, HasAcronym(..)-, acronymValues-, allAcronyms-) where+module Data.Aviation.Casa.AbbreviationsAndAcronyms.Acronym where  import Control.Applicative((<*>)) import Control.Category((.), id)@@ -197,7 +192,7 @@       "AIS"   , Acronym       "ACJ-XXX"-      "Advisory Circular Joint (issued by the JAA, can be followed by a  country code)"+      "Advisory Circular Joint (issued by the JAA, can be followed by a country code)"       "JAA"   , Acronym       "ACK"@@ -821,7 +816,7 @@       ""   , Acronym       "AT-VASIS"-      "Abbreviated 'T' Visual Approach Slope Indicator System (pronounced             'AY-TEE-VASIS')"+      "Abbreviated 'T' Visual Approach Slope Indicator System (pronounced 'AY-TEE-VASIS')"       "AIS"   , Acronym       "AT..."@@ -1149,7 +1144,7 @@       "AIS"   , Acronym       "CAVOK"-      "Visibility, cloud and present weather better than prescribed values               or conditions"+      "Visibility, cloud and present weather better than prescribed values or conditions"       "AIS"   , Acronym       "CB"@@ -1165,7 +1160,7 @@       "AIS"   , Acronym       "CCA"-      "Corrected meteorological message (for CCB, CCC..etc., in sequence)               (message type designator)"+      "Corrected meteorological message (for CCB, CCC..etc., in sequence) (message type designator)"       "ICAO"   , Acronym       "CCF"@@ -1453,7 +1448,7 @@       "AIS"   , Acronym       "CSDD"-      "Common Support Data Dictionary published by the Air Transport Association of America (ATA).  The CSDD replaces the WATOG."+      "Common Support Data Dictionary published by the Air Transport Association of America (ATA). The CSDD replaces the WATOG."       ""   , Acronym       "CSU"@@ -1525,7 +1520,7 @@       "AIS"   , Acronym       "D"-      "Downward (tendency in RVR (Runway visual range) during previous               10 minutes)"+      "Downward (tendency in RVR (Runway visual range) during previous 10 minutes)"       "ICAO"   , Acronym       "D-ATIS"@@ -1877,7 +1872,7 @@       "AIS"   , Acronym       "EMBD"-      "Embedded in a Layer (to indicate cumulonimbus embedded in layers               of other clouds)"+      "Embedded in a Layer (to indicate cumulonimbus embedded in layers of other clouds)"       "AIS"   , Acronym       "EMERG"@@ -2077,7 +2072,7 @@       "AIS"   , Acronym       "FBL"-      "Light (used to indicate the intensity of WX phenomena, interference               or static reports, eg BL RA = light rain)"+      "Light (used to indicate the intensity of WX phenomena, interference or static reports, eg BL RA = light rain)"       "AIS"   , Acronym       "FC"@@ -2689,7 +2684,7 @@       "AIS"   , Acronym       "HVY"-      "Heavy (used to indicate the intensity of WX phenomena, eg HVY               RA = heavy rain)"+      "Heavy (used to indicate the intensity of WX phenomena, eg HVY RA = heavy rain)"       "AIS"   , Acronym       "HX"@@ -3309,7 +3304,7 @@       "CASA"   , Acronym       "MCQFS"-      "Manual of criteria for the qualification of flight simulators               ICAO Doc 9625-AN/938"+      "Manual of criteria for the qualification of flight simulators ICAO Doc 9625-AN/938"       ""   , Acronym       "MCUR"@@ -3345,7 +3340,7 @@       "AIS"   , Acronym       "MERSITAB"-      "Manufacturing, Engineering and Related Services Industry Training               Advisory Body"+      "Manufacturing, Engineering and Related Services Industry Training Advisory Body"       "AIS"   , Acronym       "MET"@@ -3357,7 +3352,7 @@       "CASR Part 66"   , Acronym       "METAR"-      "Aviation routine weather report (in aeronautical meteorological               code)"+      "Aviation routine weather report (in aeronautical meteorological code)"       "AIS"   , Acronym       "METRAD"@@ -4841,7 +4836,7 @@       "AIS"   , Acronym       "SEA"-      "Sea (used in connection with sea-surface temperature and state               of the sea)"+      "Sea (used in connection with sea-surface temperature and state of the sea)"       "CAR 1998"   , Acronym       "SEACO"@@ -4885,7 +4880,7 @@       "AIS"   , Acronym       "SH..."-      "Showers (followed by RA=rain, SN=snow, PL=ice pellets, GR=hail,               GS=small hail and/or snow pellets or combinations thereof, eg, SHRASN               = showers of rain and snow)"+      "Showers (followed by RA=rain, SN=snow, PL=ice pellets, GR=hail, GS=small hail and/or snow pellets or combinations thereof, eg, SHRASN = showers of rain and snow)"       "AIS"   , Acronym       "SHF"@@ -4909,7 +4904,7 @@       "ICAO/AIP"   , Acronym       "SIGMET"-      "Information concerning en route weather phenomena which may affect               the safety of aircraft operations"+      "Information concerning en route weather phenomena which may affect the safety of aircraft operations"       "AIS"   , Acronym       "SIL"@@ -4961,7 +4956,7 @@       "AIS"   , Acronym       "SNOWTAM"-      "A special series NOTAM notifying the presence or removal of hazardous               conditions due to snow, ice, slush or standing water associated               with snow, slush and ice on the movement area"+      "A special series NOTAM notifying the presence or removal of hazardous conditions due to snow, ice, slush or standing water associated with snow, slush and ice on the movement area"       "CAR 1998"   , Acronym       "SOC"@@ -5453,7 +5448,7 @@       ""   , Acronym       "TS..."-      "Thunderstorm (followed by RA=rain, SN=snow, PE=ice pellets, GR=hail,               GS=small hail and/or snow pellets or combinations thereof, eg TSRASN               = thunderstorm with rain and snow)"+      "Thunderstorm (followed by RA=rain, SN=snow, PE=ice pellets, GR=hail, GS=small hail and/or snow pellets or combinations thereof, eg TSRASN = thunderstorm with rain and snow)"       "AIS"   , Acronym       "TSI"@@ -5629,7 +5624,7 @@       "AIS"   , Acronym       "VC"-      "Vicinity of the aerodrome (followed by FG=fog, FC=funnel cloud,               PO=dust/sand whirls, BLDU=blowing dust, BLSA=blowing sand or BLSN=blowing               snow; eg, VCFG=vicinity fog"+      "Vicinity of the aerodrome (followed by FG=fog, FC=funnel cloud, PO=dust/sand whirls, BLDU=blowing dust, BLSA=blowing sand or BLSN=blowing snow; eg, VCFG=vicinity fog"       "AIS"   , Acronym       "VCY"@@ -5833,7 +5828,7 @@       "AIS"   , Acronym       "WAC"-      "World Aeronautical Chart  ICAO 1:1,000,000 (followed by name/title)"+      "World Aeronautical Chart ICAO 1:1,000,000 (followed by name/title)"       ""   , Acronym       "WAFC"@@ -5897,7 +5892,7 @@       "AIS"   , Acronym       "WIND"-      "Wind (used in connection with direction and speed) WINTEM Forecast               upper wind and temperature at specified points (in aeronautical               met code)"+      "Wind (used in connection with direction and speed) WINTEM Forecast upper wind and temperature at specified points (in aeronautical met code)"       "AIS"   , Acronym       "WIP"
+ src/pre-process/AbbreviationsAndAcronymsGenerate.hs view
@@ -0,0 +1,128 @@+module AbbreviationsAndAcronymsGenerate where++import qualified Data.ByteString.Lazy.Char8 as LazyChar8ByteString+import Control.Lens+import Control.Monad+import Data.Char+import Network.Wreq+import System.Environment++getAbbreviationPage ::+  String+  -> IO String+getAbbreviationPage x =+  do  q <- get ("http://www.casa.gov.au/about-us/standard-page/aviation-abbreviations-and-acronyms?page=" ++ x)+      let b = LazyChar8ByteString.unpack (q ^. responseBody)+      pure b++getAcronyms ::+  [String]+  -> [Acronym]+getAcronyms [] =+  []+getAcronyms (i1:a:i2:b:i3:c:i4:r) =+  let matches =+        [+          (i1, "                  <td class=\"views-field views-field-title active\" >")+        , (i2, "                  <td class=\"views-field views-field-field-meaning\" >")+        , (i3, "                  <td class=\"views-field views-field-field-source\" >")+        , (i4, "              </tr>")+        ]+      trim =+         escapeChars . reverse . dropWhile isSpace . drop 15 . reverse . dropWhile isSpace . drop 12+  in  if all (uncurry (==)) matches+        then+          Acronym+            (trim a)+            (trim b)+            (trim c)+          :getAcronyms r+        else+          getAcronyms (a:i2:b:i3:c:i4:r)+getAcronyms (_:t) =+  getAcronyms t++requestAcronyms ::+  [Int]+  -> IO [Acronym]+requestAcronyms x =+  join <$> traverse (((getAcronyms . lines) <$>) . getAbbreviationPage . show) x++requestAllAcronyms ::+  IO [Acronym]+requestAllAcronyms =+  requestAcronyms [0..49]++data Acronym =+  Acronym+    String -- acronym+    String -- meaning+    String -- source+  deriving (Eq, Ord, Show)++render ::+  [Acronym]+  -> String+render acrs =+  let render1 (Acronym acr mean src) =+        concat+          [ +            "Acronym\n"+          , "      \""+          , acr+          , "\"\n"+          , "      \""+          , mean+          , "\"\n"+          , "      \""+          , src+          , "\""+          ]+      allAcronyms =+        concat+          [+            "allAcronyms =\n"+          , "  [\n"+          , zip (True:cycle [False]) acrs >>= \(p, a) ->+              concat+                [+                  "  "+                , if p then " " else ","+                , " "+                , render1 a+                , "\n"+                ]+          , "  ]\n"+          ]+  in  allAcronyms++escapeChars ::+  String+  -> String+escapeChars =+  transform+    (\x ->  case x of+              '&':'#':'0':'3':'9':';':r ->+                '\'':r+              h:t ->+                if isSpace h+                  then+                    h : dropWhile isSpace t+                  else+                    x+              _ ->+                x+              )++main ::+  IO ()+main =+  do  a <- getArgs+      let n =+            case a of+              [] ->+                [0..49]+              q@(_:_) ->+                read <$> q+      c <- requestAcronyms n+      writeFile "acronyms.hs" (render c)