Beispiel #1
0
        public void IdsFileLoading()
        {
            DotNetFileProvider prov = new DotNetFileProvider();
            Graph g = GraphXmlDeserializer.GetGraphInstance("ids.xml", prov, ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(g);
        }
        public void QueryGraph()
        {
            Graph idsGraph = GraphXmlDeserializer.GetGraphInstance(absoluteIdsFilePath, new FileLoader(), ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(idsGraph);

            SQLiteConnection connection = GetSqliteConnection();

            Assert.IsNotNull(connection);

            OrientedBinaryGraphToDatabaseConverter <SQLiteCommand> converter = new OrientedBinaryGraphToDatabaseConverter <SQLiteCommand>(connection);

            Assert.IsNotNull(converter);
            converter.CreateDatabase();
            converter.PopulateDatabase(idsGraph);

            connection.Open();
            IGraph sqlGraph = new SqlGraph <SQLiteCommand>(new DbProvider <SQLiteCommand>(connection,
                                                                                          new SqliteVertexStoreRawSqlProvider(), new SqliteEdgeStoreRawSqlProvider()));

            Assert.IsNotNull(sqlGraph);

            IEnumerable <IVertex> result = sqlGraph.SearchNode("", "乃");

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());

            IVertex v = result.First();

            Assert.AreEqual(103, v.GetLinkedObjects().Count);
        }
Beispiel #3
0
        public void EdgeAnnotationTest()
        {
            Graph g = GraphXmlDeserializer.LoadMultipleFiles(new string[] { "abc.xml" }, new DotNetFileProvider(), ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(g);

            IVertex a = g.SearchNode("", "A").FirstOrDefault();
        }
Beispiel #4
0
        public void EditableVertexLoadingTest()
        {
            Graph g = GraphXmlDeserializer.GetGraphInstance("annotations_test.xml", new DotNetFileProvider(), typeof(EditableVertex));

            Assert.IsNotNull(g);

            var search = g.SearchNode("", "avion");

            Assert.IsNotNull(search);
            IVertex v = search[0];
        }
Beispiel #5
0
        // Use the debugguer to inspect object
        public static void Main_3(string[] args)
        {
            Graph graph = CreateGraph();
            GraphXmlSerializer serializer = new GraphXmlSerializer();
            XDocument          xdoc       = serializer.Serialize(graph);

            xdoc.Save("graph.xml");

            graph = null;

            graph = GraphXmlDeserializer.GetGraphInstance("graph.xml", new FileLoader());
        }
Beispiel #6
0
        public void MultipleFilesLoading()
        {
            DotNetFileProvider prov = new DotNetFileProvider();
            Graph g = GraphXmlDeserializer.LoadMultipleFiles(new string[] { "ids_light_5000.xml", "readings_light_5000.xml" }, prov, ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(g);
            var search = g.SearchNode("", "侖");

            Assert.IsNotNull(search);
            Assert.AreEqual <int>(1, search.Count);

            IVertex v = search[0];
        }
        public void ExtensibleSerializationDeserializationAsGraph()
        {
            ExtensibleXmlGraphSerializer ser = new ExtensibleXmlGraphSerializer();
            Graph g = GetTestGraph();

            XDocument doc  = ser.Serialize(g);
            string    path = Path.GetTempFileName();

            doc.Save(path);

            Assert.IsTrue(File.Exists(path));

            g = GraphXmlDeserializer.GetGraphInstance(path, new FileLoader());
            Assert.IsNotNull(g);
        }
        public void CreateSqliteCreateHyperGraphDatabase()
        {
            Graph n1Graph = GraphXmlDeserializer.GetGraphInstance(absoluteN1FilePath, new FileLoader(), ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(n1Graph);

            SQLiteConnection connection = GetSqliteConnection();

            Assert.IsNotNull(connection);

            GeneralHyperGraphDatabaseConverter <SQLiteCommand> converter = new GeneralHyperGraphDatabaseConverter <SQLiteCommand>(connection);

            Assert.IsNotNull(converter);

            converter.CreateDatabase();
        }
        public ExtendedGraph Load(XDocument xdoc)
        {
            Graph                graph      = GraphXmlDeserializer.LoadFromXml(xdoc);
            ExtensionXmlNames    extNames   = new ExtensionXmlNames();
            List <IXmlExtension> extensions = new List <IXmlExtension>();

            if (xdoc != null)
            {
                XElement extensionList = xdoc.Root.Element(extNames.ExtensionListElement);
                foreach (XElement extensionNode in extensionList.Elements(extNames.ExtensionElement))
                {
                    string typeName     = extensionNode.Attribute(extNames.ExtensionPreferredDeserializerAttribute)?.Value;
                    string assemblyName = extensionNode.Attribute(extNames.ExtensionDezerializerAssemblyAttribute)?.Value;
                    if (String.IsNullOrEmpty(typeName) || String.IsNullOrEmpty(assemblyName))
                    {
                        Debug.WriteLine($"Extension loading skipped. Parameters [{typeName}] and [{assemblyName}]");
                        continue;
                    }

                    Assembly assembly = Assembly.LoadFrom(assemblyName);
                    if (assembly == null)
                    {
                        Debug.WriteLine($"Assembly [{assemblyName}] could not be loaded.");
                        continue;
                    }
                    Type type = assembly.GetType(typeName);
                    if (type == null)
                    {
                        Debug.WriteLine($"Type [{typeName}] does not exist in assembly [{assemblyName}].");
                        continue;
                    }

                    IXmlExtension extension = Activator.CreateInstance(type) as IXmlExtension;
                    if (extension == null)
                    {
                        Debug.WriteLine($"Instance of type [{typeName}] could not be created as IXmlExtension.");
                        continue;
                    }

                    extension.ReadObject(extensionNode);
                    extensions.Add(extension);
                }
                return(new ExtendedGraph(graph, extensions));
            }
            return(null);
        }
        public void CreateSqliteCreateOrientedBinaryGraphDatabase()
        {
            Graph idsGraph = GraphXmlDeserializer.GetGraphInstance(absoluteIdsFilePath, new FileLoader(), ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(idsGraph);

            SQLiteConnection connection = GetSqliteConnection();

            Assert.IsNotNull(connection);

            OrientedBinaryGraphToDatabaseConverter <SQLiteCommand> converter = new OrientedBinaryGraphToDatabaseConverter <SQLiteCommand>(connection);

            Assert.IsNotNull(converter);

            converter.CreateDatabase();
            converter.PopulateDatabase(idsGraph);
        }
Beispiel #11
0
        public void NodeExternalAnnotationTest()
        {
            Graph g = GraphXmlDeserializer.GetGraphInstance("annotations_test.xml", new DotNetFileProvider(), ExternalRessourcesLoadingPolicy.None);

            Assert.IsNotNull(g);

            var search = g.SearchNode("", "porter");

            Assert.IsNotNull(search);
            IVertex v = search[0];

            var annotations = g.GetAnnotations(v);

            Assert.AreEqual <int>(1, annotations.Count);
            Assert.AreEqual <string>("", annotations[0].Namespace);
            Assert.AreEqual <string>("pos", annotations[0].Key);
            Assert.AreEqual <string>("verbe", annotations[0].Value);
        }
        public static Trie GetTrieInstance(string resourcePath, IFileProvider fileProvider)
        {
            Graph g = GraphXmlDeserializer.GetGraphInstance(resourcePath, fileProvider, ExternalRessourcesLoadingPolicy.None);

            return(new Trie(g));
        }