All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sansa_stack.owl.spark.rdd.FunctionalSyntaxOWLAxiomsRDDBuilder.scala Maven / Gradle / Ivy

package net.sansa_stack.owl.spark.rdd

import com.typesafe.scalalogging.Logger
import net.sansa_stack.owl.common.parsing.FunctionalSyntaxParsing
import org.apache.spark.sql.SparkSession
import org.semanticweb.owlapi.io.OWLParserException


object FunctionalSyntaxOWLAxiomsRDDBuilder extends FunctionalSyntaxParsing {
  private val logger = Logger(this.getClass)

  def build(spark: SparkSession, filePath: String): OWLAxiomsRDD = {
    build(spark, FunctionalSyntaxOWLExpressionsRDDBuilder.build(spark, filePath))
  }

  // FIXME: It has to be ensured that expressionsRDD is in functional syntax
  def build(spark: SparkSession, expressionsRDD: OWLExpressionsRDD): OWLAxiomsRDD = {
    expressionsRDD.map(expression => {
      try makeAxiom(expression)
      catch {
        case exception: OWLParserException =>
          logger.warn("Parser error for line " + expression + ": " + exception.getMessage)
          null
      }
    }).filter(_ != null)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy