From 24e404158fea60d335e912d7f964cdb22f1ca134 Mon Sep 17 00:00:00 2001 From: Wojtek Dziegielewski Date: Sat, 15 Jun 2019 21:17:41 -0400 Subject: [PATCH] Adjust for Data Conveyer 3.1.0. --- .../DataConveyer_AggregateTokens.csproj | 4 ++-- DataConveyer_AggregateTokens/FileProcessor.cs | 4 ++-- README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DataConveyer_AggregateTokens/DataConveyer_AggregateTokens.csproj b/DataConveyer_AggregateTokens/DataConveyer_AggregateTokens.csproj index c73ffd6..4c0f066 100644 --- a/DataConveyer_AggregateTokens/DataConveyer_AggregateTokens.csproj +++ b/DataConveyer_AggregateTokens/DataConveyer_AggregateTokens.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,7 +6,7 @@ - + diff --git a/DataConveyer_AggregateTokens/FileProcessor.cs b/DataConveyer_AggregateTokens/FileProcessor.cs index 0b98de0..dce1127 100644 --- a/DataConveyer_AggregateTokens/FileProcessor.cs +++ b/DataConveyer_AggregateTokens/FileProcessor.cs @@ -32,7 +32,7 @@ internal FileProcessor(string inLocation, string outFile) GlobalCacheElements = new string[] { "TokenSummary" }, //a single element - a dictionary - Dict> InputDataKind = KindOfTextData.XML, IntakeReaders = () => Directory.GetFiles(_inLocation, "*.xml").Select(f => File.OpenText(f)), //note that we're neglecting to dispose the stream readers here (not a production code) - XmlJsonIntakeSettings = "RecordNode|Token,IncludeExplicitText|true", + XmlJsonIntakeSettings = "RecordNode|Token,IncludeExplicitText|true,IncludeAttributes|true", ExplicitTypeDefinitions = "__explicitText__|I", //in our case, explicit text in Token node contains integer value ClusterMarker = (rec,pRec,n) => pRec == null ? true : rec.SourceNo != pRec.SourceNo, // each file (source) constitutes a cluster MarkerStartsCluster = true, //predicate (marker) matches the first record in cluster @@ -103,7 +103,7 @@ private IEnumerable CumulateTokenData(ICluster cluster) //Regular cluster - cumulate data in the global cache foreach (var rec in cluster.Records) { - var color = (string)rec["color"]; + var color = (string)rec["@color"]; //keys originating from attributes are prepended with @ (by default) var value = (int)rec["__explicitText__"]; tokenSummary.AddOrUpdate(color, (1, value), (c, t) => (t.count + 1, t.total + value)); diff --git a/README.md b/README.md index 51620ff..0911928 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # DataConveyer_AggregateTokens DataConveyer_AggregateTokens is a console application to demonstrate how Data Conveyer can be -used to accumulate data extracted from a sequence of input files. +used to accumulate data extracted from a sequence of input files. There are 10 sample XML files located in ...Data folder. Data Conveyer will process all these files and identify tokens contained in them (in this example, tokens are just Token nodes). The