Esempio n. 1
0
 private void RaiseIfTextParseDidNotSendEndText(ITextRender render)
 {
     if (!render.IsTranslationFinished())
     {
         throw new ArgumentException("Text parser did not send end at the end!");
     }
 }
Esempio n. 2
0
        public String SaveOutput(ITextRender output)
        {
            //String help = output.GetContent();

            PropertyCollection pc       = output.getContentBlocks(true, reporting.format.reportOutputFormatName.textMdFile);
            String             mainPath = "";

            foreach (Object key in pc.Keys)
            {
                String k       = key.toStringSafe();
                String content = pc[key].ToString();
                String fn      = GetFilename(k);

                /*
                 * String fn = filename;
                 *
                 * if (k != nameof(templateFieldSubcontent.main))
                 * {
                 *  fn = fn + "_" + k.getCleanFilepath();
                 * }
                 * fn = fn.ensureEndsWith(".txt");
                 */
                if (k == nameof(templateFieldSubcontent.main))
                {
                    mainPath = fn;
                }

                folder.SaveText(content, fn, Data.enums.getWritableFileMode.overwrite, "Reference for " + scopeType.Name + " [" + k + "]", true);
            }



            return(mainPath);
        }
Esempio n. 3
0
        public void TestTypes(ITextRender output)
        {
            foreach (var pair in RelatedTypes.registry)
            {
                pair.Value.Test();
            }


            foreach (var pair in RelatedTypes.registry)
            {
                output.AppendLine("Type: " + pair.Key.GetCleanTypeName());
                output.nextTabLevel();
                var entryRoot = RelatedTypes.Get(pair.Key);

                foreach (var pi in pair.Value.ClassTypeProperties)
                {
                    var entry = RelatedTypes.Get(pi.PropertyType);
                    if (!entry.XmlSerializationOk)
                    {
                        output.AppendLine("Property: " + pi.PropertyType.GetCleanTypeName() + " " + pi.Name);
                        output.AppendLine(entry.Message.ToString());
                    }
                }


                if (!entryRoot.XmlSerializationOk)
                {
                    output.AppendLine("Problems: ");
                    output.AppendLine(entryRoot.Message.ToString());
                }

                output.prevTabLevel();
            }
        }
Esempio n. 4
0
        public TextRenderForm(ITextRender textRender, object[] fields)
        {
            InitializeComponent();
            cols = fields;

            // ITextRender
            {
                if (textRender == null)
                {
                    this.textBox1.Text = "";
                }
                else
                {
                    this.textBox1.Text = textRender.Expression.ToString();
                }
            }

            // ISimpleTextRender
            IToolTipTextRender render = textRender as IToolTipTextRender;

            if (render == null)
            {
                render = new ToolTipTextRender();
            }

            string[] row1 = new string[] { "DynamicPlacement", render.DynamicPlacement.ToString() };
            string[] row2 = new string[] { "MinimizeOverlap", render.MinimizeOverlap.ToString() };
            string[] row3 = new string[] { "RemoveDuplicate", render.RemoveDuplicate.ToString() };
            object[] rows = new object[] { row1, row2, row3 };
            foreach (string[] rowArray in rows)
            {
                this.dataGridView2.Rows.Add(rowArray);
            }
        }
Esempio n. 5
0
        public void WriteJSON(ITextRender output, MetaEntityNamespaceCollection namespaces)
        {
            var instructions = ConvertToInstructions(namespaces);
            MetaPropertyInstruction rootInstruction = new MetaPropertyInstruction("", instructions);

            rootInstruction.WriteToOutput(output, true);
        }
        public void AfterConstruction(MetaTable metaTable, TableExtractionTask task, ITextRender logger)
        {
            switch (task.score.executionMode)
            {
            default:
                break;

            case ExtractionTaskEngineMode.Validation:


                task.score.CurrentEntry().metaTable.Add(metaTable);

                break;

            case ExtractionTaskEngineMode.Application:

                task.score.CurrentEntry().metaTable.Add(metaTable);

                //if (task.tableDescription == null)
                //{
                //    var sourceDesc = sourceContentAnalysis.GetDescription(sourceTable);
                //    task.tableDescription = new imbSCI.DataExtraction.MetaTables.Descriptors.MetaTableDescription(sourceDesc, imbSCI.DataExtraction.MetaTables.Descriptors.MetaTableFormatType.vertical);
                //}


                break;
            }
        }
