Beispiel #1
0
        public static void OutputResults(SemgrexPattern pattern, SemanticGraph graph, params string[] ignored)
        {
            System.Console.Out.WriteLine("Matching pattern " + pattern + " to\n" + graph + "  :" + (pattern.Matcher(graph).Matches() ? "matches" : "doesn't match"));
            System.Console.Out.WriteLine();
            pattern.PrettyPrint();
            System.Console.Out.WriteLine();
            SemgrexMatcher matcher = pattern.Matcher(graph);

            while (matcher.Find())
            {
                System.Console.Out.WriteLine("  " + matcher.GetMatch());
                ICollection <string> nodeNames = matcher.GetNodeNames();
                if (nodeNames != null && nodeNames.Count > 0)
                {
                    foreach (string name in nodeNames)
                    {
                        System.Console.Out.WriteLine("    " + name + ": " + matcher.GetNode(name));
                    }
                }
                ICollection <string> relNames = matcher.GetRelationNames();
                if (relNames != null)
                {
                    foreach (string name in relNames)
                    {
                        System.Console.Out.WriteLine("    " + name + ": " + matcher.GetRelnString(name));
                    }
                }
            }
        }