diff --git a/buildsample/Build.AviationSample.cls b/buildsample/Build.AviationSample.cls index 1308f11..f82c5ea 100644 --- a/buildsample/Build.AviationSample.cls +++ b/buildsample/Build.AviationSample.cls @@ -43,9 +43,9 @@ ClassMethod Build() } /// This method enables you to build the sample with a minimum of output to the Terminal. -/// stagingroot is the name of the directory that contains the downloaded files. -/// interactive controls whether this method displays output. -/// Build calls this method with interactive=1. +/// stagingroot is the name of the directory that contains the downloaded files. +/// interactive controls whether this method displays output. +/// Build calls this method with interactive=1. ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0) { //repeat this test here in case we go directly to this method @@ -56,7 +56,7 @@ ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0) return 0 } - //load and compile classes *************************** + // load and compile classes *************************** set dir=stagingroot_"/cls/" ;works on both Windows and Unix if '##class(%File).DirectoryExists(dir) { if interactive { @@ -70,7 +70,7 @@ ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0) } do $system.OBJ.LoadDir(dir,"ck",,1) - //load data from exported global ****************************** + // Load data from exported global ****************************** if interactive { write !, "Loading data..." } @@ -84,7 +84,7 @@ ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0) } do $system.OBJ.Load(file) - // execute the setup code in the loaded classes ********************* + // Execute the setup code in the loaded classes ********************* if '##class(%Dictionary.CompiledClass).%ExistsId("Aviation.Utils") { if interactive { write !!, "Looking for the class Aviation.Utils but it does not exist... Quitting." diff --git a/cls/Aviation/Aircraft.cls b/cls/Aviation/Aircraft.cls index 0f2e70a..f528457 100644 --- a/cls/Aviation/Aircraft.cls +++ b/cls/Aviation/Aircraft.cls @@ -1,11 +1,11 @@ /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This class represents the details on aircraft involved in events registered by the -/// National Transportation Safety Board.

-///

Note on the data: The dataset provided in this sample demo is only a lightweight +/// This class represents the details on aircraft involved in events registered by the +/// National Transportation Safety Board. +/// Note on the data: The dataset provided in this sample demo is only a lightweight /// subset of the full NTSB dataset, which is available from -/// http://www.ntsb.gov. This data is supplied -/// here for demonstration purposes only and neither intended nor warranted to be accurate.
-/// Courtesy: National Transportation Safety Board