Esempio n. 7
0
        //public static ITextRender getRenderFor(reportAPI api)
        //{
        //}

        public static ITextRender getRenderFor(reportAPI api)
        {
            ITextRender output = null;

            switch (api)
            {
            case reportAPI.imbXmlHtml:
                output = new builderForHtml();
                break;

            //case reportAPI.EEPlus:
            //    output = new builderForTableDocument();
            //    break;
            case reportAPI.textBuilder:
                output = new builderForText();
                break;

            default:
                output = new builderForMarkdown();
                break;
            }
            output.settings.api = api;

            return(output);
        }
Esempio n. 8
0
        public static void DescribeModule(this ISpiderModuleBase module, ITextRender output)
        {
            output.open("p", "Module [" + module.name + "]", module.description);

            output.AppendPair("Class name", module.GetType().Name, true, ": ");

            output.AppendPair("Description", module.description, true, ": ");


            if (module is spiderLayerModuleBase)
            {
                spiderLayerModuleBase module_spiderLayerModuleBase = (spiderLayerModuleBase)module;
                foreach (var l in module_spiderLayerModuleBase.layers)
                {
                    l.DescribeLayer(output);
                }
            }


            output.AppendPair("Active rules", module.CountRules(spiderEvalRuleResultEnum.active), true, ": ");

            output.AppendPair("Passive rules", module.CountRules(spiderEvalRuleResultEnum.passive), true, ": ");

            foreach (IRuleBase md in module.rules)
            {
                md.DescribeRule(output);
            }

            module.GetUserManual(output, "", false, true);

            output.close();
        }
        /// <summary>
        /// Writes a summary report into ITextRender
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="sb">The sb.</param>
        /// <param name="summaryTitle">The summary title.</param>
        /// <returns></returns>
        public static String reportSummary(this Exception ex, ITextRender sb = null, String summaryTitle = "")
        {
            if (sb == null)
            {
                sb = new builderForMarkdown();
            }
            if (String.IsNullOrEmpty(summaryTitle))
            {
                summaryTitle = "Exception" + ex.GetType().Name;
            }

            //sb.open(htmlTagName.div, htmlClassForReport.noteContainer, htmlIdForReport.innerException);

            sb.AppendPair(summaryTitle + " message: ", ex.Message, true, "");

            sb.Append(summaryTitle + " stack: ", appendType.heading_3, true);
            //, htmlTagName.p, , "", false);

            ex.StackTrace.cleanStackTrace(sb);

            callerInfo ci = new callerInfo();

            sb.AppendLine(ex.Source);

            sb.AppendLine(ex.StackTrace);

            // sb.close();

            return(sb.ToString());
        }
        /// <summary>
        /// Gets the user manual for table.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="output">The output.</param>
        /// <param name="directInfo">The direct information.</param>
        /// <param name="skipUnDescribed">if set to <c>true</c> [skip un described].</param>
        public static void GetUserManualForTable(this DataTable dataObject, ITextRender output, String directInfo = "", Boolean skipUnDescribed = true)
        {
            output.AppendHeading("DataTable: " + dataObject.GetTitle(), 1);

            AppendIf(output, directInfo, "Comment: ");
            AppendIf(output, dataObject.GetDescription(), "Table description: ");

            output.AppendLine("This is automatically generated description of columns of DataTable [" + dataObject.TableName + "]");
            output.AppendHorizontalLine();

            AppendIf(output, dataObject.GetClassName(), "Table shema source: ");
            //output.AppendIf(dataObject.Rows.Count, "Table shema source: ");

            foreach (DataColumn dc in dataObject.Columns)
            {
                //output.AppendHeading("DataColumn -> [" + dc.ColumnName + "]", 2);

                var spe = dc.ExtendedProperties[templateFieldDataTable.col_spe] as settingsPropertyEntry;
                if (spe == null)
                {
                    spe = new settingsPropertyEntry(dc);
                    //spe.displayName = dc.Caption;
                    //spe.name = dc.ColumnName;
                    //spe.description = dc.GetDesc();
                    //spe.type = dc.DataType;
                    //spe.categoryName = dc.GetGroup();
                    //spe.format = dc.GetFormat();
                    //spe.letter = dc.GetLetter();
                    //spe.aggregation = dc.GetAggregation();
                    ////spe.index = dc.Ordinal;
                    //spe.importance = dc.GetImportance();
                    //spe.expression = dc.Expression;
                    //spe.unit = dc.GetUnit();
                    //spe.priority = dc.Ordinal;
                    //spe.width = dc.GetWidth();
                }

                GetUserManualSPE(spe, output);

                // dc.GetSPE().GetUserManual(output);
            }

            output.AppendHorizontalLine();

            var addInfo = dataObject.GetAdditionalInfo();

            output.AppendPairs(addInfo, false, " => ");

            var extraLines = dataObject.GetExtraDesc();

            if (Enumerable.Any <string>(extraLines))
            {
                output.AppendHorizontalLine();

                output.AppendList(extraLines, true);
            }

            //dataObject.GetDescription();
        }
