neo4j-contrib / neo4j-apoc-procedures

Awesome Procedures On Cypher for Neo4j - codenamed "apoc"                     If you like it, please ★ above ⇧            
https://neo4j.com/labs/apoc
Apache License 2.0
1.71k stars 493 forks source link

GCP NLP procedures error codes #1869

Open tomasonjo opened 3 years ago

tomasonjo commented 3 years ago

The main issue is that GCP entities API returns "400" bad request response when a user inputs text of an unsupported language to the GCP entities request.

Example data:

CREATE (b:Article{body:"Kam pa kam veseli popotnik, je rekel prijatelj Janez."})

The text is in Slovenian. If you run it through GCP entities API.

MATCH (a:Article)
CALL apoc.nlp.gcp.entities.graph(a, {
  key: $apiKey,
  nodeProperty: "body",
  writeRelationshipType: "ENTITY"
})
YIELD graph AS g
RETURN g;

The error is:

Failed to invoke procedure apoc.nlp.gcp.entities.graph: Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://language.googleapis.com/v1/documents:analyzeEntities?key=

It seems that this is due to unsupported language. Here is a list of supported languages : https://cloud.google.com/natural-language/docs/languages

This can be very bad for the user experience. We could add a better error response like

"Make sure your text language is supported at https://cloud.google.com/natural-language/docs/languages"

or something. Not sure about failing silently.

p.s. AWS works just fine even though it is not a supported language, but they do have a list of errors https://docs.aws.amazon.com/comprehend/latest/dg/API_DetectEntities.html we could try and catch.

Nan-sku commented 2 years ago

I get the same error but the language of the body is in English