Ë
    µŒjK)  ã                  óê   — d dl mZ d dlmZmZmZmZ erd dlZdddddœZed	   d
z   Z	ed	   dz   Z
ed	   dz   Zed	   dz   Zed   ed	   z   dz   Zed	   ed   z   dz   Zed	   ed   z   dz   Z G d„ d«      Zy)é    )Úannotations)ÚTYPE_CHECKINGÚDictÚListÚOptionalNz-PREFIX owl: <http://www.w3.org/2002/07/owl#>
z:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
z5PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
z0PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
)ÚowlÚrdfÚrdfsÚxsdr
   zeSELECT DISTINCT ?cls ?com
WHERE { 
    ?instance a ?cls . 
    OPTIONAL { ?cls rdfs:comment ?com } 
}zvSELECT DISTINCT ?cls ?com
WHERE { 
    ?instance a/rdfs:subClassOf* ?cls . 
    OPTIONAL { ?cls rdfs:comment ?com } 
}z’SELECT DISTINCT ?cls ?com
WHERE { 
    ?instance a/rdfs:subClassOf* ?cls . 
    FILTER (isIRI(?cls)) . 
    OPTIONAL { ?cls rdfs:comment ?com } 
}zdSELECT DISTINCT ?rel ?com
WHERE { 
    ?subj ?rel ?obj . 
    OPTIONAL { ?rel rdfs:comment ?com } 
}r	   z|SELECT DISTINCT ?rel ?com
WHERE { 
    ?rel a/rdfs:subPropertyOf* rdf:Property . 
    OPTIONAL { ?rel rdfs:comment ?com } 
}r   zSELECT DISTINCT ?op ?com
WHERE { 
    ?op a/rdfs:subPropertyOf* owl:ObjectProperty . 
    OPTIONAL { ?op rdfs:comment ?com } 
}z�SELECT DISTINCT ?dp ?com
WHERE { 
    ?dp a/rdfs:subPropertyOf* owl:DatatypeProperty . 
    OPTIONAL { ?dp rdfs:comment ?com } 
}c                  ó    — e Zd ZdZ	 	 	 	 	 	 	 	 d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zedd„«       Z	 	 	 	 dd„Z	 	 	 	 dd„Ze	dd„«       Z
dd„Zdd	„Zy)ÚRdfGraphaì  RDFlib wrapper for graph operations.

    Modes:
    * local: Local file - can be queried and changed
    * online: Online file - can only be queried, changes can be stored locally
    * store: Triple store - can be queried and changed if update_endpoint available
    Together with a source file, the serialization should be specified.

    *Security note*: Make sure that the database connection uses credentials
        that are narrowly-scoped to only include necessary permissions.
        Failure to do so may result in data corruption or loss, since the calling
        code may attempt commands that would result in deletion, mutation
        of data if appropriately prompted or reading sensitive data if such
        data is present in the database.
        The best way to guard against such negative outcomes is to (as appropriate)
        limit the permissions granted to the credentials used with this tool.

        See https://python.langchain.com/docs/security for more information.
    Nc	                ó¬  — || _         || _        || _        || _        || _        || _        	 ddl}	ddlm}
 | j                  dx}vrt        d|› d�«      ‚|s|r|r|s|rt        d«      ‚|rz|j                  d	«      rd
| _        n$d| _        | j
                  €| j                   | _         |	j                  «       | _        | j                  j                  || j                  ¬«       |rž|xs i }d| _        |s3 |
j                   di |¤Ž| _        | j"                  j%                  |«       n4 |
j&                  di |¤Ž| _        | j"                  j%                  ||f«       |xs i } |	j                  | j"                  fi |¤Ž| _        t)        | j                  «      st+        d«      ‚d| _        | j/                  «        y# t        $ r t        d«      ‚w xY w)aä  
        Set up the RDFlib graph

        :param source_file: either a path for a local file or a URL
        :param serialization: serialization of the input
        :param query_endpoint: SPARQL endpoint for queries, read access
        :param update_endpoint: SPARQL endpoint for UPDATE queries, write access
        :param standard: RDF, RDFS, or OWL
        :param local_copy: new local copy for storing changes
        :param graph_kwargs: Additional rdflib.Graph specific kwargs
        that will be used to initialize it,
        if query_endpoint is provided.
        :param store_kwargs: Additional sparqlstore.SPARQLStore specific kwargs
        that will be used to initialize it,
        if query_endpoint is provided.
        r   N)ÚsparqlstorezTCould not import rdflib python package. Please install it with `pip install rdflib`.)r	   r
   r   z+Invalid standard. Supported standards are: Ú.z–Could not unambiguously initialize the graph wrapper. Specify either a file (local or online) via the source_file or a triple store via the endpoints.ÚhttpÚonlineÚlocal)ÚformatÚstorezThe graph is empty.Ú © )Úsource_fileÚserializationÚquery_endpointÚupdate_endpointÚstandardÚ