+/// http://www.ntsb.gov. This data is supplied +/// here for demonstration purposes only and neither intended nor warranted to be accurate. +/// Courtesy: National Transportation Safety Board Class Aviation.Aircraft Extends %Persistent { @@ -139,207 +139,5 @@ Property FlightMedicalType As %Library.String(MAXLEN = 15); Index PKINDEX On (EventId, AircraftKey) [ PrimaryKey, Unique ]; -Storage Default -{ - - -%%CLASSNAME - - -EventId - - -AircraftKey - - -RegistrationNumber - - -Missing - - -FlightPlan - - -FlightPlanActivated - - -Damage - - -AccidentFire - - -AccidentExplosion - - -AircraftManufacturer - - -AircraftModel - - -AircraftSeries - - -AircraftSerialNo - - -AircraftCertMaxGrossWeight - - -AircraftCategory - - -AircraftRegistrationClass - - -AircraftHomeBuilt - - -SeatsFlightCrew - - -SeatsCabinCrew - - -SeatsPassengers - - -SeatsTotal - - -EngineCount - - -GearType - - -LastInspectionType - - -LastInspectionDate - - -AirFrameHoursSinceLastInspection - - -AirFrameHours - - -Owner - - -OwnerState - - -OwnerCountry - - -OperatorIndividual - - -OperatorName - - -OperatorState - - -OperatorCountry - - -OperatorCode - - -OwnerCertified - - -OperatorCertificate - - -OperatorCertificateNum - - -OperationScheduled - - -OperationDomestic - - -OperationType - - -FlightType - - -SecondPilot - - -DepartureSameAsEvent - - -DepartureAirportId - - -DepartureCity - - -DepartureState - - -DepartureCountry - - -DepartureTime - - -DepartureTimeZone - - -DestinationSameAsLocal - - -DestinationAirportId - - -DestinationCity - - -DestinationState - - -DestinationCountry - - -FlightPhase - - -ReportedToICAO - - -EvacuationOccurred - - -AirFrameHoursSince - - -FlightSiteSeeing - - -FlightMedical - - -FlightMedicalType - - -{%%PARENT}("Aircraft") -AircraftDefaultData -100000 -^Aviation.EventC("Aircraft") -^Aviation.AircraftI -^Aviation.AircraftS -%Storage.Persistent -} - } diff --git a/cls/Aviation/Classification/Aviation.Classification.Utils.cls b/cls/Aviation/Classification/Aviation.Classification.Utils.cls index dadcd32..3f556f0 100644 --- a/cls/Aviation/Classification/Aviation.Classification.Utils.cls +++ b/cls/Aviation/Classification/Aviation.Classification.Utils.cls @@ -16,22 +16,22 @@ ClassMethod CreateClassifier() As %Status quit } - // create training and test set using a rather random split based on the modulo of the record ID + // Create training and test set using a rather random split based on the modulo of the record ID // Using the modulo operator ensures we'll get the same results each time (unlike using RandomFilter) set tTrainingSet = ##class(%iKnow.Filters.SqlFilter).%New(tDomId, "SELECT ':SQL:'||YEAR(EventDate)||':'||EventID AS ExternalID FROM Aviation.Event WHERE (ID # 10) <= 5") set tTestSet = ##class(%iKnow.Filters.SqlFilter).%New(tDomId, "SELECT ':SQL:'||YEAR(EventDate)||':'||EventID AS ExternalID FROM Aviation.Event WHERE (ID # 10) > 5") - // instantiate builder and configure for use with highest injury + // Instantiate builder and configure for use with highest injury set tBuilder = ##class(%iKnow.Classification.IKnowBuilder).%New("Aviation Events demo",tTrainingSet) set tBuilder.TestSet = tTestSet set tSC = tBuilder.%LoadMetadataCategories("HighestInjury") quit:$$$ISERR(tSC) - // note that "HighestInjury" is perhaps not that convenient to use as a category, as + // Note that "HighestInjury" is perhaps not that convenient to use as a category, as // for example, a "HighestInjury=Serious" record could well mention some minor injuries as well. - // populate the model with a few terms + // Populate the model with a few terms set tSC = tBuilder.%PopulateTerms(50) quit:$$$ISERR(tSC) set tSC = tBuilder.%AddEntity("crash site") @@ -39,11 +39,11 @@ ClassMethod CreateClassifier() As %Status set tSC = tBuilder.%AddTermsFromSQL("SELECT TOP 50 EntityValue AS Term FROM %iKnow_Objects.EntityUnique WHERE DomainID = "_tDomId_" AND EntityValue LIKE '%injur%' ORDER BY CorpusSpread DESC") quit:$$$ISERR(tSC) - // add more terms as you see fit + // Add more terms as you see fit // ... - // generate classifier class + // Generate classifier class set tSC = tBuilder.%CreateClassifierClass("Aviation.Classification.MyClassifier", 1, 1, 1) quit:$$$ISERR(tSC) @@ -66,29 +66,30 @@ ClassMethod OptimizeClassifier() As %Status set tDomId = $system.iKnow.GetDomainId("Aviation Events demo") - // restore a builder object from our class definition + // Restore a builder object from our class definition set tSC = ##class(%iKnow.Classification.Builder).%LoadFromDefinition("Aviation.Classification.MyClassifier", .tBuilder) quit:$$$ISERR(tSC) - // instantiate a builder object + // Instantiate a builder object set tOptimizer = ##class(%iKnow.Classification.Optimizer).%New() set tOptimizer.Builder = tBuilder - // load candidate entities + // Load candidate entities set tSC = ##class(%iKnow.Queries.EntityAPI).GetTopBM25(.tCandidates, tDomId, 1, 200) quit:$$$ISERR(tSC) - // skip the first 50, as we already added them in ..CreateClassifier() + + // Skip the first 50, as we already added them in ..CreateClassifier() for i=1:1:50 { kill tCandidates(i) } set tSC = tOptimizer.LoadTermsArray(.tCandidates, 2) quit:$$$ISERR(tSC) - // fire off the optimization process + // Fire off the optimization process set tOptimizer.Verbose = 1 set tSC = tOptimizer.Optimize(20) quit:$$$ISERR(tSC) write ! - // save updated class + // Save updated class set tSC = tOptimizer.SaveClassifier("Aviation.Classificaton.MyClassifier", 1) quit:$$$ISERR(tSC) @@ -121,7 +122,7 @@ ClassMethod TestClassifier() As %Status write !,"We got ",tRight," records right out of ",tTotal,! - // retrieve precision and recall metrics for this test result + // Retrieve precision and recall metrics for this test result set tSC = ##class(%DeepSee.PMML.Utils.TempResult).GetAggregatePrecisionMetrics(tResId,.tPrecision,.tMPrecision,.tRecall,.tMRecall,.tFMeasure,.tMFMeasure) quit:$$$ISERR(tSC) write !," micro-AVG macro-AVG" @@ -129,7 +130,7 @@ ClassMethod TestClassifier() As %Status write !,"Recall: ",$fnumber(tMRecall,"",2),"% ",$fnumber(tRecall,"",2),"%" write !,"F-measure: ",$fnumber(tMFMeasure,"",2),"% ",$fnumber(tFMeasure,"",2),"%",! - // drop test results + // Drop test results do ##class(%DeepSee.PMML.Utils).%DropResults(tResId) } catch (ex) { diff --git a/cls/Aviation/Crew.cls b/cls/Aviation/Crew.cls index 68e7190..b6c773b 100644 --- a/cls/Aviation/Crew.cls +++ b/cls/Aviation/Crew.cls @@ -1,11 +1,11 @@ /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This class represents the details on crew involved in events registered by the -/// National Transportation Safety Board.

