Esempio n. 1
0
 public function writeCoocFile($conference_id, $cut_off, $file_path, $api, $normalizeStrings = false)
 {
     $query = "SELECT DISTINCT concepts.contentID, concepts.conceptName, concepts.conceptAPI\n                            FROM concepts, content\n                            WHERE concepts.contentID = content.contentID";
     $query .= $this->createConferenceIDString($conference_id);
     if ($api != null) {
         $query .= $this->createApiString($api);
     }
     $result = mysql_query($query);
     if ($result == false) {
         throw new \Exception("Query failed! " . mysql_error());
     }
     $topic_array = array();
     while ($row = mysql_fetch_assoc($result)) {
         $topic_array[$row['contentID']][] = $row['conceptName'];
     }
     $file = library\Toolkit::openOrCreateFile($file_path);
     foreach ($topic_array as $id1 => $terms1) {
         if ($normalizeStrings) {
             $terms1 = array_map('headstart\\library\\Toolkit::normalizeString', $terms1);
         }
         foreach ($topic_array as $id2 => $terms2) {
             if ($id1 == $id2) {
                 continue;
             }
             if ($normalizeStrings) {
                 $terms2 = array_map('headstart\\library\\Toolkit::normalizeString', $terms2);
             }
             $terms1_unique = array_unique($terms1);
             $terms2_unique = array_unique($terms2);
             $out = array($id1, $id2, count(array_intersect($terms1_unique, $terms2_unique)));
             fputcsv($file, $out);
         }
     }
     fclose($file);
 }
Esempio n. 2
0
 public function performCalculationAndWriteOutputToFile($working_dir)
 {
     $ini = $this->ini_array["calculation"];
     $output = $this->ini_array["output"];
     $base_dir = $this->ini_array["general"]["preprocessing_dir"];
     $binary = $ini["binary"];
     $script = $base_dir . $ini["script"];
     $path = '"' . $binary . '" ' . $script . ' "' . $working_dir . '" "' . $output["cooc"] . '" "' . $output["metadata"] . '" "' . $output["output_scaling_clustering"] . '" "' . $ini["mode"] . '"';
     library\Toolkit::info($path);
     exec($path);
 }
Esempio n. 3
0
 protected function writeToFile($file_path, $result)
 {
     $file = library\Toolkit::openOrCreateFile($file_path);
     fputcsv($file, array('id', 'content'));
     while ($row = mysql_fetch_assoc($result)) {
         $merged_string = $row['title'] . " " . $row['abstract'];
         $merged_array = array($row['contentID'], $merged_string);
         fputcsv($file, $merged_array);
     }
     fclose($file);
 }
 public function getConferenceBookmarks($conference_id)
 {
     $query = sprintf("SELECT bookmarking.bookmarkingID, bookmarking.userID, bookmarking.contentID \n            FROM bookmarking, content \n            WHERE (bookmarking.contentID=content.contentID) AND (content.contentType <> %s)", "\"no-paper\"");
     $query .= $this->createConferenceIDString($conference_id);
     $result = mysql_query($query);
     if (!$result) {
         $message = 'Invalid Query: ' . mysql_error() . "\n";
         $message .= 'Full query: ' . $query;
         die($message);
     }
     $bookmark_array = array();
     while ($row = mysql_fetch_assoc($result)) {
         library\Toolkit::addOrInitiatlizeArrayKeyNumerical($bookmark_array, $row['contentID']);
     }
     $return_array = array();
     foreach ($bookmark_array as $id => $num) {
         $return_array[] = array("id" => $id, "num" => $num);
     }
     return $return_array;
 }
Esempio n. 5
0
<?php

header('Content-type: application/json');
require dirname(__FILE__) . '/../classes/headstart/personalization/DBConnectionPersonalization.php';
require_once dirname(__FILE__) . '/../classes/headstart/library/CommUtils.php';
require_once dirname(__FILE__) . '/../classes/headstart/library/toolkit.php';
use headstart\library;
$INI_DIR = dirname(__FILE__) . "/../preprocessing/conf/";
$ini_array = library\Toolkit::loadIni($INI_DIR);
$user_id = library\CommUtils::getParameter($_GET, "user_id");
$conference_id = library\CommUtils::getParameter($_GET, "content_id");
$connection = new headstart\personalization\DBConnectionPersonalization($ini_array);
$connection->establishConnection();
$bookmarking_data = $connection->removePersonalBookmark($user_id, $conference_id);
$jsonData = json_encode($bookmarking_data);
library\CommUtils::echoOrCallback($jsonData, $_GET);
Esempio n. 6
0
 protected function getBookmarks($conference_id, $cut_off)
 {
     $query = sprintf("SELECT bookmarking.bookmarkingID, bookmarking.userID, bookmarking.contentID \n            FROM bookmarking, presentation, eventsession, content \n            WHERE (bookmarking.contentID=presentation.contentID) AND (bookmarking.contentID = content.contentID)\n                AND (presentation.eventSessionID=eventsession.eventSessionID) AND (content.contentType <> %s)", "\"no-paper\"");
     $query .= $this->createConferenceIDString($conference_id);
     $result = mysql_query($query);
     if (!$result) {
         $message = 'Invalid Query: ' . mysql_error() . "\n";
         $message .= 'Full query: ' . $query;
         die($message);
     }
     $bookmark_array = array();
     while ($row = mysql_fetch_assoc($result)) {
         $bookmark_array[] = $row;
         library\Toolkit::addOrInitiatlizeArrayKeyNumerical($this->numBookmarks, $row['contentID']);
     }
     if (count($this->numBookmarks) > 0) {
         $this->numBookmarks = array_filter($this->numBookmarks, function ($item) use($cut_off) {
             return $item >= $cut_off;
         });
     }
     $library_array = array();
     foreach ($bookmark_array as $line) {
         if (!isset($library_array[$line['userID']])) {
             $library_array[$line['userID']] = array($line['contentID']);
         } else {
             $library_array[$line['userID']][] = $line['contentID'];
         }
     }
     return $library_array;
 }
Esempio n. 7
0
 private function getFullResponseZemanta($text, $uri, $dir)
 {
     $ch = $this->createNewCurlHandleZemanta($text, "rdfxml");
     $response = curl_exec($ch);
     curl_close($ch);
     library\Toolkit::putContentsToFile($dir . $uri . ".rdf", $response);
 }