Exemplo n.º 1
0
        /// <summary>
        /// Prepares the and construct.
        /// </summary>
        /// <param name="task">The task.</param>
        /// <param name="output">The output.</param>
        public void PrepareAndConstruct(TableExtractionTask task, List <TableExtractionChain> output)
        {
            //List<SourceTable> sourceTables =

            //var sourceDict = output.ToDictionary(x => x.source);


            switch (task.multiNodePolicy)
            {
            case TaskMultiNodePolicy.AsSingleTableRows:
            case TaskMultiNodePolicy.AsSignleTableColumns:
                var st = output.Select(x => x.source).ToList();
                output.Clear();

                SourceTable sti   = st[0];
                SourceTable final = sti;
                for (int i = 1; i < st.Count; i++)
                {
                    if (task.multiNodePolicy == TaskMultiNodePolicy.AsSingleTableRows)
                    {
                        final = final.MergeAsRows(st[i]);
                    }
                    else
                    {
                        final = final.MergeAsColumns(st[i]);
                    }
                }

                TableExtractionChain chain = new TableExtractionChain()
                {
                    source = final,
                    name   = task.resultTableNamePrefix
                };

                //sourceTables.Add(final);


                //  if (firstMetaTable == null) firstMetaTable = ch.meta;

                output.Add(chain);

                break;

            default:
            case TaskMultiNodePolicy.AsSeparatedTables:
//                    foreach (var ch in output)
//                    {
//                        sourceTables.Add(ch.source);
////                        ch.meta = Construct(ch.source, task);
//                       // if (firstMetaTable == null) firstMetaTable = ch.meta;
//                    }
                break;
            }

            var mode = task.score.executionMode;

            for (int i2 = 0; i2 < output.Count; i2++)
            {
                var metaDescription = ConstructDescription(output[i2].source, task);
                if (mode != ExtractionTaskEngineMode.Training)
                {
                    var metaTable = Construct(output[i2].source, task);
                    if (metaTable != null)
                    {
                        metaTable.ExtraInfoEntries.Merge(task.ExtraInfoEntries);
                        metaTable.ExtraInfoEntries.Add(MetaTable.EXTRAINFOENTRYKEY_TASKNAME, task.name);
                        metaTable.ExtraInfoEntries.Add(MetaTable.EXTRAINFOENTRYKEY_EXTRACTORNAME, task.ExtractorName);
                    }
                    if (mode == ExtractionTaskEngineMode.Validation)
                    {
                        if (metaTable.Comment.isNullOrEmpty())
                        {
                            metaTable.Comment = "Constructed by " + GetType().Name;
                        }
                    }
                    AfterConstruction(metaTable, task);
                    output[i2].meta = metaTable;
                }
            }
        }