<commit_before>package example.mysql;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import com.obidea.semantika.app.ApplicationFactory;
import com.obidea.semantika.app.ApplicationManager;
import com.obidea.semantika.exception.ConfigurationException;
import com.obidea.semantika.materializer.MaterializationException;
import com.obidea.semantika.materializer.MaterializerEngine;

public class RdfMaterializerTest
{
   /**
    * This example shows how to materialize RDB rows into RDF data in NTriples format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testNTriplesMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory().configure("example/mysql/configuration.xml").createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to NTriples.
      MaterializerEngine materializer = manager.createMaterializerEngine().useNTriples();
      
      // Specify the output location where the results are going to be stored.
      File fout = File.createTempFile("employees", ".n3", new File("/tmp"));
      
      // Mark the start and end of the materialization process.
      materializer.start();
      materializer.materialize(fout);
      materializer.stop();
   }

   /**
    * This example shows how to materialize RDB rows into RDF data in Turtle format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testTurtleMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory().configure("example/mysql/configuration.xml").createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to Turtle.
      MaterializerEngine materializer = manager.createMaterializerEngine().useTurtle();
      
      // Mark the start and end of the materialization process.
      File fout = File.createTempFile("employees", ".ttl", new File("/tmp"));
      materializer.start();
      materializer.materialize(fout);
      materializer.stop();
   }

   /**
    * This example shows how to materialize RDB rows into RDF data in RDF/XML format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testRdfXmlMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory().configure("example/mysql/configuration.xml").createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to RDF/XML.
      MaterializerEngine materializer = manager.createMaterializerEngine().useRdfXml();
      <commit_msg>Initial commit of materialization example with MySQL as the back-end<commit_after>package example.mysql;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import com.obidea.semantika.app.ApplicationFactory;
import com.obidea.semantika.app.ApplicationManager;
import com.obidea.semantika.exception.ConfigurationException;
import com.obidea.semantika.materializer.MaterializationException;
import com.obidea.semantika.materializer.MaterializerEngine;

public class RdfMaterializerTest
{
   /**
    * This example shows how to materialize RDB rows into RDF data in NTriples format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testNTriplesMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory()
            .configure("example/mysql/configuration.xml")
            .createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to NTriples.
      MaterializerEngine materializer = manager.createMaterializerEngine().useNTriples();
      
      // Specify the output location where the results are going to be stored.
      File fout = File.createTempFile("employees", ".n3", new File("/tmp"));
      
      // Mark the start and end of the materialization process.
      materializer.start();
      materializer.materialize(fout);
      materializer.stop();
   }

   /**
    * This example shows how to materialize RDB rows into RDF data in Turtle format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testTurtleMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory()
            .configure("example/mysql/configuration.xml")
            .createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to Turtle.
      MaterializerEngine materializer = manager.createMaterializerEngine().useTurtle();
      
      // Mark the start and end of the materialization process.
      File fout = File.createTempFile("employees", ".ttl", new File("/tmp"));
      materializer.start();
      materializer.materialize(fout);
      materializer.stop();
   }

   /**
    * This example shows how to materialize RDB rows into RDF data in RDF/XML format where the
    * back-end database used is MySQL.
    *
    * @throws ConfigurationException
    * @throws MaterializationException
    * @throws IOException
    */
   @Test
   public void testRdfXmlMaterializer() throws ConfigurationException, MaterializationException, IOException
   {
      // Create an application manager using the given configuration resource.
      ApplicationManager manager = new ApplicationFactory()
            .configure("example/mysql/configuration.xml")
            .createApplicationManager();
      
      // Obtain the materializer engine from the manager and set the format to RDF/XML.
      MaterializerEngine materializer = manager.createMaterializerEngine().useRdfXml();
      
{'fraction_non_alphanumeric': 0.07701266559906828, 'fraction_numerical': 0.00029116319697190275, 'mean_word_length': 3.4523655217109526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3732307', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1648, 'n_words': 537}