Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlik sentiment & text analysis connector error

I am using Qlik sense sentiment analysis connector. whenever I am passing the data .this error is shown.Error: Invalid URI: The Uri string is too long

Capture.PNG

2 Replies
balabhaskarqlik

May be this:

Text not already URL encoded

If you are using text data from a source which is not already URL encoded you will need a script similar to the following to URL encode the text before sending it to the sentiment analyzer.

Sub urlEncode(str)

  let str=replace(str, '%', '%25'); // should be first

  let str=replace(str, '#', '%23');

  let str=replace(str, ' ', '%20');

  let str=replace(str, '$', '%24');

  let str=replace(str, '&', '%26');

  let str=replace(str, '+', '%2B');

  let str=replace(str, ',', '%2C');

  let str=replace(str, '/', '%2F');

  let str=replace(str, '\', '%5C');

  let str=replace(str, ':', '%3A');

  let str=replace(str, ';', '%3B');

  let str=replace(str, '=', '%3D');

  let str=replace(str, '?', '%3F');

  let str=replace(str, '@', '%40');

  let str=replace(str, '[', '%5B');

  let str=replace(str, ']', '%5D');

  let str=replace(str, '>', '%3E');

  let str=replace(str, '<', '%3C');

  let str=replace(str, chr(10), '%0A'); // Line feed.

  let str=replace(str, chr(39), '%27'); // 39 Apostrophe

  call=str;

End sub

LET noRows = NoOfRows('Timeline');

for i=0 to $(noRows)-1

  let text = peek('text', $(i), 'Timeline');

  let textEncoded = text;

  call urlEncode(textEncoded);

  Sentiment:

  LOAD

  '$(text)' as text, // Use this if you want to link your table on the text

  status as sentiment_status,

  score as sentiment_score

  FROM

  [http://localhost:5555/data?ConnectorID=TextAnalyserConnector&table=Sentiment_Sentiment140&text=$(tex...)]

  (html, utf8, embedded labels, table is @1);

next

URL encoding should be done using UTF-8.