我已经在Java Apache Jena上测试过linkedmdb-18-05-2009-dump.nt,但是在dotNetRDF上抛出了一个异常
VDS.RDF.Parsing.RdfParseException
HResult=0x80131500
Message=Invalid URI encountered, see inner exception for details
Source=dotNetRDF
StackTrace:
at VDS.RDF.Parsing.NTriplesParser.TryParseUri(TokenisingParserContext context, String uri)
at VDS.RDF.Parsing.NTriplesParser.TryParseTriple(TokenisingParserContext context)
at VDS.RDF.Parsing.NTriplesParser.Parse(TokenisingParserContext context)
at VDS.RDF.Parsing.NTriplesParser.Load(IRdfHandler handler, TextReader input)
at ConsoleApp2_RDFWALKTHROUGH.Program.Main(String[] args) in
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
UriFormatException: Invalid URI: The hostname could not be parsed.我的c#代码如下:
String inputFile = "D:/linkedmdb-18-05-2009-dump.nt";
IGraph g = new Graph();
NTriplesParser parser = new NTriplesParser(NTriplesSyntax.Original);
Console.WriteLine("RDF DS-1 Loading Started:");
parser.Load(g, new StreamReader(inputFile));
Console.WriteLine("RDF DS-1 Loading Finished:");
Console.WriteLine(new DateTime(loadingTime).ToShortTimeString());
Console.ReadLine();请告诉我哪里错了,因为同样的文件在Java上是可以的,但在dotNetRDF上却不能解析,这是非常令人困惑的。
发布于 2020-09-13 22:51:57
问题是转储包含无效的IRI。在我从https://www.cs.toronto.edu/~oktie/linkedmdb/下载的转储文件的第3104575行,有以下内容:
<http://data.linkedmdb.org/film/9995> <http://xmlns.com/foaf/0.1/page> <http://?> .该行上的最后一个IRI会导致解析器卡住,因为?不是IRI中该位置的有效字符。
https://stackoverflow.com/questions/63859227
复制相似问题