-///

Note on the data: The dataset provided in this sample demo is only a lightweight +/// This class represents the details on aircraft involved in events registered by the +/// National Transportation Safety Board. +/// Note on the data: The dataset provided in this sample demo is only a lightweight /// subset of the full NTSB dataset, which is available from -/// http://www.ntsb.gov. This data is supplied -/// here for demonstration purposes only and neither intended nor warranted to be accurate.
-/// Courtesy: National Transportation Safety Board

+/// http://www.ntsb.gov. This data is supplied +/// here for demonstration purposes only and neither intended nor warranted to be accurate. +/// Courtesy: National Transportation Safety Board Class Aviation.Crew Extends %Persistent { @@ -41,63 +41,5 @@ Property SeatbeltUsed As %String(MAXLEN = 1); Property ShoulderHarnessUsed As %String(MAXLEN = 1); -Storage Default -{ - - -%%CLASSNAME - - -EventId - - -AircraftKey - - -CrewNumber - - -Age - - -Category - - -Injury - - -Sex - - -ToxicologyTestPerformed - - -MedicalCertificationDate - - -MedicalCertification - - -MedicalCertificationValid - - -Seat - - -SeatbeltUsed - - -ShoulderHarnessUsed - - -{%%PARENT}("Crew") -CrewDefaultData -100000 -^Aviation.AircraftC("Crew") -^Aviation.CrewI -^Aviation.CrewS -%Storage.Persistent -} - } diff --git a/cls/Aviation/Event.cls b/cls/Aviation/Event.cls index 0e49d40..1c1278d 100644 --- a/cls/Aviation/Event.cls +++ b/cls/Aviation/Event.cls @@ -1,11 +1,11 @@ /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This class represents events involving aircraft as registered by the -/// National Transportation Safety Board.

-///

Note on the data: The dataset provided in this sample demo is only a lightweight +/// This class represents the details on aircraft involved in events registered by the +/// National Transportation Safety Board. +/// Note on the data: The dataset provided in this sample demo is only a lightweight /// subset of the full NTSB dataset, which is available from -/// http://www.ntsb.gov. This data is supplied -/// here for demonstration purposes only and neither intended nor warranted to be accurate.
-/// Courtesy: National Transportation Safety Board

