java - OWL API 从多行注释中删除空行

标签 java owl-api reasoning

我尝试使用 OWL API 编写以下评论:

<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
CRECK Modeling Group (Politecnico di Milano)
http://creckmodeling.chem.polimi.it/


Primary Reference Fuels (PRF) + PAH Mechanism
Version 1311, November 2013
Detailed and semidetailed (lumped) mechanism of the pyrolysis,
partial oxidation and combustion Primary Reference Fuels,
including PAH (Polycyclic Aromatic Hydrocarbons) formation up to C20.

Kinetic scheme (Low and High temperature): 276 species and 8476 reactions

References

E. Ranzi, A. Frassoldati, S. Granata, T. Faravelli,
Ind. Eng. Chem. Res. 44(14), 5170-5183 (2005), doi: 10.1021/ie049318g

T. Bieleveld, A. Frassoldati, A. Cuoci, T. Faravelli, E. Ranzi, U. Niemann K. Seshadri,
Proceedings of the Combustion Institute 32 I, pp. 493-500 (2009), doi:10.116/j.proci.2008.06.214

Saggese C., Frassoldati, Cuoci A., Faravelli T., Ranzi,
Combustion and Flame (2013), DOI: 10.1016/j.combustflame.2013.02.013

CRECK Modeling Group (Politecnico di Milano)http://creckmodeling.chem.polimi.it/
Version 1311, November 2013


</rdfs:comment>

不幸的是,它最终向我显示了以下删除了空行的评论:

<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
CRECK Modeling Group (Politecnico di Milano)http://creckmodeling.chem.polimi.it/
Primary Reference Fuels (PRF) + PAH Mechanism
Version 1311, November 2013
Detailed and semidetailed (lumped) mechanism of the pyrolysis,
partial oxidation and combustion Primary Reference Fuels,
including PAH (Polycyclic Aromatic Hydrocarbons) formation up to C20.
Kinetic scheme (Low and High temperature): 276 species and 8476 reactionsReferences
E. Ranzi, A. Frassoldati, S. Granata, T. Faravelli,
Ind. Eng. Chem. Res. 44(14), 5170-5183 (2005), doi: 10.1021/ie049318g
T. Bieleveld, A. Frassoldati, A. Cuoci, T. Faravelli, E. Ranzi, U. Niemann, K. Seshadri,
Proceedings of the Combustion Institute 32 I, pp. 493-500 (2009), doi:10.1016/j.proci.2008.06.214
Saggese C., Frassoldati, Cuoci A., Faravelli T., Ranzi,
Combustion and Flame (2013), DOI: 10.1016/j.combustflame.2013.02.013
CRECK Modeling Group (Politecnico di Milano)
http://creckmodeling.chem.polimi.it/Version 1311, November 2013
</rdfs:comment>

为了在 OWL 中对上述注释进行编码,我使用以下方法: org.semanticweb.owlapi.model.OWLDataFactory.getOWLLiteral(comment);

与问题描述相关的代码片段如下:

/**
* Creates an OWL literal with one of the following data types:</br>
* 1. String.
* 2. Integer, and
* 3. Float.
* 
* @param ontoFactory
* @param propertyName
* @param literal
* @return
* @throws OntoException
*/


private OWLLiteral createOWLLiteral(OWLDataFactory ontoFactory, String propertyName, String literal) throws OntoException{
if(propertyName.startsWith(basePathTBox.concat(HASH))){
propertyName = propertyName.replace(basePathTBox.concat(HASH), EMPTY);
}
if(dataPropertyNameVsTypeMap.containsKey(propertyName.toLowerCase())){
if(dataPropertyNameVsTypeMap.get(propertyName.toLowerCase()).equals("string")){
return ontoFactory.getOWLLiteral(literal);
} else if(dataPropertyNameVsTypeMap.get(propertyName.toLowerCase()).equals("integer")){
try{
return ontoFactory.getOWLLiteral(Integer.parseInt(literal));
}catch(NumberFormatException e){
throw new OntoException("The following value is not an integer:"+literal);
}
} else if(dataPropertyNameVsTypeMap.get(propertyName.toLowerCase()).equals("float")){
try{
return ontoFactory.getOWLLiteral(Float.parseFloat(literal));
}catch(NumberFormatException e){
throw new OntoException("The following value is not a float:"+literal);
}
}
}
throw new OntoException("The following data type could not be recognised:"+dataPropertyNameVsTypeMap.get(propertyName.toLowerCase()));
}

