while ($row = mysql_fetch_array($d)) {
        if (!in_array($row['relationship'], $excluded)) {
            $dependency = array();
            if (!array_key_exists($row['relationship'], $dependencies)) {
                $dependencies[$row['relationship']] = array();
            }
            $dependency['gov_index'] = $row['gov_index'];
            $dependency['gov'] = $row['gov'];
            $dependency['dep_index'] = $row['dep_index'];
            $dependency['dep'] = $row['dep'];
            array_push($dependencies[$row['relationship']], $dependency);
        }
    }
    return $dependencies;
}
//if used as a script
if ($_GET['random'] == "on") {
    include 'dbsetup.php';
    include 'util.php';
    $sentenceInfo = getRandomSentence();
    $dependencies = getDependencyIDs('', '', '', false, true, $sentenceInfo['id'], false);
    while (mysql_num_rows($dependencies) == 0 || count(categorizeDependencies) == 0) {
        $sentenceInfo = getRandomSentence();
        $dependencies = getDependencyIDs('', '', '', false, true, $sentenceInfo['id'], false);
    }
    $data = array();
    $sentence = $sentenceInfo['sentence'];
    $data['randomSentence'] = $sentence;
    $data['randomDependencies'] = categorizeDependencies($dependencies);
    echo json_encode($data);
}
Beispiel #2
0
    }
} else {
    if ($grammatical) {
        $gov = str_replace('\\"', '"', $_GET['gov']);
        $dep = str_replace('\\"', '"', $_GET['dep']);
        $relationship = str_replace('\\"', '"', $_GET['relation']);
        $log = fopen("/projects/wordseer/logs/query.log", "a");
        $data = 'gov=' . $gov . ' dep=' . $dep . ' relation=' . $relation . ' ';
        fwrite($log, $data);
        fclose($log);
        $count = 0;
        $sentence_dependencies = array();
        $govs = wordIDList($gov);
        $deps = wordIDList($dep);
        $rels = relationshipIDList($relationship);
        $dependency_ids = getDependencyIDs($govs, $deps, $rels, $withinNarrative, $withinSentence, $within, true);
        $count = mysql_num_rows($dependency_ids);
        // print out graph data in JSON format
        if ($count > 0) {
            //printStatistics(old_getStatistics($dependency_ids));
            printStatistics(getStatistics($deps, $govs, $rels));
            mysql_data_seek($dependency_ids, 0);
        }
        //print out search results
        if ($count > 0) {
            echo '<h3 class="num-results">' . $count;
            if ($count == 1) {
                echo ' result';
            } else {
                if ($count < $pageLength) {
                    echo ' results';