+/// http://www.ntsb.gov. This data is supplied +/// here for demonstration purposes only and neither intended nor warranted to be accurate. +/// Courtesy: National Transportation Safety Board Class Aviation.Event Extends %Persistent { @@ -111,168 +111,5 @@ Relationship Aircraft As Aviation.Aircraft [ Cardinality = children, Inverse = E Index PKINDEX On EventId [ PrimaryKey, Unique ]; -Storage Default -{ - - -%%CLASSNAME - - -EventId - - -NTSBId - - -Type - - -EventDate - - -EventTime - - -TimeZone - - -LocationCountry - - -LocationState - - -LocationCity - - -LocationCountryCode - - -LocationSiteZipCode - - -LocationCoordsLatitude - - -LocationCoordsLongitude - - -MidAir - - -OnGroundCollision - - -AirportName - - -AirportLocation - - -AirportDistance - - -AirportDirection - - -AirportElevation - - -LightConditions - - -SkyConditionNonCeiling - - -SkyConditionNonCeilingHeight - - -SkyConditionCeilingHeight - - -SkyConditionCeiling - - -Visibility - - -WeatherAirTemperature - - -WindDirection - - -WindDirectionIndicator - - -WindVelocity - - -WindVelocityIndicator - - -WindGustIndicator - - -WindGust - - -Altimeter - - -WeatherPrecipitation - - -InjuriesHighest - - -InjuriesGroundFatal - - -InjuriesGroundMinor - - -InjuriesGroundSerious - - -InjuriesTotalFatal - - -InjuriesTotalMinor - - -InjuriesTotalNone - - -InjuriesTotalSerious - - -InjuriesTotal - - -InvestigatingAgency - - -FAADistrictOffice - - -NarrativeFull - - -NarrativeSummary - - -NarrativeCause - - -^Aviation.EventD -EventDefaultData -100000 -^Aviation.EventD -^Aviation.EventI -^Aviation.EventS -%Storage.Persistent -} - } diff --git a/cls/Aviation/ReportDomain.cls b/cls/Aviation/ReportDomain.cls index f168b71..1329dd6 100644 --- a/cls/Aviation/ReportDomain.cls +++ b/cls/Aviation/ReportDomain.cls @@ -1,12 +1,11 @@ /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This class wraps all settings for the Aviation Events demo domain in a single XData block. -/// Check the documentation on "Domain Definitions" or the class reference of -/// %iKnow.DomainDefinition for more details.

-///

Note on the data: The dataset provided in this sample demo is only a lightweight -/// subset of the full NTSB dataset, which is available from -/// http://www.ntsb.gov. This data is supplied -/// here for demonstration purposes only and neither intended nor warranted to be accurate.
-/// Courtesy: National Transportation Safety Board

+/// This class represents the details on aircraft involved in events registered by the +/// National Transportation Safety Board. +/// Note on the data: The dataset provided in this sample demo is only a lightweight +/// subset of the full NTSB dataset, which is available from +/// http://www.ntsb.gov. This data is supplied +/// here for demonstration purposes only and neither intended nor warranted to be accurate. +/// Courtesy: National Transportation Safety Board Class Aviation.ReportDomain Extends %iKnow.DomainDefinition { diff --git a/cls/Aviation/UI/Investigator.cls b/cls/Aviation/UI/Investigator.cls index 4f4efe7..506c67a 100644 --- a/cls/Aviation/UI/Investigator.cls +++ b/cls/Aviation/UI/Investigator.cls @@ -1,8 +1,8 @@ Include %IKInclude /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This page represents a mockup interface for typing in new aviation event reports for the -/// Aviation.Event narrative columns. After typing in a report of a few +/// This page represents a mockup interface for typing in new aviation event reports for the +/// Aviation.Event narrative columns. After typing in a report of a few /// sentences and pressing the "process" button, the system will look for reports similar to the /// one being typed in using the basic similarity algorithm (first tab) and a slightly more /// elaborate matching-based approach (second tab). This matching-based approach constructs a @@ -12,21 +12,21 @@ Include %IKInclude /// the matching-based alternative demonstrates how other iKnow API calls can be used together /// from a simple interface. More specifically, the matching-based approach has the advantage /// non-exact matches also contribute to the similarity, at the cost of performance and slight -/// over-scoring of simple re-occurring words.

