Ejemplo n.º 1
0
function createCSVFile($results)
{
    $csvPath = SettingsStorage::settings()["csv_file_locations"];
    $rand = Utils::generateRandomString(10) . '.csv';
    $results->asCSV(FileStorage::getPath($rand, $csvPath));
    return $rand;
}
Ejemplo n.º 2
0
 /**
  * MammalClassifier constructor.
  * @param null $settings A settings object to run the algorithm
  * @param bool $scientistDataset Switches between running on live data, or scientist data
  */
 public function __construct($settings = null, $scientistDataset = false)
 {
     $this->result = null;
     $this->imageId = null;
     try {
         $this->db = new ClassificationQuery();
     } catch (PDOException $exception) {
         trigger_error("Failure to create a database connection." . " Possibly database settings provided are wrong", E_USER_WARNING);
     }
     if (!$settings) {
         $settings = SettingsStorage::settings();
     }
     $this->scientistDataset = $scientistDataset;
     $this->CONSECUTIVE_EXPECTED = Utils::getValue($settings['consecutive_expected'], 8);
     $this->VOTES_BEFORE_CONSENSUS = Utils::getValue($settings['votes_before_consensus'], 15);
     $this->UNREASONABLE_NUMBER_OF_SPECIES_IN_IMAGE = Utils::getValue($settings['unreasonable_number_of_species_in_image'], 5);
     $this->EVENNESS_THRESHOLD_COUNT = Utils::getValue($settings['evenness_threshold_count'], 0.6899999999999999);
     $this->EVENNESS_THRESHOLD_SPECIES = Utils::getValue($settings['evenness_threshold_species'], 0.7);
     $this->NUMBER_OF_NOTHING_HERE_BEFORE_CLASSIFY = Utils::getValue($settings["number_of_nothing_here_before_classify"], 5);
 }
Ejemplo n.º 3
0
<?php

include '../../core.php';
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
if (isset($_REQUEST['action'])) {
    $apiParam = $_REQUEST['action'];
    try {
        if ($apiParam === 'get') {
            $settings = SettingsStorage::settings();
            echo json_encode($settings);
        } else {
            if ($apiParam === 'store') {
                if (isset($_POST['settings'])) {
                    $settingsChange = json_decode($_POST['settings'], true);
                    if (is_null($settingsChange)) {
                        error('Invalid settings provided, couldn\'t parse the JSON');
                    } else {
                        SettingsStorage::set($settingsChange);
                        echo json_encode(["success" => true]);
                    }
                } else {
                    error('You need to set the post field "settings" before storing data');
                }
            } else {
                error("Invalid action");
            }
        }
    } catch (PDOException $e) {