public void Report(folderNode folder)
        {
            builderForText reporter = new builderForText();

            Detectors.Report(reporter);
            Candidates.Report(reporter, nameof(Candidates));

            AcceptedCandidates.Report(reporter, nameof(AcceptedCandidates));

            DeclinedCandidates.Report(reporter, nameof(DeclinedCandidates));

            DeclinedByDetectorCandidates.Report(reporter, nameof(DeclinedByDetectorCandidates));

            NodeDictionaryGraphStyleSettings style = new NodeDictionaryGraphStyleSettings();


            var initialGraph = InitialGraph.BuildDirectedGraph(style);

            initialGraph.Save(folder.pathFor("InitialGraph.dgml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Initial content graph of chunk detection"));

            var finalGraph = CurrentGraph.BuildDirectedGraph(style);

            finalGraph.Save(folder.pathFor("FinalGraph.dgml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Final content graph of chunk detection"));

            CurrentGraphStates.Save(folder, "StateGraph");

            foreach (var chunk in DetectedChunks)
            {
                chunk.PublishAnnotation(initialGraph, "#f7941d", style);
            }

            initialGraph.Save(folder.pathFor("InitialGraphWithAnnotation.dgml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Initial content graph of chunk detection with chunks annoted"));
            folder.SaveText(reporter.GetContent(), "report.txt");
        }
Ejemplo n.º 2
0
        public ChunkDetectionResult Run(NodeGraph InitialGraph)
        {
            Check();



            ChunkDetectionResult result = new ChunkDetectionResult(InitialGraph, this);


            foreach (IContentChunkDetector detector in Detectors)
            {
                detector.GetCandidates(result);
            }

            result.Candidates.ScoreAndSort();

            NodeDictionaryGraphStyleSettings style = new NodeDictionaryGraphStyleSettings();


            result.CurrentGraphStates.Add(result.CurrentGraph.BuildDirectedGraph(style));

            foreach (ChunkContentCandidate candidate in result.Candidates)
            {
                //if (candidate.Score == 0)
                //{
                //    result.DeclinedCandidates.Add(candidate);
                //    continue;
                //}
                var rootNode = result.CurrentGraph.GetChildAtPath <NodeGraph>(candidate.Node.path, "/", false);
                if (rootNode == null)
                {
                    result.DeclinedCandidates.Add(candidate);
                }
                else
                {
                    ContentChunk contentChunk = new ContentChunk();
                    contentChunk.ExtractorName = candidate.Detector.GetExtractorName();
                    contentChunk.DeployRootNode(rootNode);

                    var subGraph = rootNode.GetSubgraph(true);
                    contentChunk.SubGraph = subGraph;

                    if (candidate.Detector.SetContentChunk(contentChunk, candidate, result))
                    {
                        result.DetectedChunks.Add(contentChunk);
                        result.AcceptedCandidates.Add(candidate);
                    }
                    else
                    {
                        result.DeclinedByDetectorCandidates.Add(candidate);
                    }

                    result.CurrentGraphStates.Add(result.CurrentGraph.BuildDirectedGraph(style));
                }
            }


            return(result);
        }