<commit_before>
require 'rubygems'
require 'json/ld'
require 'sparql'
require 'rdf/nquads'
require 'minitest/autorun'

describe 'example-codemeta-full.json deserialized to RDF' do
  before (:all) do
    @input = JSON.parse(File.read('examples/example-codemeta-full.json'))
    @graph = RDF::Graph.new << JSON::LD::API.toRdf(@input)
  end

  it 'parses to a non-empty graph' do
    refute @graph.empty?
  end

  it 'has an author orcid' do
    sse = SPARQL.parse("PREFIX so: <http://schema.org/>
                        PREFIX cm: <https://codemeta.github.io/terms/>
                        PREFIX orcid: <http://orcid.org/>
                        SELECT * WHERE { orcid:0000-0002-2192-403X ?p ?o  }")
    resultSet = @graph.query(sse)
    #resultSet.each do |result|
      #puts result.inspect
      #puts "predicate=#{result.p} object=#{result.o}"
    #end
    refute resultSet.empty?
  end

  it 'has agent' do
    sse = SPARQL.parse("PREFIX so: <http://schema.org/>
                      PREFIX cm: <https://codemeta.github.io/terms/>
                      PREFIX orcid: <http://orcid.org/>
                      SELECT * WHERE { ?s <http://schema.org/agent> ?o  }")
    resultSet = @graph.query(sse)
    #resultSet.each do |result|
    #  puts result.inspect
    #end
    refute resultSet.empty?
  end

  it 'has schema.org predicates' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <http://schema.org/JSONTerm> ?o  }"
     # Check statements with schema.org based predicate
     predicates = ["affiliation", "codeRepository", "dateCreated", "dateModified", "datePublished",
                  "description", "downloadUrl", "email", "keywords", "license",
                 "programmingLanguage", "publisher", "suggests",
                 "version", "URL", "name"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
           #puts result.inspect
         #nd
         refute resultSet.empty?
     end
   end

  it 'has codemeta predicates' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <https://codemeta.github.io/terms/JSONTerm> ?o  }"
     # Check statements with codemeta namespaced predicate
     predicates = ["buildInstructions", "contIntegration",
       "embargoDate", "function", "funding", "inputs", "interactionMethod",
       "isAutomatedBuild", "isMaintainer", "isRightsHolder", "issueTracker", "mustBeCited", "namespace", "outputs",
       "packageId", "packageSystem", "readme", "relatedLink",
       "relatedPublications", "relationship", "relationshipType", "relatedIdentifier", "relatedIdentifierType",
       "requirement", "Role", "roleCode", "softwareCitation", "softwarePaperCitation",
       "uploadedBy", "zippedCode"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
         # puts result.inspect
         #end
         refute resultSet.empty?
     end
  end

  it 'has dcterms' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <http://purl.org/dc/terms/JSONTerm> ?o  }"
     # Check statements with codemeta namespaced predicate
     predicates = ["identifier", "title"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
          # puts result.inspect
         #end
         refute resultSet.empty?
     end
   end
end
<commit_msg>Remove ‘packageId’ term from RDF serialization test<commit_after>
require 'rubygems'
require 'json/ld'
require 'sparql'
require 'rdf/nquads'
require 'minitest/autorun'

describe 'example-codemeta-full.json deserialized to RDF' do
  before (:all) do
    @input = JSON.parse(File.read('examples/example-codemeta-full.json'))
    @graph = RDF::Graph.new << JSON::LD::API.toRdf(@input)
  end

  it 'parses to a non-empty graph' do
    refute @graph.empty?
  end

  it 'has an author orcid' do
    sse = SPARQL.parse("PREFIX so: <http://schema.org/>
                        PREFIX cm: <https://codemeta.github.io/terms/>
                        PREFIX orcid: <http://orcid.org/>
                        SELECT * WHERE { orcid:0000-0002-2192-403X ?p ?o  }")
    resultSet = @graph.query(sse)
    #resultSet.each do |result|
      #puts result.inspect
      #puts "predicate=#{result.p} object=#{result.o}"
    #end
    refute resultSet.empty?
  end

  it 'has agent' do
    sse = SPARQL.parse("PREFIX so: <http://schema.org/>
                      PREFIX cm: <https://codemeta.github.io/terms/>
                      PREFIX orcid: <http://orcid.org/>
                      SELECT * WHERE { ?s <http://schema.org/agent> ?o  }")
    resultSet = @graph.query(sse)
    #resultSet.each do |result|
    #  puts result.inspect
    #end
    refute resultSet.empty?
  end

  it 'has schema.org predicates' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <http://schema.org/JSONTerm> ?o  }"
     # Check statements with schema.org based predicate
     predicates = ["affiliation", "codeRepository", "dateCreated", "dateModified", "datePublished",
                  "description", "downloadUrl", "email", "keywords", "license",
                 "programmingLanguage", "publisher", "suggests",
                 "version", "URL", "name"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
           #puts result.inspect
         #nd
         refute resultSet.empty?
     end
   end

  it 'has codemeta predicates' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <https://codemeta.github.io/terms/JSONTerm> ?o  }"
     # Check statements with codemeta namespaced predicate
     predicates = ["buildInstructions", "contIntegration",
       "embargoDate", "function", "funding", "inputs", "interactionMethod",
       "isAutomatedBuild", "isMaintainer", "isRightsHolder", "issueTracker", "mustBeCited", "namespace", "outputs",
       "packageSystem", "readme", "relatedLink",
       "relatedPublications", "relationship", "relationshipType", "relatedIdentifier", "relatedIdentifierType",
       "requirement", "Role", "roleCode", "softwareCitation", "softwarePaperCitation",
       "uploadedBy", "zippedCode"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
         # puts result.inspect
         #end
         refute resultSet.empty?
     end
  end

  it 'has dcterms' do
     queryStr = "PREFIX so: <http://schema.org/>
                 PREFIX cm: <https://codemeta.github.io/terms/>
                 PREFIX orcid: <http://orcid.org/>
                 SELECT * WHERE { ?s <http://purl.org/dc/terms/JSONTerm> ?o  }"
     # Check statements with codemeta namespaced predicate
     predicates = ["identifier", "title"]
     predicates.each do |thisPredicate|
         thisQueryStr = queryStr.gsub("JSONTerm", thisPredicate)
         sse = SPARQL.parse(thisQueryStr)
         resultSet = @graph.query(sse)
         #resultSet.each do |result|
          # puts result.inspect
         #end
         refute resultSet.empty?
     end
   end
end

{'fraction_non_alphanumeric': 0.13455767614932182, 'fraction_numerical': 0.0036010082823190494, 'mean_word_length': 2.3515687851971037, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 41, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106572', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2543, 'n_words': 585}