+/// over-scoring of simple re-occurring words. /// -///

When clicking one of the suggested "similar" reports, a popup shows the basic details of +/// When clicking one of the suggested "similar" reports, a popup shows the basic details of /// the similar event (time, location, aircraft, link to NTSB report) as well as the the contents /// of the existing report, with all entities (and CRCs) of the input text highlighted in this /// similar one. A second tab then reveals the presumed cause of that similar event as recorded /// by the NTSB, which may "help" the user get an idea of a likely cause for the event being -/// described in his manual input.

+/// described in his manual input. /// -///

Being a code sample, the code is supposed to be quite readable with some comments about +/// Being a code sample, the code is supposed to be quite readable with some comments about /// what is being achieved by specific line(s) of code, as well as suggesting extensions -/// developers might wish to make to make the demo perform better.

+/// developers might wish to make to make the demo perform better. /// -///

To set up the demo, run the following command from the terminal: -///

do ##class(Aviation.UI.Investigator).Setup()

+/// To set up the demo, run the following command from the terminal: +/// do ##class(Aviation.UI.Investigator).Setup() Class Aviation.UI.Investigator Extends %ZEN.Component.page { @@ -60,7 +60,7 @@ Property inputSource As %ZEN.Datatype.integer; /// A filter string to restrict the scope of the similarity search. /// Either use an InitialExpression or add code to populate this property, similar to the -/// filterPane and associated methods in %iKnow.UI.AbstractPortal +/// filterPane and associated methods in %iKnow.UI.AbstractPortal Property filter As %ZEN.Datatype.string(ZENURL = "FILTER"); /// The ID of the dictionary created as part of BuildSrcDictionary @@ -199,8 +199,8 @@ queryName="GetTopSourcesByDictionary" autoExecute="false" OnExecuteResultSet="Ex } -///

ZenMethod to process manual user input pText by the iKnow engine and store the -/// ID of the generated Virtual Source in inputSource.

