<commit_before>package com.github.anno4j.util;


import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import org.openrdf.model.*;
import org.openrdf.model.impl.GraphImpl;
import org.openrdf.model.impl.StatementImpl;
import org.openrdf.model.impl.ValueFactoryImpl;

import java.util.Vector;

/**
 * Provides functionality to convert Jena objects to Sesame objects.
 */
public class JenaSesameUtils {

    /**
     * Internal model used to create instances of Jena API objects
     */
    private static final Model mInternalModel = ModelFactory.createDefaultModel();

    /**
     * Sesame value factory for creating instances of Sesame API objects
     */
    private static final ValueFactory FACTORY = new ValueFactoryImpl();

    /**
     * Convert the given Jena Resource into a Sesame Resource
     * @param theRes the jena resource to convert
     * @return the jena resource as a sesame resource
     */
    public static org.openrdf.model.Resource asSesameResource(Resource theRes) {
        if (theRes == null) {
            return null;
        }
        else if (theRes.canAs(Property.class)) {
            return asSesameURI(theRes.as(Property.class));
        }
        else {
            return FACTORY.createBNode(theRes.getId().getLabelString());
        }
    }

    /**
     * Convert the given Jena Property instance to a Sesame URI instance<commit_msg>Map blank nodes to unique URIs when converting to Sesame triples (cf. issue #164).<commit_after>package com.github.anno4j.util;


import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import org.openrdf.model.*;
import org.openrdf.model.impl.GraphImpl;
import org.openrdf.model.impl.StatementImpl;
import org.openrdf.model.impl.ValueFactoryImpl;

import java.util.Vector;

/**
 * Provides functionality to convert Jena objects to Sesame objects.
 */
public class JenaSesameUtils {

    /**
     * Internal model used to create instances of Jena API objects
     */
    private static final Model mInternalModel = ModelFactory.createDefaultModel();

    /**
     * Sesame value factory for creating instances of Sesame API objects
     */
    private static final ValueFactory FACTORY = new ValueFactoryImpl();

    /**
     * Convert the given Jena Resource into a Sesame Resource
     * @param theRes the jena resource to convert
     * @return the jena resource as a sesame resource
     */
    public static org.openrdf.model.Resource asSesameResource(Resource theRes) {
        if (theRes == null) {
            return null;
        }
        else if (theRes.canAs(Property.class)) {
            return asSesameURI(theRes.as(Property.class));
        }
        else {
            return FACTORY.createURI("urn:anno4j:" + theRes.getId().getLabelString());
        }
    }

    /**
     * Convert the given Jena Property instance to a Sesame URI instance
{'fraction_non_alphanumeric': 0.10046511627906977, 'fraction_numerical': 0.0018604651162790699, 'mean_word_length': 2.9729064039408866, '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': '4940932', 'n_tokens_mistral': 1006, 'n_tokens_neox': 993, 'n_words': 257}