## Not run:
# load("./data/yelpChineseRestaurantReviews.rda")
# set.seed(1234)
# documents <- sample(yelpChReviews$text, 1000)
#
# tryCatch({
#
# # Start async topic detection
# operation <- textaDetectTopics(
# documents, # At least 100 docs/sentences
# stopWords = NULL, # Stop word list (optional)
# topicsToExclude = NULL, # Topics to exclude (optional)
# minDocumentsPerWord = NULL, # Threshold to exclude rare topics (optional)
# maxDocumentsPerWord = NULL, # Threshold to exclude ubiquitous topics (optional)
# resultsPollInterval = 0L # Poll interval (in s, default: 30s, use 0L for async)
# )
#
# # Poll the servers until the work completes or until we time out
# resultsPollInterval <- 60L
# resultsTimeout <- 1200L
# startTime <- Sys.time()
# endTime <- startTime + resultsTimeout
#
# while (Sys.time() <= endTime) {
# sleepTime <- startTime + resultsPollInterval - Sys.time()
# if (sleepTime > 0)
# Sys.sleep(sleepTime)
# startTime <- Sys.time()
#
# # Poll for results
# topics <- textaDetectTopicsStatus(operation)
# if (topics$status != "NotStarted" && topics$status != "Running")
# break;
# }
#
# # Class and structure of topics
# class(topics)
# #> [1] "textatopics"
#
# str(topics, max.level = 1)
# #> List of 8
# #> $ status : chr "Succeeded"
# #> $ operationId : chr "30334a3e1e28406a80566bb76ff04884"
# #> $ operationType : chr "topics"
# #> $ documents :'data.frame': 1000 obs. of 2 variables:
# #> $ topics :'data.frame': 71 obs. of 3 variables:
# #> $ topicAssignments:'data.frame': 502 obs. of 3 variables:
# #> $ json : chr "{\"status\":\"Succeeded\",\"createdDateTime\": __truncated__ }
# #> $ request :List of 7
# #> ..- attr(*, "class")= chr "request"
# #> - attr(*, "class")= chr "textatopics"
#
# # Print results
# topics
# #> textatopics [https://westus.api.cognitive.microsoft.com/text/analytics/ __truncated__ ]
# #> status: Succeeded
# #> operationId: 30334a3e1e28406a80566bb76ff04884
# #> operationType: topics
# #> topics (first 20):
# #> ------------------------
# #> keyPhrase score
# #> ---------------- -------
# #> portions 35
# #> noodle soup 30
# #> vegetables 20
# #> tofu 19
# #> garlic 17
# #> Eggplant 15
# #> Pad 15
# #> combo 13
# #> Beef Noodle Soup 13
# #> House 12
# #> entree 12
# #> wontons 12
# #> Pei Wei 12
# #> mongolian beef 11
# #> crab 11
# #> Panda 11
# #> bean 10
# #> dumplings 9
# #> veggies 9
# #> decor 9
# #> ------------------------
#
# }, error = function(err) {
#
# # Print error
# geterrmessage()
#
# })
# ## End(Not run)
Run the code above in your browser using DataLab