M-Bostone commented on issue #1705: URL: https://github.com/apache/age/issues/1705#issuecomment-2041148905
sorry it took me this long to reply but i've got one of the slowest machines there is but try this: def upsert_triplet(self, subj: str, rel: str, obj: str) -> None: """Add triplet.""" rel = rel.replace(" ", "_").upper() prepared_statement = f""" MERGE (n1:`{self.node_label}` {{id: $subj}}) MERGE (n2:`{self.node_label}` {{id: $obj}}) MERGE (n1)-[:`{rel}`]->(n2) """ self._age.execCypher(prepared_statement, params={"subj": subj, "obj": obj}) self._age.commit() try this On Sat, Apr 6, 2024 at 4:44 PM Moturi Bostone ***@***.***> wrote: > let me take a look > > > On Sat, Apr 6, 2024 at 4:35 PM Noah Zhu ***@***.***> wrote: > >> okay let me check your documents and see where the problem is do you mind >> if i see your work >> … <#m_7435983581932783017_m_8141234859897622336_> >> On Sat, Apr 6, 2024 at 3:56 PM Noah Zhu *@*.*> wrote: have you tried >> escaping the single quotes by doubling the single quotes like; MERGE >> (n2:Entity {id: 'It''s better for technology companies to be run by product >> people'}) which will tell your parser to treat the single quote in your >> string as part of the string … <#m_6476712402078747728_> On Sat, Apr 6, >> 2024 at 3:10 PM Noah Zhu @.> wrote: Hi @M-Bostone >> <https://github.com/M-Bostone> https://github.com/M-Bostone >> <https://github.com/M-Bostone> https://github.com/M-Bostone >> <https://github.com/M-Bostone> https://github.com/M-Bostone >> <https://github.com/M-Bostone> For sure, I'm encountering some problem with >> age that the behavior is little different with the Neo4j in some specific >> case, I've already created a issue for this #1722 >> <https://github.com/apache/age/issues/1722> <#1722 >> <https://github.com/apache/age/issues/1722>> <#1722 >> <https://github.com/apache/age/issues/1722> <#1722 >> <https://github.com/apache/age/issues/1722>>> I'd appreciate some help. >> Also I want to contribute to this project, but I need to learn more in >> advance. — Reply to this email directly, view it on GitHub <#1705 >> <https://github.com/apache/age/issues/1705> (comment) <#1705 (comment) >> <https://github.com/apache/age/issues/1705#issuecomment-2041065431>>>, or >> unsubscribe >> https://github.com/notifications/unsubscribe-auth/BFO2YCEMHQXK6WMEXQ25LTTY37Q2HAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3DKNBTGE >> <https://github.com/notifications/unsubscribe-auth/BFO2YCEMHQXK6WMEXQ25LTTY37Q2HAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3DKNBTGE> >> https://github.com/notifications/unsubscribe-auth/BFO2YCEMHQXK6WMEXQ25LTTY37Q2HAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3DKNBTGE >> <https://github.com/notifications/unsubscribe-auth/BFO2YCEMHQXK6WMEXQ25LTTY37Q2HAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3DKNBTGE> >> . You are receiving this because you were mentioned.Message ID: @.> -- men >> I'm using the docker image which is provided on the github README.md for >> some testing. I do can put the completed query and add like backslash, use >> double quotes to wrap the string if the string contains single quotes or >> use single quotes to wrap the string if the string contains double quotes. >> But most of my time, I need to parameterize the queries that looks buggy, >> especially with the python driver. And for now the problem from my side is >> all the strings are from some documents, that means I need to process the >> string in advance to put it as the parameters into the query, but that >> doesn't work for now. There's no this kinds of problems when I use the >> Neo4j. Also I can't create a vertex with a label contain single quotes >> which works in Neo4j. — Reply to this email directly, view it on GitHub >> <#1705 (comment) >> <https://github.com/apache/age/issues/1705#issuecomment-2041074897>>, or >> unsubscribe >> https://github.com/notifications/unsubscribe-auth/BFO2YCCQ7PVYHFUFGPDN44LY37WGLAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3TIOBZG4 >> <https://github.com/notifications/unsubscribe-auth/BFO2YCCQ7PVYHFUFGPDN44LY37WGLAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA3TIOBZG4> >> . You are receiving this because you were mentioned.Message ID: @.***> >> >> I'm working with the llamaindex, use LLM(OpenAI Model) to extract some >> contents to triplets like [subj, rel, obj], the contents are from any pdfs >> or txts, so that means I can't fully control what the LLM extract for me, >> maybe the subj contains some special chars, or rel and obj as well. >> >> this is my python code >> >> def upsert_triplet(self, subj: str, rel: str, obj: str) -> None: >> """Add triplet.""" >> rel = rel.replace(" ", "_").upper() >> prepared_statement = f""" >> MERGE (n1:`{self.node_label}` {{id: %s}}) >> MERGE (n2:`{self.node_label}` {{id: %s}}) >> MERGE (n1)-[:`{rel}`]->(n2) >> """ >> >> self._age.execCypher(prepared_statement, params=(subj, obj)) >> self._age.commit() >> >> the extracted data could be: >> >> ["I", "Learned", "It's better for technology companies to be run by product people"] >> >> >> or maybe the subj or rel also includes single quotes or double quotes >> ["I", "include any '", "It's better for technology companies to be run by product people"] >> >> There's no problem with this kind of data in Neo4j. >> >> — >> Reply to this email directly, view it on GitHub >> <https://github.com/apache/age/issues/1705#issuecomment-2041083817>, or >> unsubscribe >> <https://github.com/notifications/unsubscribe-auth/BFO2YCAJJG2OD53YGL57NX3Y372ZLAVCNFSM6AAAAABE4GDGHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGA4DGOBRG4> >> . >> You are receiving this because you were mentioned.Message ID: >> ***@***.***> >> > -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@age.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org