<commit_before>package org.python.ReL;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;

import org.python.core.*;
import org.python.antlr.base.expr;

import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.core.*;
import com.hp.hpl.jena.datatypes.BaseDatatype;
import com.hp.hpl.jena.datatypes.DatatypeFormatException;
import com.hp.hpl.jena.datatypes.RDFDatatype;
import com.hp.hpl.jena.datatypes.TypeMapper;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.vocabulary.RDF;

import oracle.rdf.kv.client.jena.*;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * A class that is used to interface with the oracle database.
 * All statements and queries should go through here to communicate with oracle.
 */
 
public class OracleRDFNoSQLInterface extends DatabaseInterface {

    private OracleNoSqlConnection connection;
    DatasetGraphNoSql datasetGraph = null;
    private ResultSet rs = null;
    private String debug;
    private String nameSpace = "carnot:";
    private String nameSpacePrefix = "c";
     
    public OracleRDFNoSQLInterface(String url, String uname, String passw, String conn_type, String debug) {
        super();

        connection = null;
        this.debug = debug;

        if(conn_type != "none" ) {
            this.connection = OracleNoSqlConnection.createInstance("kvstore", "Phils-MacBook-Pro.local", "5000");
            OracleGraphNoSql graph = new OracleGraphNoSql(connection);
            this.datasetGraph = DatasetGraphNoSql.createFrom(graph);

            // Close graph, as it is no longer needed
            graph.close(); 
            
            // Clear dataset
            System.out.println("\nWRNING: the NoSQL database is being cleared in PyRelConnection!\n");
            datasetGraph.clearRepository();
        }
    }

    public String getNameSpace() { return nameSpace; }
    public String getNameSpacePrefix() { return nameSpacePrefix; }

    @Override
    public void OracleNoSQLAddQuad(String graph, String subject, String predicate, String object)
    {
        if( ! graph.contains("http://"))     graph     = nameSpace + graph;
        if( ! subject.contains("http://"))   subject   = nameSpace + subject;
        if( ! predicate.contains("http://")) predicate = nameSpace + predicate;
        if( ! object.contains("http://"))    object    = nameSpace + object;
        if(debug.equals("debug")) System.out.println("In addQuad, stmt is: " + graph + ", " + subject + ", " + predicate + ", " + object);

        try  { 
            Double.parseDouble(object.replaceAll("carnot:", "")); 
            datasetGraph.add(Node.createURI(graph), Node.createURI(subject), Node.createURI(predicate), Node.createLiteral(object.replaceAll("carnot:", "")));
        } catch(NumberFormatException e)  
        {   
          datasetGraph.add(Node.createURI(graph), Node.createURI(subject), Node.createURI(predicate), Node.createURI(object));
        }
    }

    @Override<commit_msg>More ORDER BY.<commit_after>package org.python.ReL;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;

import org.python.core.*;
import org.python.antlr.base.expr;

import com.hp.hpl.jena.graph.*;
import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.core.*;
import com.hp.hpl.jena.datatypes.BaseDatatype;
import com.hp.hpl.jena.datatypes.DatatypeFormatException;
import com.hp.hpl.jena.datatypes.RDFDatatype;
import com.hp.hpl.jena.datatypes.TypeMapper;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.vocabulary.RDF;

import oracle.rdf.kv.client.jena.*;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * A class that is used to interface with the oracle database.
 * All statements and queries should go through here to communicate with oracle.
 */
 
public class OracleRDFNoSQLInterface extends DatabaseInterface {

    private OracleNoSqlConnection connection;
    DatasetGraphNoSql datasetGraph = null;
    private ResultSet rs = null;
    private String debug;
    private String nameSpace = "carnot:";
    private String nameSpacePrefix = "c";
     
    public OracleRDFNoSQLInterface(String url, String uname, String passw, String conn_type, String debug) {
        super();

        connection = null;
        this.debug = debug;

        if(conn_type != "none" ) {
            this.connection = OracleNoSqlConnection.createInstance("kvstore", "Phils-MacBook-Pro.local", "5000");
            OracleGraphNoSql graph = new OracleGraphNoSql(connection);
            this.datasetGraph = DatasetGraphNoSql.createFrom(graph);

            // Close graph, as it is no longer needed
            graph.close(); 
            
            // Clear dataset
            System.out.println("\nWRNING: the NoSQL database is being cleared in PyRelConnection!\n");
            datasetGraph.clearRepository();
        }
    }

    public String getNameSpace() { return nameSpace; }
    public String getNameSpacePrefix() { return nameSpacePrefix; }

    @Override
    public void OracleNoSQLAddQuad(String graph, String subject, String predicate, String object)
    {
        if( ! graph.contains("http://"))     graph     = nameSpace + graph;
        if( ! subject.contains("http://"))   subject   = nameSpace + subject;
        if( ! predicate.contains("http://")) predicate = nameSpace + predicate;
        if( ! object.contains("http://"))    object    = nameSpace + object;
        if(debug.equals("debug")) System.out.println("In addQuad, stmt is: " + graph + ", " + subject + ", " + predicate + ", " + object);

        try  { 
            Double.parseDouble(object.replaceAll(nameSpace, "")); 
            datasetGraph.add(Node.createURI(graph), Node.createURI(subject), Node.createURI(predicate), Node.createLiteral(object.replaceAll(nameSpace, "")));
        } catch(NumberFormatException e)  
        {   
          datasetGraph.add(Node.createURI(graph), Node.createURI(subject), Node.createURI(predicate), Node.createURI(object));
        }
    }

    @Override
{'fraction_non_alphanumeric': 0.12494776431257835, 'fraction_numerical': 0.0011143613316617913, 'mean_word_length': 3.2738095238095237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3014814', 'n_tokens_mistral': 2226, 'n_tokens_neox': 2188, 'n_words': 455}