|
|
|
|
|
|
|
|
|
|
|
### NORMALIZATION ###
|
|
|
|
|
|
For the normalization reasons the backend part given bellow was added in the code together with scala parts listed on the bottom of the page:
|
|
|
|
|
|
> #For the normalization json.dump was replaced with the loop below
|
|
|
> ```
|
|
|
> #json.dump({"section_springer_material":list(res.values())}, sys.stdout, indent=2, sort_keys=True, ensure_ascii=False)
|
|
|
> for mat in res.values():
|
|
|
> matS=backend.openSection("section_springer_material")
|
|
|
> for cl in mat.get("section_springer_classification",[]):
|
|
|
> clS = backend.openSection("section_springer_classification")
|
|
|
> if "springer_classification" in cl:
|
|
|
> backend.addValue("springer_classification",cl["springer_classification"])
|
|
|
> if "springer_number_of_classification_reference_per_material" in cl:
|
|
|
> backend.addValue("springer_number_of_classification_reference_per_material",cl["springer_number_of_classification_reference_per_material"])
|
|
|
> backend.closeSection("section_springer_classification",clS)
|
|
|
> for cl in mat.get("section_springer_compound_class",[]):
|
|
|
> clS = backend.openSection("section_springer_compound_class")
|
|
|
> if "springer_compound_class" in cl:
|
|
|
> backend.addValue("springer_compound_class",cl["springer_compound_class"])
|
|
|
> if "springer_number_of_compound_class_reference_per_material" in cl:
|
|
|
> backend.addValue("springer_number_of_compound_class_reference_per_material",cl["springer_number_of_compound_class_reference_per_material"])
|
|
|
> backend.closeSection("section_springer_compound_class",clS)
|
|
|
> for cl in mat.get("section_springer_id",[]):
|
|
|
> clS = backend.openSection("section_springer_id")
|
|
|
> if "springer_id" in cl:
|
|
|
> backend.addValue("springer_id",cl["springer_id"])
|
|
|
> if "springer_url" in cl:
|
|
|
> backend.addValue("springer_url",cl["springer_url"])
|
|
|
> backend.closeSection("section_springer_id",clS)
|
|
|
> for ref in cl.get("section_springer_references",[]):
|
|
|
> refS = backend.openSection("section_springer_references")
|
|
|
> if "springer_reference" in ref:
|
|
|
> backend.addValue("springer_reference",ref["springer_reference"])
|
|
|
> backend.closeSection("section_springer_references",refS)
|
|
|
> if "springer_formula" in mat:
|
|
|
> backend.addValue("springer_formula",mat["springer_formula"])
|
|
|
>
|
|
|
> if "springer_space_group_number" in mat:
|
|
|
> backend.addValue("springer_space_group_number",mat["springer_space_group_number"])
|
|
|
>
|
|
|
>
|
|
|
> backend.closeSection("section_springer_material",matS)
|
|
|
> ```
|
|
|
|
|
|
|
|
|
**SCALA PART**
|
|
|
|
|
|
|
|
|
Added file `SpringerNormalizer.scala`
|
|
|
in:
|
|
|
`normalizer-springer/src/main/scala/eu/nomad_lab/normalizers`
|
|
|
|
|
|
contents:
|
|
|
|
|
|
|
|
|
```scala
|
|
|
package eu.nomad_lab.normalizers
|
|
|
import eu.{ nomad_lab => lab }
|
|
|
import eu.nomad_lab.DefaultPythonInterpreter
|
|
|
import org.{ json4s => jn }
|
|
|
import scala.collection.breakOut
|
|
|
import eu.nomad_lab.normalize.ExternalNormalizerGenerator
|
|
|
import eu.nomad_lab.meta
|
|
|
import eu.nomad_lab.query
|
|
|
object SpringerNormalizer extends ExternalNormalizerGenerator(
|
|
|
name = "SpringerNormalizer",
|
|
|
info = jn.JObject(
|
|
|
("name" -> jn.JString("SpringerNormalizer")) ::
|
|
|
("normalizerId" -> jn.JString("SpringerNormalizer" + lab.SpringerVersionInfo.version)) ::
|
|
|
("versionInfo" -> jn.JObject(
|
|
|
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
|
|
|
case (k, v) => k -> jn.JString(v.toString)
|
|
|
}(breakOut): List[(String, jn.JString)])) ::
|
|
|
(lab.SpringerVersionInfo.toMap.map {
|
|
|
case (key, value) =>
|
|
|
(key -> jn.JString(value.toString))
|
|
|
}(breakOut): List[(String, jn.JString)])
|
|
|
)) :: Nil
|
|
|
),
|
|
|
context = "calcuation_context",
|
|
|
filter = query.CompiledQuery(query.QueryExpression("program_name = \"FHI-aims\""), meta.KnownMetaInfoEnvs.publicMeta),
|
|
|
cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/normalizers/springer/normalizer/normalizer-springer/classify4me_SM_normalizer.py",
|
|
|
"${contextUri}", "${archivePath}"),
|
|
|
resList = Seq(
|
|
|
"normalizer-springer/classify4me_SM_normalizer.py",
|
|
|
"normalizer-springer/SM_all08.db",
|
|
|
"nomad_meta_info/public.nomadmetainfo.json",
|
|
|
"nomad_meta_info/common.nomadmetainfo.json",
|
|
|
"nomad_meta_info/meta_types.nomadmetainfo.json",
|
|
|
"nomad_meta_info/stats.nomadmetainfo.json"
|
|
|
) ++ DefaultPythonInterpreter.commonFiles(),
|
|
|
dirMap = Map(
|
|
|
"normalizer-springer" -> "normalizers/springer/normalizer/normalizer-springer",
|
|
|
"nomad_meta_info" -> "nomad-meta-info/meta_info/nomad_meta_info",
|
|
|
"python" -> "python-common/common/python/nomadcore"
|
|
|
) ++ DefaultPythonInterpreter.commonDirMapping(),
|
|
|
metaInfoEnv = lab.meta.KnownMetaInfoEnvs.common
|
|
|
)
|
|
|
```
|
|
|
|
|
|
|
|
|
and scala binding file `SpringerNormalizer.scala` in
|
|
|
`normalizer-springer/src/test/scala/eu/nomad_lab/normalizers`
|
|
|
|
|
|
contents:
|
|
|
|
|
|
|
|
|
```scala
|
|
|
package eu.nomad_lab.normalizers
|
|
|
import eu.nomad_lab.{ parsers, DefaultPythonInterpreter }
|
|
|
import org.scalacheck.Properties
|
|
|
import org.specs2.mutable.Specification
|
|
|
import org.{ json4s => jn }
|
|
|
object SpringerNormalizerSpec extends Specification {
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
Also **SpringerNormalizer ** was added in
|
|
|
|
|
|
`normalize/src/main/scala/eu/nomad_lab/normalize/AllNormalizers.scala`
|
|
|
|
|
|
|
|
|
Next the `setup-paths.py` was added in
|
|
|
`../springer/normalizer/normalizer-springer/`
|
|
|
|
|
|
and also cmd line inserted in SpringerNormalizer.scala in src/main...
|
|
|
```scala
|
|
|
cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/normalizers/springer/normalizer/normalizer-springer/classify4me_SM_normalizer.py",
|
|
|
"${contextUri}", "${archivePath}"),
|
|
|
``` |