Esempio n. 11
0
 public void Describe(ITextRender output)
 {
     output.AppendHeading("Document selection query", 2);
     //  if (ApplyDomainLevelLimits) output.AppendLabel("Apply limit on domain level");
     output.AppendPair("Size limit", SizeLimit, true, "");
     output.AppendPair("Trashold limit", TrasholdLimit, true, "");
     output.AppendPair("Query Terms", QueryTerms, true, "");
 }
        public metaExternalBlock AddExternalContent(ITextRender textBuilder, string title, string undertitle)
        {
            metaExternalBlock output = new metaExternalBlock(textBuilder, title, undertitle);

            output.parent = this;
            blocks.Add(output);
            return(output);
        }
Esempio n. 13
0
 public ViewBase(Document doc, ITextRender r, Padding padding)
 {
     this._Padding          = padding;
     this.Document          = doc;
     this.render            = r;
     this.SrcChanged       += new EventHandler((s, e) => { });
     this.PageBoundChanged += new EventHandler((s, e) => { });
 }
 public static void AppendIf(this ITextRender output, String content, String prefix = "")
 {
     if (content.isNullOrEmpty())
     {
         return;
     }
     output.AppendLine(prefix + content);
 }
Esempio n. 15
0
 public void Deploy(ITextRender _output, HtmlNodeValueExtractionSettings _valueExtraction, CellContentAnalysis _sourceContentAnalysis, folderNode _folder)
 {
     output                = _output;
     valueExtraction       = _valueExtraction;
     sourceContentAnalysis = _sourceContentAnalysis;
     folder                = _folder;
     universalMetaTableConstructor.Deploy(sourceContentAnalysis, valueExtraction);
 }
 /// <summary>
 /// Sets default evaluation logger
 /// </summary>
 /// <param name="_logger">The logger.</param>
 public void SetLogger(ITextRender _logger)
 {
     logger = _logger;
     foreach (var pair in this)
     {
         pair.Value.SetLogger(logger);
     }
 }
 public void Describe(ITextRender textRender)
 {
     textRender.AppendPair(nameof(Count), Count);
     textRender.AppendPair(nameof(Mean), Mean);
     textRender.AppendPair(nameof(Variance), Variance);
     textRender.AppendPair(nameof(StandardDeviation), StandardDeviation);
     textRender.AppendPair(nameof(Maximum), Maximum);
     textRender.AppendPair(nameof(Minimum), Minimum);
 }