非常感谢您帮助解决此问题。

最佳答案

问题不在于工厂。以下代码生成正确间隔的注释注释。问题一定是用于保存的格式或错误。

    OWLAnnotation a = df.getRDFSComment("\n" + "CRECK Modeling Group (Politecnico di Milano)\n"
        + "http://creckmodeling.chem.polimi.it/\n" + "\n" + "\n"
        + "Primary Reference Fuels (PRF) + PAH Mechanism\n" + "Version 1311, November 2013\n"
        + "Detailed and semidetailed (lumped) mechanism of the pyrolysis,\n"
        + "partial oxidation and combustion Primary Reference Fuels,\n"
        + "including PAH (Polycyclic Aromatic Hydrocarbons) formation up to C20.\n" + "\n"
        + "Kinetic scheme (Low and High temperature): 276 species and 8476 reactions\n" + "\n"
        + "References\n" + "\n" + "E. Ranzi, A. Frassoldati, S. Granata, T. Faravelli,\n"
        + "Ind. Eng. Chem. Res. 44(14), 5170-5183 (2005), doi: 10.1021/ie049318g\n" + "\n"
        + "T. Bieleveld, A. Frassoldati, A. Cuoci, T. Faravelli, E. Ranzi, U. Niemann K. Seshadri,\n"
        + "Proceedings of the Combustion Institute 32 I, pp. 493-500 (2009), doi:10.116/j.proci.2008.06.214\n"
        + "\n" + "Saggese C., Frassoldati, Cuoci A., Faravelli T., Ranzi,\n"
        + "Combustion and Flame (2013), DOI: 10.1016/j.combustflame.2013.02.013\n" + "\n"
        + "CRECK Modeling Group (Politecnico di Milano)http://creckmodeling.chem.polimi.it/\n"
        + "Version 1311, November 2013\n" + "\n" + "\n");
    System.out.println(a);

Annotation(rdfs:comment "
CRECK Modeling Group (Politecnico di Milano)
http://creckmodeling.chem.polimi.it/


Primary Reference Fuels (PRF) + PAH Mechanism
Version 1311, November 2013
Detailed and semidetailed (lumped) mechanism of the pyrolysis,
partial oxidation and combustion Primary Reference Fuels,
including PAH (Polycyclic Aromatic Hydrocarbons) formation up to C20.

Kinetic scheme (Low and High temperature): 276 species and 8476 reactions

References

E. Ranzi, A. Frassoldati, S. Granata, T. Faravelli,
Ind. Eng. Chem. Res. 44(14), 5170-5183 (2005), doi: 10.1021/ie049318g

T. Bieleveld, A. Frassoldati, A. Cuoci, T. Faravelli, E. Ranzi, U. Niemann K. Seshadri,
Proceedings of the Combustion Institute 32 I, pp. 493-500 (2009), doi:10.116/j.proci.2008.06.214

Saggese C., Frassoldati, Cuoci A., Faravelli T., Ranzi,
Combustion and Flame (2013), DOI: 10.1016/j.combustflame.2013.02.013

CRECK Modeling Group (Politecnico di Milano)http://creckmodeling.chem.polimi.it/
Version 1311, November 2013


"^^xsd:string)

关于java - OWL API 从多行注释中删除空行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52668086/

相关文章:

java - Spring Boot 单页应用并发

java - 使用 Maven 构建 Eclipse 插件 - 最新观点

java - 如何使用 OWLAPI 获取对象属性的个体集

java - 使用 OWL API 发出 SWRL 请求

web-services - OWL API - 在 Web 服务发现的上下文中进行 OWL 类包含测试

java - 运行测试时获取 "java.lang.IllegalArgumentException: Decode argument cannot be null"

java - 不知道如何使用 Hermit 从 java 中的本体中获取对象属性

rdf - 使用Pellet作为推理机的OutOfMemoryError

java - 如何在 Camel 中路由使用 SOAP Web 服务的端点链?