-1

How do i write a statement for similarity cosine using ga.nlp.ml.similarity.cosine for node News:

CREATE (n:News)
SET n.text = "Scores of people were already lying dead or injured inside a crowded Orlando nightclub,
and the police had spent hours trying to connect with the gunman and end the situation without further violence.
But when Omar Mateen threatened to set off explosives, the police decided to act, and pushed their way through a
wall to end the bloody standoff.";

What is the proper syntax?

Neuron
  • 5,141
  • 5
  • 38
  • 59
User502
  • 15
  • 1
  • 2
    you need at least two nodes/news to compute similarity between objects. Could you refine your requirements? – Alessandro Negro Nov 09 '17 at 11:02
  • yes i know that it requires 2 nodes. i have 2 nodes but i need to know the proper syntax with an example. Because when am trying to run it i am facing with some errors like : "Type mismatch: expected List but was Boolean (line 3, column 35 (offset: 72)) "CALL ga.nlp.ml.similarity.cosine(n:News,5,n1.people,n1.HAS_TAG) YIELD result return result"" I need some examples because all the reference for similarity cosine is outdated . No new uploaded details, so i require an example to continue it. – User502 Nov 10 '17 at 05:03
  • Type mismatch: expected List but was Map (line 3, column 34 (offset: 71)) "CALL ga.nlp.ml.similarity.cosine({a:n.text,n:n.id},5,n.people,n.HAS_TAG) YIELD result return result" – User502 Nov 10 '17 at 05:23

2 Answers2

4

This is the call structure:

CALL ga.nlp.ml.similarity.cosine([<nodes>],depth,Query,Relationship type)
//nodes->The list of annotated nodes for which it will compute the distances
//depth->Integer. if 0, it will not use Concept Net 5 imported data for the distance computing. If greater than 0 it will consider concepts during computation, the value will define how much in general it should go.
//Query->String. It is the query that will be used to compute the tags vector, some are already defined, so this cold be null
//Relationship Type->String. The name to assign to the Relationship created between AnnotatedText nodes.

This is an example:

MATCH (a:AnnotatedText) 
with collect(a) as list
CALL ga.nlp.ml.similarity.cosine(list, 0, null, "SIMILARITY") YIELD result
return result
0
     CALL ga.nlp.ml.similarity.cosine([<nodes>],depth,Query,Relationship type)
//nodes->Must be annotated nodes
//depth->integer data
//Query->String
//Relationship Type->String
User502
  • 15
  • 1