Esempio n. 18
0
 public void Report(ITextRender output)
 {
     output.AppendLine(BaseUrl);
     if (username != "")
     {
         output.AppendLine(username);
         output.AppendLine(password);
     }
 }
        /// <summary>
        /// Reports public properties and returns the ones that are not supported/reported
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="output">The output.</param>
        /// <param name="onlyDeclared">if set to <c>true</c> [only declared].</param>
        /// <param name="heading">The heading.</param>
        /// <returns></returns>
        public static List <PropertyInfo> ReportBase <T>(this T instance, ITextRender output, Boolean onlyDeclared = true, String heading = "") where T : class
        {
            List <PropertyInfo> plist = instance.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).ToList();

            if (output == null)
            {
                return(plist);
            }
            if (!heading.isNullOrEmpty())
            {
                output.AppendHeading(heading, 1);
                output.nextTabLevel();
            }

            foreach (var pi in plist.ToList())
            {
                Boolean removePi = true;
                if (onlyDeclared && pi.DeclaringType != instance.GetType())
                {
                    continue;
                }

                Object vl = pi.GetValue(instance, null);

                if (pi.PropertyType.IsValueType || pi.PropertyType == typeof(String))
                {
                    output.AppendLine(pi.Name + "\t\t\t" + vl.toStringSafe());
                }
                else if (vl is List <String> stringList)
                {
                    output.AppendLine(pi.Name + "\t\t\t" + stringList.toCsvInLine());
                }
                else if (vl is rangeFinder range)
                {
                    if (range.IsLearned)
                    {
                        range.Report(output, pi.Name, "");
                    }
                }
                else
                {
                    removePi = false;
                }
                if (removePi)
                {
                    plist.Remove(pi);
                }
            }

            if (!heading.isNullOrEmpty())
            {
                output.prevTabLevel();
            }

            return(plist);
        }
        //protected Dictionary<CellContentType, Double> rate { get; set; } = new Dictionary<CellContentType, Double>();

        //protected Dictionary<CellContentType, Int32> frequency { get; set; } = new Dictionary<CellContentType, int>();

        public void Report(folderNode folder, ITextRender output)
        {
            List <System.Reflection.PropertyInfo> plist = this.ReportBase(output, false);

            output.AppendLine("Cell content type counter:");
            output.AppendLine("-- root:");
            cellContentTypeCounter.Report(output);
            output.AppendLine("-- real:");
            cellContentRealTypeCounter.Report(output);
        }
 public void Report(rangeFinder ranger, ITextRender output, String rangeName, String prefix)
 {
     output.AppendLine("Range [" + rangeName + "]");
     output.nextTabLevel();
     foreach (var pair in ranger.GetDictionary(prefix))
     {
         output.AppendPair(pair.Key, pair.Value.ToString("F3"));
     }
     output.prevTabLevel();
 }
Esempio n. 22
0
        public override IExeAppend execute(IRenderExecutionContext context, ITextRender render)
        {
            foreach (exeAppendTemplateBundleItem item in items)
            {
                List <string> files = item.getFromSource(context, render, target, targetFilename);
                item.setToTarget(files, context, operation, target, targetFilename);
            }

            return(this);
        }
Esempio n. 23
0
        /// <summary>
        /// Ubacuje opis HtmlNode-a u izvestaj prema ugradjenom sablonu
        /// </summary>
        /// <param name="node">HtmlNode objekat koji se opisuje</param>
        /// <param name="report">Izvestaj u kome se opisuje</param>
        /// <param name="isExpandedMode">Da li je rec o prosirenom ili skracenom izvestaju</param>
        public static void htmlNodeReport(this HtmlNode node, ITextRender report, Boolean isExpandedMode)
        {
            report.open(nameof(htmlTagName.div));
            Int32 childs = node.ChildNodes.Count;

            //report.AppendPairs(node, node.XPath + " " + node.Name + " (ch:" + childs + ")", "NodeType");
            report.AppendPair("Inner text", node.InnerText.toWidthMaximum(100));
            report.AppendPair("Inner HTML", node.InnerHtml.toWidthMaximum(100));
            report.close();
        }
Esempio n. 24
0
        public ITextRender Report(ITextRender output = null)
        {
            if (output == null)
            {
                output = new builderForMarkdown();
            }

            var scores = items.Select(x => x.score);

            output.AppendHeading("Granularity");

            var   distinct = items.GetDistinctScores();
            Int32 dC       = distinct.Count();

            output.AppendPair("Distinct", dC);
            output.AppendPair("Entries", scores.Count());
            Double r = (Double)dC.GetRatio(scores.Count());

            output.AppendPair("Distinct / Entries", r);

            output.AppendHeading("Cumulative histogram");


            for (int i = 1; i < 11; i++)
            {
                Double l_min = (i - 1).GetRatio(10);
                Double l_max = i.GetRatio(10);
                var    bin   = scores.Where(x => (x > l_min) && (x < l_max));
                Double per   = bin.Count().GetRatio(scores.Count());
                output.AppendPair("Bin [" + i + "][" + l_max.ToString("F2") + "]", per.ToString("P2"));
            }

            output.AppendHeading("Descriptive statistics");

            DescriptiveStatistics desc = scores.GetStatistics(true);

            desc.Describe(output);



            output.AppendHeading("Document selection result");

            foreach (DocumentSelectResultEntry result in items)
            {
                output.AppendLine(result.score.ToString("F5") + "\t\t" + result.AssignedID);
            }

            output.AppendHorizontalLine();

            query.Describe(output);

            output.AppendHorizontalLine();

            return(output);
        }
