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

时间:2018-10-05 14:40:58

标签: java owl-api reasoning

我尝试使用OWL API整理以下注释:

  


CRECK   建模小组(Politecnico di Milano)
http://creckmodeling.chem.polimi.it/

     


主要参考燃料(PRF)+ PAH机理
版本   2013年11月1311日
详细和半详细(集中式)机制   分解,
部分氧化和燃烧的机理   参考燃料,包括PAH(多环芳烃)   直到C20为止。

运动方案(低温和高温):   276种和8476个反应

参考

E。兰兹,A。   Frassoldati,S。Granata,T。Faravelli,
工业。 。化学Res。   44(14),5170-5183(2005),doi:10.1021 / ie049318g

T。 Bieleveld,   A.Frassoldati,A.Cuoci,T.Faravelli,E.Ranzi,U.Niemann K.   Seshadri,
《燃烧学会学报》,第32卷第pp。   493-500(2009),doi:10.116 / j.proci.2008.06.214

Saggese C.,   Frassoldati,Cuoci A.,Faravelli T.,Ranzi,
燃烧与火焰   (2013),DOI:10.1016 / j.combustflame.2013.02.013

CRECK建模   Group(Politecnico di Milano)http://creckmodeling.chem.polimi.it/
版本1111年11月   2013


不幸的是,它最终向我显示了以下注释,其中删除了空行:

  


CRECK   建模组(Politecnico di Milano)http://creckmodeling.chem.polimi.it/
主要参考燃料   (PRF)+ PAH机制
版本1311,2013年11月
详细   分解的半详细(半集总)机理,
部分   氧化和燃烧主要参考燃料,
包括PAH   (多环芳烃)的形成直至C20。
运动学   方案(低温和高温):276种和8476个反应参考文献
E。 Ranzi,A。Frassoldati,S。Granata,T。   Faravelli,
工业。化学Res。 44(14),5170-5183(2005),doi:   10.1021 / ie049318g
T. Bieleveld,A.Frassoldati,A.Cuoci,T.Faravelli,E.Ranzi,U.Niemann,K.Seshadri,
论文集   燃烧研究所32 I,第493-500页(2009),   doi:10.1016 / j.proci.2008.06.214
Saggese C.,Frassoldati,Cuoci   A.,Faravelli T.,Ranzi,
燃烧与火焰(2013),DOI:   10.1016 / j.combustflame.2013.02.013
CRECK建模小组(米兰理工大学)
http://creckmodeling.chem.polimi.it/Version 1311,2013年11月

为了在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()));
}

非常感谢您为解决该问题提供的帮助。

1 个答案:

答案 0 :(得分:1)

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

    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)