当我尝试运行我的java程序时,我得到以下错误(它应该读取一个xml文件并打印出一些内容).
根据我的理解,有一个未引用的实体,它不是xml标准的一部分,所以我的问题是; 我该如何解决这个问题?
谢谢,
[Fatal Error] subject.xml:4:233: The entity "rsquo" was referenced, but not declared.
org.xml.sax.SAXParseException: The entity "rsquo" was referenced, but not declared.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at DomParserExample2.parseXmlFile(DomParserExample2.java:42)
at DomParserExample2.runExample(DomParserExample2.java:24)
at DomParserExample2.main(DomParserExample2.java:115)
Exception in thread "main" java.lang.NullPointerException
at DomParserExample2.parseDocument(DomParserExample2.java:54)
at DomParserExample2.runExample(DomParserExample2.java:27)
at DomParserExample2.main(DomParserExample2.java:115)
Run Code Online (Sandbox Code Playgroud) 我想解析以下XML文档来解析其中的所有实体:
<!DOCTYPE doc SYSTEM 'mydoc.dtd'>
<doc>&title;</doc>
Run Code Online (Sandbox Code Playgroud)
我的EntityResolver应该从数据库中获取具有给定系统ID的外部实体,然后执行解决方案,请参阅下面的插图:
private static class MyEntityResolver
{
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException
{
// At this point, systemId is always absolutized to the current working directory,
// even though the XML document specified it as relative.
// E.g. "file:///H:/mydoc.dtd" instead of just "mydoc.dtd"
// Why??? How can I prevent this???
SgmlEntity entity = findEntityFromDatabase(systemId);
InputSource is = new InputSource(new ByteArrayInputStream(entity.getContents()));
is.setPublicId(publicId);
is.setSystemId(systemId);
return is;
}
}
Run Code Online (Sandbox Code Playgroud)
我都尝试使用DOM(DocumentBuilder的)和SAX(XMLReader的),实体解析器设置为MyEntityResolver(即setEntityResolver(new MyEntityResolver())),但systemId …
我有两个带有姓名列表的数据框
df1[name] -> number of rows 3000
df2[name] -> number of rows 64000
Run Code Online (Sandbox Code Playgroud)
我使用 fuzzy wuzzy 使用以下代码从 df2 中获取 df1 条目的最佳匹配:
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
matches = [process.extract(x, df1, limit=1) for x in df2]
Run Code Online (Sandbox Code Playgroud)
但这需要很长时间才能完成。有没有更快的方法来对 pandas 中的字符串进行模糊匹配?