local_copyÚrdflibÚrdflib.plugins.storesr   ÚImportErrorÚ
ValueErrorÚ
startswithÚmodeÚGraphÚgraphÚparseÚSPARQLStoreÚ_storeÚopenÚSPARQLUpdateStoreÚlenÚAssertionErrorÚschemaÚload_schema)Úselfr   r   r   r   r   r   Úgraph_kwargsÚstore_kwargsr   r   Úsupported_standardss               ún/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/graphs/rdf_graph.pyÚ__init__zRdfGraph.__init__o   sÙ  € ð6 'ˆÔØ*ˆÔØ,ˆÔØ.ˆÔØ ˆŒØ$ˆŒð	ÛÝ9ð �=‰=Ð8NÐ!NÐ!4ÑOÜØ=Ð>QÐ=RÐRSÐTóð ñ
 Ù"ÙÙ¡?äð7óð ñ Ø×%Ñ% fÔ-Ø$�•	à#�”	Ø—?‘?Ð*Ø&*×&6Ñ&6�D”OØ%˜Ÿ™›ˆDŒJØ�J‰J×Ñ˜[°×1CÑ1CÐÔDáØ'Ò-¨2ˆLØˆDŒIÙ"Ø5˜k×5Ñ5ÑE¸ÑE�”Ø—‘× Ñ  Õ0à;˜k×;Ñ;ÑK¸lÑK�”Ø—‘× Ñ  .°/Ð!BÔCØ'Ò-¨2ˆLØ%˜Ÿ™ d§k¡kÑB°\ÑBˆDŒJô �4—:‘:ŒÜ Ð!6Ó7Ð7ð ˆŒØ×ÑÕøôe ò 	Üð?óð ð	ús   ¬
F> Æ>Gc                ó   — | j                   S )z;
        Returns the schema of the graph database.
        )r-   )r/   s    r3   Ú
get_schemazRdfGraph.get_schemaÈ   s   € ð
 �{‰{Ðó    c                óÌ   — ddl m} ddlm} 	 | j                  j                  |«      }|D �cg c]  }t        ||«      sŒ|‘Œ c}S # |$ r}t        d|› �«      ‚d}~ww xY wc c}w )z"
        Query the graph.
        r   ©ÚParserError)Ú	ResultRowú&Generated SPARQL statement is invalid
N)Úrdflib.exceptionsr:   Úrdflib.queryr;   r%   Úqueryr!   Ú
isinstance)r/   r?   r:   r;   ÚresÚeÚrs          r3   r?   zRdfGraph.queryÏ   sm   € õ 	2Ý*ð	LØ—*‘*×"Ñ" 5Ó)ˆCñ Ó;™3�a¤*¨Q°	Õ":’˜3Ñ;Ð;øð ò 	LÜÐFÀqÀcÐJÓKÐKûð	Lüâ;s!   ŽA ­A!¿A!ÁAÁAÁAc                ó2  — ddl m} 	 | j                  j                  |«       | j
                  rD| j                  j                  | j
                  | j
                  j                  d«      d   ¬«       yt	        d«      ‚# |$ r}t	        d|› �«      ‚d}~ww xY w)	z#
        Update the graph.
        r   r9   r<   Nr   éÿÿÿÿ)Údestinationr   z5No target file specified for saving the updated file.)r=   r:   r%   Úupdater!   r   Ú	serializeÚsplit)r/   r?   r:   rB   s       r3   rG   zRdfGraph.updateß   s‘   € õ 	2ð	LØ�J‰J×Ñ˜eÔ$ð �?Š?Ø�J‰J× Ñ Ø ŸO™O°D·O±O×4IÑ4IÈ#Ó4NÈrÑ4Rð !õ ô ÐTÓUÐUøð ò 	LÜÐFÀqÀcÐJÓKÐKûð	Lús   ˆA> Á>BÂBÂBc                óˆ   — d| v r| j                  d«      d   }|S d| v r| j                  d«      d   }|S t        d| › d�«      ‚)NÚ#rE   Ú/zUnexpected IRI 'z ', contains neither '#' nor '/'.)rI   r!   )ÚiriÚ
local_names     r3   Ú_get_local_namezRdfGraph._get_local_nameó   s^   € à�#‰:ØŸ™ 3›¨Ñ+ˆJð
 Ðð	 �C‰ZØŸ™ 3›¨Ñ+ˆJð Ðô Ð/°¨uÐ4TÐUÓVÐVr7   c                ó~   — dt        ||   «      z   dz   | j                  ||   «      z   dz   t        |d   «      z   dz   S )NÚ<z> (ú, ÚcomÚ))ÚstrrO   )r/   rA   Úvars      r3   Ú_res_to_strzRdfGraph._res_to_strý   sa   € àÜ�#�c‘(‹mñàñð ×"Ñ" 3 s¡8Ó,ñ-ð ñ	ô
 �#�e‘*‹oñð ñð	
