function extract($module_id, $text_list, $batch_size = Config::DEFAULT_BATCH_SIZE, $sleep_if_throttled = true) { HandleErrors::check_batch_limits($text_list, $batch_size); $url = $this->endpoint . $module_id . '/extract/'; $res = array(); $headers = array(); $batches = array_chunk($text_list, $batch_size); foreach ($batches as $batch) { $data = array('text_list' => $batch); list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); $headers[] = $header; $res = array_merge($res, $response['result']); } return new MonkeyLearnResponse($res, $headers); }
function classify($module_id, $sample_list, $sandbox = false, $batch_size = Config::DEFAULT_BATCH_SIZE, $sleep_if_throttled = true) { HandleErrors::check_batch_limits($sample_list, $batch_size); $url = $this->endpoint . $module_id . '/classify/'; if ($sandbox) { $url .= '?sandbox=1'; } $res = array(); $headers = array(); $batches = array_chunk($sample_list, $batch_size); foreach ($batches as $batch) { if (is_array($batch[0])) { $data = array('sample_list' => $batch); } else { $data = array('text_list' => $batch); } list($response, $header) = $this->make_request($url, 'POST', $data, $sleep_if_throttled); $headers[] = $header; $res = array_merge($res, $response['result']); } return new MonkeyLearnResponse($res, $headers); }