+/// ZenMethod to process manual user input pText by the iKnow engine and store the +/// ID of the generated Virtual Source in inputSource. Method ProcessInput(pText As %String(MAXLEN=32767), pLanguage As %String) As %String [ ZenMethod ] { set tSC = $$$OK, tOldStatus = 0 @@ -208,7 +208,7 @@ Method ProcessInput(pText As %String(MAXLEN=32767), pLanguage As %String) As %St set tDomainId = ..reportDomain set tDomainName = $system.iKnow.GetDomainName(tDomainId) - // drop the previous virtual source created + // Drop the previous virtual source created do:..inputSource ##class(%iKnow.Source.Loader).DeleteVirtualSource(tDomainId, $zabs(..inputSource)) // create a simple configuration object for pLanguage, if none exists yet @@ -220,12 +220,12 @@ Method ProcessInput(pText As %String(MAXLEN=32767), pLanguage As %String) As %St quit:$$$ISERR(tSC) } - // process pText, loading it as a virtual source + // Process pText, loading it as a virtual source set tFullRef = "AviationInvestigatorInput "_$zdt($h) set tSC = $system.iKnow.IndexString(tDomainName, tFullRef, pText, tConfigName, 1, .vSrcId) quit:$$$ISERR(tSC) - // store the generated (virtual) source ID + // Store the generated (virtual) source ID set ..inputSource = vSrcId } catch (ex) { @@ -258,7 +258,7 @@ Method BuildSrcDictionary() As %Status [ ZenMethod ] set tDomainId = ..reportDomain set tDomainIdCause = ..causeDomain - // first kill existing dictionary + // First kill existing dictionary set tDictId = ##class(%iKnow.Matching.DictionaryAPI).GetDictionaryId(tDomainId, ..#IKNOWDICTNAME) set:tDictId>0 tSC = ##class(%iKnow.Matching.DictionaryAPI).DropDictionary(tDomainId, tDictId) quit:$$$ISERR(tSC) @@ -266,7 +266,7 @@ Method BuildSrcDictionary() As %Status [ ZenMethod ] set:tDictIdCause>0 tSC = ##class(%iKnow.Matching.DictionaryAPI).DropDictionary(tDomainIdCause, tDictIdCause) quit:$$$ISERR(tSC) - // now create a new one, containing all entities and CRCs of the current source + // Now create a new one, containing all entities and CRCs of the current source // NOTE: this is a very crude approach. refining this to all entities that are dominant // in the input text and/or not too common in the overall domain (such as "pilot" etc), // could improve the results. @@ -301,7 +301,7 @@ Method BuildSrcDictionary() As %Status [ ZenMethod ] } quit:$$$ISERR(tSC) - // now match all sources in the reports domain against this new dictionary + // Now match all sources in the reports domain against this new dictionary set tSC = ##class(%iKnow.Matching.MatchingAPI).MatchSources(tDomainId, ..filter, $lb(..dictId)) quit:$$$ISERR(tSC) @@ -319,16 +319,15 @@ ClientMethod refreshDictionaryAsync() [ Language = javascript ] var sc = zenPage.BuildSrcDictionary(); zen('tblDictionary').refreshContents(); - // also refresh source view panes, should they already be open before the matching process + // Also refresh source view panes, should they already be open before the matching process // finished at the end of BuildSrcDictionary(); zen('htmlSource').refreshContents(); zen('htmlCause').refreshContents(); } /// This client event, if present, is fired when the page -/// is first loaded or whenever it is resized.
-/// If this is called at load time, then load will -/// be true. +/// is first loaded or whenever it is resized. +/// If this is called at load time, then load will be true. ClientMethod onlayoutHandler(load) [ Language = javascript ] { zenPage.resizeGroups(load); @@ -383,7 +382,7 @@ Method DrawPercentage(pTable As %ZEN.Component.tablePane, pName As %String, pSee } /// Utility method to draw source metadata in a <tablePane> column for a given source. -/// pSeed is expected to be the name of the metadata field to display. +/// pSeed is expected to be the name of the metadata field to display. Method DrawMetadata(pTable As %ZEN.Component.tablePane, pName As %String, pSeed As %String) As %Status { set tExtId = $g(%query("extId"),$g(%query("externalId"))) @@ -394,7 +393,7 @@ Method DrawMetadata(pTable As %ZEN.Component.tablePane, pName As %String, pSeed } /// Client-side method refreshing appropriate sections of the popup window using the -/// srcId passed in. +/// srcId passed in. ClientMethod displaySourceClient(srcId) [ Language = javascript ] { zen('modSource').show(); @@ -412,7 +411,7 @@ ClientMethod summarize() [ Language = javascript ] zen('htmlSource').refreshContents(); } -///

Draws a number of event properties as a header for the popup.

+/// Draws a number of event properties as a header for the popup. Method DrawEventHeader(pSeed As %String) As %Status { set tSC = $$$OK @@ -445,11 +444,11 @@ Method DrawEventHeader(pSeed As %String) As %Status quit tSC } -///

Draws the contents of a source (report or cause, based on pSeed) as identified by +/// Draws the contents of a source (report or cause, based on pSeed) as identified by /// the value of selectedSource. The source is summarized if /// summaryLength is non-zero (interpreted as the number of sentences) and /// any matches against the dictionary created by BuildSrcDictionary is -/// highlighted.

+/// highlighted. Method DrawSource(pSeed As %String) As %Status { set tSC = $$$OK @@ -476,7 +475,7 @@ Method DrawSource(pSeed As %String) As %Status set:pSeed="CAUSE" tSC = ##class(%iKnow.Matching.MatchingAPI).MatchSource(tDomainId, tSrcId, $lb(tDictId)) quit:$$$ISERR(tSC) - w "

" + w "" set srcObj = ##class(%iKnow.Objects.Source).PKINDEXOpen(tDomainId, tSrcId) set sentBase = srcObj.FirstSentenceId-1 @@ -504,7 +503,7 @@ Method DrawSource(pSeed As %String) As %Status } w:(prevPos=(sentBase+srcObj.SentenceCount)) " ..." - w "

