<commit_before>
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import logging

from askomics.libaskomics.ParamManager import ParamManager

from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder
from askomics.libaskomics.rdfdb.SparqlQueryGraph import SparqlQueryGraph
from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher
from askomics.libaskomics.rdfdb.MultipleQueryLauncher import MultipleQueryLauncher
from askomics.libaskomics.rdfdb.FederationQueryLauncher import FederationQueryLauncher

from askomics.libaskomics.EndpointManager import EndpointManager

class TripleStoreExplorer(ParamManager):
    """
    Use the different Sparql template queries in order to:
        - get special settings:
            * relation between two classes (nodes) specified by another class (hidden node).
            * virtual relation adding special Where clauses specified in the database domain.
        - get the suggestion list for classes listed as Categories and displayed
          as node attributes by AskOmics.
        - get the startpoints to begin a query building.
        - get the neighbor nodes and the attributes of a node.
    """

    def __init__(self, settings, session, dico={}):
        ParamManager.__init__(self, settings, session)

        self.log = logging.getLogger(__name__)

    def get_start_points(self):
        """
        Get the possible starting points for your graph.

        :return: List of starting points
        :rtype: Node list
        """
        self.log.debug(" =========== TripleStoreExplorer:get_start_points ===========")
        nodes = []

        sqg = SparqlQueryGraph(self.settings, self.session)
        ql = MultipleQueryLauncher(self.settings, self.session)
        em = EndpointManager(self.settings, self.session)

        results = ql.process_query(sqg.get_public_start_point().query,em.listAskomicsEndpoints(),indexByEndpoint=True)
        results.update(ql.process_query(sqg.get_user_start_point().query,em.listAskomicsEndpoints(),indexByEndpoint=True))

        for endpoint in results:
            for result in results[endpoint]:
                g  = result["g"]
                uri = result["nodeUri"]
                label = result["nodeLabel"]

                if ('accesLevel' in result) and ('private' in result['accesLevel']):
                    public = False
                    private = True
                else:
                    public = True<commit_msg>fix bug startingpoint without connexion<commit_after>
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import logging

from askomics.libaskomics.ParamManager import ParamManager

from askomics.libaskomics.rdfdb.SparqlQueryBuilder import SparqlQueryBuilder
from askomics.libaskomics.rdfdb.SparqlQueryGraph import SparqlQueryGraph
from askomics.libaskomics.rdfdb.QueryLauncher import QueryLauncher
from askomics.libaskomics.rdfdb.MultipleQueryLauncher import MultipleQueryLauncher
from askomics.libaskomics.rdfdb.FederationQueryLauncher import FederationQueryLauncher

from askomics.libaskomics.EndpointManager import EndpointManager

class TripleStoreExplorer(ParamManager):
    """
    Use the different Sparql template queries in order to:
        - get special settings:
            * relation between two classes (nodes) specified by another class (hidden node).
            * virtual relation adding special Where clauses specified in the database domain.
        - get the suggestion list for classes listed as Categories and displayed
          as node attributes by AskOmics.
        - get the startpoints to begin a query building.
        - get the neighbor nodes and the attributes of a node.
    """

    def __init__(self, settings, session, dico={}):
        ParamManager.__init__(self, settings, session)

        self.log = logging.getLogger(__name__)

    def get_start_points(self):
        """
        Get the possible starting points for your graph.

        :return: List of starting points
        :rtype: Node list
        """
        self.log.debug(" =========== TripleStoreExplorer:get_start_points ===========")
        nodes = []

        sqg = SparqlQueryGraph(self.settings, self.session)
        ql = MultipleQueryLauncher(self.settings, self.session)
        em = EndpointManager(self.settings, self.session)

        results = ql.process_query(sqg.get_public_start_point().query,em.listAskomicsEndpoints(),indexByEndpoint=True)
        r2 = ql.process_query(sqg.get_user_start_point().query,em.listAskomicsEndpoints(),indexByEndpoint=True)
        
        for key, value in r2.items():
            if key in results:
                for elt in value:
                    results[key].append(elt)
            else:
                results[key] = r2[key]

        for endpoint in results:
            for result in results[endpoint]:
                g  = result["g"]
                uri = result["nodeUri"]
                label = result["nodeLabel"]

                if ('accesLevel' in result) and ('private' in result['accesLevel']):
                    public = False
                    private = True
                else:
                    public = True
{'fraction_non_alphanumeric': 0.08496605237633366, 'fraction_numerical': 0.0013579049466537342, 'mean_word_length': 2.717375630857967, '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': '5206154', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1318, 'n_words': 375}