Ejemplo n.º 1
0
        /// <summary>
        /// Allows <see cref="schema"/> upgrade after additional analysis of the stored <see cref="entries"/>. This should be called after <see cref="SetEntries(SourceTable)"/>.
        /// </summary>
        /// <param name="analyser">Content analyser to be used</param>
        public void RefineSchema(CellContentAnalysis analyser)
        {
            //  DataTable output = new DataTable("schemaTable");

            foreach (var property in properties.items)
            {
                var propData = entries.GetAllValuesForProperty(property);

                if (propData.Count == 0)
                {
                }
                else
                {
                    RefinedPropertyStats propertyStats = new RefinedPropertyStats();

                    foreach (var data in propData)
                    {
                        CellContentInfo info = analyser.DetermineContentType(data);

                        propertyStats.Assign(info);
                    }

                    propertyStats.Compute();

                    propertyStats.Deploy(property);

                    //  GetColumn(property, output, propertyStats);
                }
            }
        }
Ejemplo n.º 2
0
        //public override MetaTableSchema GetTableSchema()
        //{
        //    return null;
        //    //throw new NotImplementedException();
        //}

        /// <summary>
        /// Constructs the specified source table.
        /// </summary>
        /// <param name="sourceTable">The source table.</param>
        /// <param name="task">The task.</param>
        /// <returns></returns>
        public override MetaTable Construct(SourceTable sourceTable, TableExtractionTask task)
        {
            if (UseUniversalConstructors)
            {
                return(base.Construct(sourceTable, task));
            }

            MetaTable table = new MetaTable(GetTableDescription());

            var rows = sourceTable.GetContentCells();
            //var data = sourceTable.GetContentCells();

            Boolean IsMultiEntryList = false;

            if (sourceTable.Width > 2)
            {
                IsMultiEntryList = true;
            }

            if (IsMultiEntryList)
            {
                table.description.format = MetaTableFormatType.vertical;

                var entryIDProperty = table.properties.Add("ID");
                entryIDProperty.index = EntryID;

                var EntryPropertyTerm = table.properties.Add("Term");
                EntryPropertyTerm.index = PropertyX;

                var EntryPropertyValue = table.properties.Add("Value");
                EntryPropertyValue.index = ValueX;

                foreach (var row in rows)
                {
                    table.entries.CreateEntry(row, true);
                }
            }
            else
            {
                table.description.format = MetaTableFormatType.horizontal;

                Dictionary <String, MetaTableProperty> propDict = new Dictionary <string, MetaTableProperty>();

                List <String> propertyValues = new List <string>();

                foreach (var row in rows)
                {
                    String propertyName  = row[PropertyX].Value;
                    String propertyValue = row[ValueX].Value;
                    propertyValues.Add(propertyValue);

                    var vInfo        = sourceContentAnalysis.DetermineContentType(propertyValue, true);
                    var metaProperty = table.properties.Add(propertyName);
                    metaProperty.ContentType = vInfo.type;
                    propDict.Add(propertyName, metaProperty);

                    RefinedPropertyStats pStats = new RefinedPropertyStats();
                    pStats.Assign(vInfo);
                    pStats.Compute();
                    pStats.Deploy(metaProperty);
                }

                MetaTableEntry entry = table.entries.CreateEntry(propertyValues, true);
            }

            return(table);
        }