" + w "" } catch (ex) { set tSC = ex.AsStatus() @@ -589,7 +588,7 @@ table#metadata td.left { } /// Sets up the Aviation Investigator demo. If the Standalone Aviation demo was already -/// set up through Aviation.Utils, that domain will be used. +/// set up through Aviation.Utils, that domain will be used. ClassMethod Setup() As %Status { try { diff --git a/cls/Aviation/Utils.cls b/cls/Aviation/Utils.cls index 4c2562b..94a7ec7 100644 --- a/cls/Aviation/Utils.cls +++ b/cls/Aviation/Utils.cls @@ -1,26 +1,24 @@ Include %IKPublic /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. -///

This class groups code for setting up two demos:

-/// +/// security settings allow accessing the UI classes. /// -///

The classes in this package represent events involving aircraft as registered by the -/// National Transportation Safety Board.

-///

Note on the data: The dataset provided in this sample demo is only a lightweight +/// The classes in this package represent events involving aircraft as registered by the +/// National Transportation Safety Board. +/// Note on the data: The dataset provided in this sample demo is only a lightweight /// subset of the full NTSB dataset, which is available from -/// http://www.ntsb.gov. This data is supplied +/// http://www.ntsb.gov. This data is supplied /// here for demonstration purposes only and neither intended nor warranted to be accurate.
-/// Courtesy: National Transportation Safety Board

+/// Courtesy: National Transportation Safety Board Class Aviation.Utils Extends %RegisteredObject { @@ -75,9 +73,9 @@ ClassMethod SetupCube() As %Status quit tSC } -///

Sets up a regular iKnow domain and loads the Aviation demo dataset into it by calling the -/// Aviation.ReportDomain %Build() method after enabling it and configuring CSP access -/// to %iKnow UI classes for the SAMPLES web application.

+/// Sets up a regular iKnow domain and loads the Aviation demo dataset into it by calling the +/// Aviation.ReportDomain %Build() method after enabling it and configuring CSP access +/// to %iKnow UI classes for the SAMPLES web application. ClassMethod SetupStandalone(pLoadTermLists As %Boolean = 1, pVerbose As %Boolean = 1) As %Status { try { @@ -107,8 +105,7 @@ ClassMethod SetupStandalone(pLoadTermLists As %Boolean = 1, pVerbose As %Boolean /// Returns the dictionaries to be used for matching with the Aviation dataset in a /// pseudo-form, so they can be used both for building Term Lists (see -/// CreateTermLists) and iKnow Dictionaries -/// (CreateIKnowDictionaries). +/// CreateTermLists method and iKnow Dictionaries (CreateIKnowDictionaries method) ClassMethod GetAviationDictionaries(Output pDictionaries) As %Status [ Internal ] { kill pDictionaries @@ -273,17 +270,17 @@ ClassMethod CreateTermLists() As %Status quit tSC } -///

Loads pMaxRecords aviation event records from the official NTSB database, which -/// can be downloaded as a Microsoft Access file from www.ntsb.gov. -/// The Access file needs to be exposed through ODBC using a DSN named pDSN. Any existing +/// Loads pMaxRecords aviation event records from the official NTSB database, which +/// can be downloaded as a Microsoft Access file from www.ntsb.gov. +/// The Access file needs to be exposed through ODBC using a DSN named pDSN. Any existing /// information for a given event will be overwritten, so loading from the "update" databases on -/// ntsb.gov will just append to your existing database.

-///

Set pMaxRecords to 0 to load all events from the database and use pClearFirst -/// to specify whether existing events should be erased prior to the load. Using pPrefList, -/// and pWhereClause, you can list specific events which need to be selected, as records -/// are selected randomly from the full database. With pSkipWhenEmpty, a list of properties +/// ntsb.gov will just append to your existing database. +/// Set pMaxRecords to 0 to load all events from the database and use pClearFirst +/// to specify whether existing events should be erased prior to the load. Using pPrefList, +/// and pWhereClause, you can list specific events which need to be selected, as records +/// are selected randomly from the full database. With pSkipWhenEmpty, a list of properties /// of the event, aircraft and crew records can be supplied which needs to be non-null for the record -/// to be selected.

