从.net创建Protege可读本体



我正在尝试从。net创建一个propro可读本体。

我从一个4GB的.nt文件开始,并解析出我希望使用的所需类和实例。这些都存储在内存中,因为我把它压缩到不到1分钟,大约1GB。它们现在是Dictionary<String,HashSet<String>>的形式。下一步是获取该数据并将其移动到OWL本体中。有什么地方可以从如何手动循环开始吗?我所有的研究都指向我使用曼彻斯特OWL,但我能找到的一切都是与现有的工具一起使用,不符合我的需求。我正在寻找只是做一个简单的循环可能与LINQ到XML,我不确定如何格式化或在哪里寻找找到如何做到这一点。

谢谢吉米

你可以从这个

开始
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string definition =
                "<?xml version="1.0" encoding="UTF-8"?>" +
                "<Ontology xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"" +
                    " xsi:schemaLocation="http://www.w3.org/2002/07/owl# http://www.w3.org/2009/09/owl2-xml.xsd"" +
                    " xmlns="http://www.w3.org/2002/07/owl#"" +
                    " xml:base="http://example.com/myOntology"" +
                    " ontologyIRI="http://example.com/myOntology">" +
                "</Ontology>";
            XDocument doc = XDocument.Parse(definition);
            XElement ontology = (XElement)doc.FirstNode;
            XNamespace ns = ontology.Name.Namespace;
            ontology.Add(new XElement[] {
                new XElement(ns + "Prefix", new XAttribute[] {
                       new XAttribute("name", "myOnt"),
                       new XAttribute("IRI", "http://example.com/myOntology#")
                }),
                new XElement(ns + "Import", "http://example.com/someOtherOntology")
            });
        }
    }
}
​

最新更新