<commit_before>
(ns kabob.build.input-kb
  (:require [kr.core.kb
             :refer [connection kb]]
            [kr.core.rdf
             :refer [register-namespaces synch-ns-mappings]]
            [kr.sesame.kb
             :refer [*default-server* *repository-name* *username* *password*]]
            [kabob.core.namespace
             :refer [*namespaces*]])
  (:import [org.openrdf.rio RDFFormat]
           [org.openrdf.query.resultio TupleQueryResultFormat]
           [org.openrdf.repository.http HTTPRepository]
           [virtuoso.sesame2.driver VirtuosoRepository]))

(defn initialize-kb [kb]
  (register-namespaces (synch-ns-mappings (connection kb)) *namespaces*))

(defn virtuoso-kb [args]
  ;;Init source KB connection
  (println "forcing a virtuoso connection")
  (let [kb (kb (VirtuosoRepository. "jdbc:virtuoso://localhost:1111","dba","dba"))]
    (initialize-kb kb)))

(defn open-kb [args]
  (binding [*default-server* (:server-url args)
            *repository-name* (:repo-name args)
            *username* (:username args)
            *password* (:password args)]
    (if (= "true" (:is-virtuoso args))
      (virtuoso-kb args)
      (initialize-kb (kb HTTPRepository)))))

(def source-kb open-kb)
<commit_msg>Testing the virtuoso connection url<commit_after>
(ns kabob.build.input-kb
  (:require [kr.core.kb
             :refer [connection kb]]
            [kr.core.rdf
             :refer [register-namespaces synch-ns-mappings]]
            [kr.sesame.kb
             :refer [*default-server* *repository-name* *username* *password*]]
            [kabob.core.namespace
             :refer [*namespaces*]])
  (:import [org.openrdf.rio RDFFormat]
           [org.openrdf.query.resultio TupleQueryResultFormat]
           [org.openrdf.repository.http HTTPRepository]
           [virtuoso.sesame2.driver VirtuosoRepository]))

(defn initialize-kb [kb]
  (register-namespaces (synch-ns-mappings (connection kb)) *namespaces*))

(defn virtuoso-kb [args]
  ;;Init source KB connection
  (println "forcing a virtuoso connection")
  (let [kb (kb (VirtuosoRepository. "jdbc:virtuoso://virtuoso-prod:1111","dba","dba"))]
    (initialize-kb kb)))

(defn open-kb [args]
  (binding [*default-server* (:server-url args)
            *repository-name* (:repo-name args)
            *username* (:username args)
            *password* (:password args)]
    (if (= "true" (:is-virtuoso args))
      (virtuoso-kb args)
      (initialize-kb (kb HTTPRepository)))))

(def source-kb open-kb)

{'fraction_non_alphanumeric': 0.14703525641025642, 'fraction_numerical': 0.004006410256410256, 'mean_word_length': 2.7948328267477205, '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': '4598802', 'n_tokens_mistral': 861, 'n_tokens_neox': 824, 'n_words': 174}