r7   c                óZ  ‡ — 	 	 	 	 	 	 dˆ fd„}‰ j                   dk(  r9‰ j                  t        «      }‰ j                  t        «      } |||«      ‰ _        y‰ j                   dk(  r9‰ j                  t
        «      }‰ j                  t        «      } |||«      ‰ _        y‰ j                   dk(  rØ‰ j                  t        «      }‰ j                  t        «      }‰ j                  t        «      }ddj                  |D �cg c]  }‰ j                  |d«      ‘Œ c}«      › ddj                  |D �cg c]  }‰ j                  |d	«      ‘Œ c}«      › d
dj                  |D �cg c]  }‰ j                  |d«      ‘Œ c}«      › d�‰ _        yt        d‰ j                   › d�«      ‚c c}w c c}w c c}w )z4
        Load the graph schema information.
        c                óÞ   •— ddj                  | D �cg c]  }‰j                  |d«      ‘Œ c}«      › ddj                  |D �cg c]  }‰j                  |d«      ‘Œ c}«      › d�S c c}w c c}w )NzšIn the following, each IRI is followed by the local name and optionally its description in parentheses. 
The RDF graph supports the following node types:
rR   Úclsz5
The RDF graph supports the following relationships:
ÚrelÚ
)ÚjoinrW   )ÚclassesÚrelationshipsrC   r/   s      €r3   Ú_rdf_s_schemaz+RdfGraph.load_schema.<locals>._rdf_s_schema  s   ø€ ð
Eð —9‘9Á'ÓJÁ'¸Q˜d×.Ñ.¨q°%Õ8À'ÑJÓKÐLð MHà—9‘9Á-ÓPÁ-¸Q˜d×.Ñ.¨q°%Õ8À-ÑPÓQÐRÐRTðVðùò KùâPs   ’A%
ÁA*r	   r
   r   zšIn the following, each IRI is followed by the local name and optionally its description in parentheses. 
The OWL graph supports the following node types:
rR   rZ   z^
The OWL graph supports the following object properties, i.e., relationships between objects:
Úopzi
The OWL graph supports the following data properties, i.e., relationships between objects and literals:
Údpr\   zMode 'z' is currently not supported.N)r^   úList[rdflib.query.ResultRow]r_   rc   ÚreturnrU   )r   r?   Úcls_query_rdfÚrel_query_rdfr-   Úcls_query_rdfsÚrel_query_rdfsÚcls_query_owlÚop_query_owlÚdp_query_owlr]   rW   r!   )r/   r`   ÚclssÚrelsÚopsÚdpsrC   s   `      r3   r.   zRdfGraph.load_schema  sœ  ø€ ð
	Ø1ð	à7ð	ð õ	ð �=‰=˜EÒ!Ø—:‘:œmÓ,ˆDØ—:‘:œmÓ,ˆDÙ'¨¨dÓ3ˆD�KØ�]‰]˜fÒ$Ø—:‘:œnÓ-ˆDØ—:‘:œnÓ-ˆDÙ'¨¨dÓ3ˆD�KØ�]‰]˜eÒ#Ø—:‘:œmÓ,ˆDØ—*‘*œ\Ó*ˆCØ—*‘*œ\Ó*ˆCðEð —9‘9Á$ÓGÁ$¸Q˜d×.Ñ.¨q°%Õ8À$ÑGÓHÐIð J9ð —9‘9ÁÓEÁ¸A˜d×.Ñ.¨q°$Õ7ÀÑEÓFÐGð HFð —9‘9ÁÓEÁ¸A˜d×.Ñ.¨q°$Õ7ÀÑEÓFÐGÀrð	Kð �Kô ˜v d§m¡m _Ð4QÐRÓSÐSùò Hùò Fùò Fs   Ã<F
Ä,F#ÅF()NÚttlNNr	   NNN)r   úOptional[str]r   rq   r   rq   r   rq   r   rq   r   rq   r0   úOptional[Dict]r1   rr   rd   ÚNone)rd   rU   )r?   rU   rd   rc   )r?   rU   rd   rs   )rM   rU   rd   rU   )rA   zrdflib.query.ResultRowrV   rU   rd   rU   )rd   rs   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r4   Úpropertyr6   r?   rG   ÚstaticmethodrO   rW   r.   r   r7   r3   r   r   Z   sí   „ ñð, &*Ø',Ø(,Ø)-Ø"'Ø$(Ø'+Ø'+ðWà"ðWð %ðWð &ð	Wð
 'ðWð  ðWð "ðWð %ðWð %ðWð 
óWðr òó ðð<àð<ð 
&ó<ð VàðVð 
óVð( òó ðó	
ô+Tr7   r   )Ú
__future__r   Útypingr   r   r   r   r   Úprefixesre   rg   ri   rf   rh   rj   rk   r   r   r7   r3   Ú<module>r}      s  ðÝ "÷ó ñ Ûð @ØLØHØBñ	€ð ˜Ñ ðñ€ð ˜&Ñ!ðñ€ð ˜Ñ ðñ€ð ˜Ñ ðñ€ð ˆU�OØˆvÑñð	ñð ð ˆVÑØˆu�oñð	ñð ð ˆVÑØˆu�oñð	ñð ÷YTò YTr7   