+/// to be selected. ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Integer = 1200, pClearFirst As %Boolean = 1, pVerbose As %Boolean = 1, pSkipWhenEmpty As %List = {$lb($lb("NarrativeFull","LocationCoordsLongitude","InjuriesHighest","MidAir","SkyConditionNonCeiling"),$lb("Damage","AircraftCategory","FlightType"))}, pWhereClause As %String = "", pPrefList As %List = {$lb("20020611X00850","20030728X01207","20010123X00341")}) As %Status { set tSC = $$$OK @@ -302,7 +299,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int set tSC = tConnection.Connect(pDSN,"","") quit:$$$ISERR(tSC) - // prepare main event statements + // Prepare main event statements set tEventResultSet = ##class(%ResultSet).%New("%DynamicQueryGW:SQLGW") set tSQLPref = "SELECT *, -1 As FakeOrder FROM events WHERE ev_id = '"_$lts(pPrefList,"' OR ev_id = '")_"'" set tSQL = "SELECT *, (ev_time*ev_time) MOD 79 As FakeOrder FROM events WHERE " _ $s(pWhereClause="":"ev_year >= 2000", 1:pWhereClause) @@ -321,7 +318,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int set tSC = tEventResultSet.Execute() quit:$$$ISERR(tSC) - // prepare other statements + // Prepare other statements set tNarrativeResultSet = ##class(%ResultSet).%New("%DynamicQueryGW:SQLGW") set tAircraftResultSet = ##class(%ResultSet).%New("%DynamicQueryGW:SQLGW") set tCrewResultSet = ##class(%ResultSet).%New("%DynamicQueryGW:SQLGW") @@ -427,7 +424,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int set tEvent.WindVelocityIndicator = $case(tValue, "CALM":"Calm", "LVAR":"Light and variable", "SPEC":"Special", "UNK":"Unknown", "V":"Variable", :tValue) - // load first narrative for this event + // Load first narrative for this event set tSC = tNarrativeResultSet.Prepare("SELECT * FROM narratives WHERE ev_id = '"_tEventId_"' AND Aircraft_Key = 1",, tConnection) quit:$$$ISERR(tSC) set tSC = tNarrativeResultSet.Execute() @@ -449,7 +446,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int do tNarrativeResultSet.Close() - // verify pSkipWhenEmpty elements + // Verify pSkipWhenEmpty elements set ptr=0, tSkip=0 while $listnext(tEventProps, ptr, tProp) { if ($property(tEvent, tProp)="") { @@ -460,7 +457,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int continue:tSkip - // loop through aircraft for this event + // Loop through aircraft for this event set tSC = tAircraftResultSet.Prepare("SELECT * FROM aircraft WHERE ev_id = '"_tEventId_"'",, tConnection) quit:$$$ISERR(tSC) set tSC = tAircraftResultSet.Execute() @@ -549,7 +546,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int set tAircraft.SeatsTotal = $zstrip(tAircraftResultSet.Get("total_seats"),"<>W") set tAircraft.SecondPilot = $zstrip(tAircraftResultSet.Get("second_pilot"),"<>W") - // verify pSkipWhenEmpty elements + // Verify pSkipWhenEmpty elements set ptr=0, tSkip=0 while $listnext(tAircraftProps, ptr, tProp) { if ($property(tAircraft, tProp)="") { @@ -593,7 +590,7 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int set tCrew.ToxicologyTestPerformed = $zstrip(tCrewResultSet.Get("crew_tox_perf"),"<>W") - // verify pSkipWhenEmpty elements + // Verify pSkipWhenEmpty elements set ptr=0, tSkip=0 while $listnext(tCrewProps, ptr, tProp) { if ($property(tCrew, tProp)="") { @@ -606,12 +603,12 @@ ClassMethod LoadFromNTSB(pDSN As %String = "AviationAccess", pMaxRecords As %Int } do tCrewResultSet.Close() - // skip if no Crew entries left + // Skip if no Crew entries left continue:'tAircraft.Crew.Count() } do tAircraftResultSet.Close() - // skip if no Aircraft entries left + // Skip if no Aircraft entries left if ('tEvent.Aircraft.Count()) { set tSkipCount = tSkipCount+1 continue