Esempio n. 25
0
 public void Draw(ITextRender render)
 {
     if (this.Enabled && this.Rectangle != Rectangle.Empty)
     {
         Rectangle gripperRect = this.Rectangle;
         double    radius      = gripperRect.Width / 2;
         Point     point;
         point = new Point(gripperRect.X + radius, gripperRect.Y + radius);
         render.DrawGripper(point, radius);
     }
 }
        public void Report(folderNode folder, ITextRender output)
        {
            if (output == null)
            {
                return;
            }
            this.ReportBase(output, false, "MetaTableDescription");


            sourceDescription.ReportBase(output, false, "Source description"); //.Report(folder, output);
        }
 public void Report(ITextRender output, Int32 index = Int32.MinValue)
 {
     if (index != Int32.MinValue)
     {
         output.AppendLine("[" + index.ToString("D3") + "]:[" + Score.ToString("F2") + "] " + Detector.GetType().Name + " : " + Node.path);
     }
     else
     {
         output.AppendLine("[" + Score.ToString("F2") + "] " + Detector.GetType().Name + " : " + Node.path);
     }
 }
        /// <summary>
        /// Generates content for <see cref="settingsPropertyEntry"/>
        /// </summary>
        /// <param name="spec">The spec.</param>
        /// <param name="output">The output.</param>
        public static void GetUserManualSPE(this settingsPropertyEntry spec, ITextRender output)
        {
            output.AppendHeading(imbSciStringExtensions.add(spec.categoryName, spec.displayName, ": "), 3);
            output.AppendPair("Property name: ", spec.name);
            output.AppendPair("Type: ", spec.type.Name);

            if (!spec.description.isNullOrEmpty())
            {
                output.AppendParagraph(spec.description);
            }

            if (!spec.letter.isNullOrEmpty())
            {
                output.AppendPair("Annotation: ", spec.letter);
            }
            if (!spec.unit.isNullOrEmpty())
            {
                output.AppendPair("Unit: ", spec.unit);
            }
            if (spec.aggregation != null)
            {
                output.AppendPair("Aggregation: ", spec.aggregation.multiTableType.ToString());
            }

            //if (showValue)
            //{
            //    if (spec.value != null)
            //    {
            //        output.AppendPair("Value: ", spec.value.toStringSafe(spec.format));
            //    }
            //}

            if (spec.type.IsEnum)
            {
                output.AppendPair("Possible values: ", spec.type.GetEnumNames().toCsvInLine());
            }
            else if (spec.type == typeof(Int32))
            {
            }

            if (!spec.info_helpTitle.isNullOrEmpty())
            {
                output.AppendLabel(spec.info_helpTitle);
                output.AppendQuote(spec.info_helpTips);
            }

            if (!spec.info_link.isNullOrEmpty())
            {
                output.AppendLink(spec.info_link, "More", "More");
            }

            output.AppendHorizontalLine();
        }
        public void Describe(ITextRender output)
        {
            output.AppendLine("Set calls [" + SetCalls + "]");
            output.AppendLine("Set prevented [" + SetPrevented + "]");
            output.AppendLine("Set saved to file [" + SetSavedToFile + "]");
            output.AppendLine("Set already in memory [" + SetAlreadyInMemory + "]");

            output.AppendLine("Get calls [" + GetCalls + "]");
            output.AppendLine("Get prevented [" + GetPrevented + "]");
            output.AppendLine("Get from file [" + GetFromFile + "]");
            output.AppendLine("Get from memory [" + GetFromMemory + "]");
        }
Esempio n. 30
0
        public static void DescribeRule(this IRuleBase rule, ITextRender output)
        {
            output.open("p", "Rule: " + rule.name, rule.description);
            output.AppendPair("Class", rule.GetType().Name, true, ": ");
            output.AppendPair("Role", rule.role, true, ": ");
            output.AppendPair("Subject", rule.subject, true, ": ");
            output.AppendPair("Priority", rule.priority, true, ": ");
            output.AppendPair("Mode", rule.mode, true, ": ");
            output.AppendPair("Tag", rule.tagName, true, ": ");

            output.close();
        }