<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Text Analytics Sentiment API in R - Twitter in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/212100#M6697</link>
    <description>&lt;P&gt;not specifically related to your problem, but you can use | to seperate multiple objects in gsub, like so:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dataframe$text &amp;lt;- gsub("—|&amp;amp;", " ", dataframe$text)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;which might make your code a little more concise - there's some great documentation on &lt;A href="https://www.rdocumentation.org/packages/base/versions/3.4.1/topics/grep" target="_blank"&gt;the grep function&lt;/A&gt;&amp;nbsp;and &lt;A href="https://www.rdocumentation.org/packages/base/versions/3.4.1/topics/regex" target="_self"&gt;how R handles regular expressions&lt;/A&gt; available online :).&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 13:34:32 GMT</pubDate>
    <dc:creator>BeardyGeorge</dc:creator>
    <dc:date>2017-07-14T13:34:32Z</dc:date>
    <item>
      <title>Text Analytics Sentiment API in R - Twitter</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/187694#M5983</link>
      <description>&lt;P&gt;I am using R to stream tweets from Twitter&lt;BR /&gt;After doing some cleaning on the tweets, ie. eliminating link, duplicated links, etc, I convert it to seriallsed&amp;nbsp;JSON format&lt;BR /&gt;&lt;BR /&gt;I am trying to call the text analytics (sentiment) API but always return 400 (bad service)&lt;BR /&gt;But when I limit the number of tweets to very small amount (10 tweets), somehow it works&lt;BR /&gt;&lt;BR /&gt;Any suggestion on how to solve this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GalaxyS8 &amp;lt;- searchTwitter("Galaxy S8", n=10000, lang='en')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GalaxyS8_tweets_df = do.call("rbind", lapply(GalaxyS8, as.data.frame))&lt;BR /&gt;GalaxyS8_tweets_df = subset(GalaxyS8_tweets, select = c(text))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;textScrubber &amp;lt;- function(dataframe)&lt;BR /&gt;{dataframe$text &amp;lt;- gsub("—", " ", dataframe$text)&lt;BR /&gt;dataframe$text &amp;lt;- gsub("&amp;amp;", " ", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("[[:punct:]]", "", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("(RT|via)((?:\\b\\W*@\\w+)+)", " ", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("@\\w+", "", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("http\\w+", "", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("[ \t]{2,}", "", dataframe$text)&lt;BR /&gt;dataframe$text = gsub("^\\s+|\\s+$", "", dataframe$text)&lt;BR /&gt;dataframe["DuplicateFlag"] = duplicated(dataframe$text)&lt;BR /&gt;dataframe = subset(dataframe, dataframe$DuplicateFlag=="FALSE")&lt;BR /&gt;dataframe = subset(dataframe, select = -c(DuplicateFlag))&lt;/P&gt;&lt;P&gt;return(dataframe)&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;GalaxyS8_tweets_df &amp;lt;- textScrubber(GalaxyS8_tweets_df)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GalaxyS8_tweets_df["language"] = "en"&lt;BR /&gt;GalaxyS8_tweets_df["id"] = seq.int(nrow(GalaxyS8_tweets_df))&lt;BR /&gt;request_body_GalaxyS8 = GalaxyS8_tweets_df[c(2,3,1)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;request_body_json_GalaxyS8 = toJSON(list(documents = request_body_GalaxyS8))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;result_GalaxyS8 &amp;lt;- POST("&lt;A href="https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment" target="_blank"&gt;https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment&lt;/A&gt;",&lt;BR /&gt;body = request_body_json_GalaxyS8,&lt;BR /&gt;add_headers(.headers = c('Content-Type'='application/json','Ocp-Apim-Subscription-Key'='your-api-key')))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 03:40:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/187694#M5983</guid>
      <dc:creator>reinaldogani</dc:creator>
      <dc:date>2017-06-05T03:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Text Analytics Sentiment API in R - Twitter</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/189344#M6018</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/32105"&gt;@reinaldogani&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned in &lt;A href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/quick-start" target="_blank"&gt;document&lt;/A&gt;, it has size limitation for input JSON when calling Text Analytics Sentiment API:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;The maximum size of a single document that can be submitted is 10 KB, and the total maximum size of submitted input is 1 MB. No more than 1,000 documents may be submitted in one call. Rate limiting exists at a rate of 100 calls per minute - we therefore recommend that you submit large quantities of documents in a single call.&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 03:04:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/189344#M6018</guid>
      <dc:creator>v-sihou-msft</dc:creator>
      <dc:date>2017-06-07T03:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Text Analytics Sentiment API in R - Twitter</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/212100#M6697</link>
      <description>&lt;P&gt;not specifically related to your problem, but you can use | to seperate multiple objects in gsub, like so:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dataframe$text &amp;lt;- gsub("—|&amp;amp;", " ", dataframe$text)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;which might make your code a little more concise - there's some great documentation on &lt;A href="https://www.rdocumentation.org/packages/base/versions/3.4.1/topics/grep" target="_blank"&gt;the grep function&lt;/A&gt;&amp;nbsp;and &lt;A href="https://www.rdocumentation.org/packages/base/versions/3.4.1/topics/regex" target="_self"&gt;how R handles regular expressions&lt;/A&gt; available online :).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 13:34:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Text-Analytics-Sentiment-API-in-R-Twitter/m-p/212100#M6697</guid>
      <dc:creator>BeardyGeorge</dc:creator>
      <dc:date>2017-07-14T13:34:32Z</dc:date>
    </item>
  </channel>
</rss>

