Пример #1
0
//if the query is a sequence
if ($sequence) {
    $lhs = $_GET['lhs'];
    $rhs = explode(' ', $_GET['rhs']);
    $distance = $_GET['distance'];
    $toHighlight = $rhs;
    $pos_list = array();
    if (strlen($_GET['rhs']) > 0) {
        $rhs_ids = "";
        foreach ($rhs as $rh) {
            $rhs_ids += " " . getWordID($rh);
        }
        if ($lhs != "anything") {
            $pos_list = listFormat($lhs);
        }
        $rhs_ids = numberList($rhs_ids);
        if ($distance == 'sentence') {
            if ($lhs == "anything") {
                $query = "SELECT sentence_id FROM sentence_xref_word WHERE word_id in (" . $rhs_ids . "); ";
                $sentence_ids = mysql_($query);
            } else {
                $query = "SELECT sentence_id, word as lhs FROM word, sentence_xref_word WHERE word_id in (" . $rhs_ids . ") AND lhs.id = sentence_xref_word.word_id AND word.pos in (" . $pos_list . ");";
                $sentence_ids = mysql_query($query);
            }
        } else {
            if ($lhs == "anything") {
                $query = "SELECT s.sentence_id, s.word_id as lhsid, s.position as lhspos from sentence_xref_word as s, (SELECT sentence_id, position from sentence_xref_word WHERE word_id in (" . $rhs_ids . ")) AS positions WHERE\n\t\t\t\t\t\t\ts.sentence_id = positions.sentence_id AND\n\t\t\t\t\t\t\t(positions.position - s.position)*(positions.position - s.position) <=" . pow(intval($distance), 2) . ";";
                $sentence_ids = mysql_query($query);
            } else {
                $query = "SELECT s.sentence_id, s.word_id as lhsid, s.position as lhspos FROM \n\t\t\t\t\t\t(SELECT * from sentence_xref_word, word as lh WHERE lh.pos in  (" . $pos_list . ") ) as s,\n\t\t\t\t\t\t(SELECT sentence_id, position from sentence_xref_word WHERE word_id in (" . $rhs_ids . ")) AS positions\n\t\t\t\t\t\tWHERE  s.sentence_id = positions.sentence_id AND\n\t\t\t\t\t\t(positions.position - s.position)*(positions.position - s.position) <=" . pow(intval($distance), 2) . ";";
                $sentence_ids = mysql_query($query);
Пример #2
0
<?php

include "dbsetup.php";
include "util.php";
$withinSentence = $_GET['within'] == 'sentence';
$withinNarrative = $_GET['within'] == 'narrative';
$within = numberList($_GET['results']);
//paging
$page = $_GET['page'];
$pageLength = $_GET['pagelength'];
$gov = str_replace('\\"', '"', $_GET['gov']);
$dep = str_replace('\\"', '"', $_GET['dep']);
$relationship = str_replace('\\"', '"', $_GET['relation']);
$count = 0;
$sentence_dependencies = array();
$t1 = time();
$govs = wordIDList($gov);
$deps = wordIDList($dep);
$rels = relationshipIDList($relationship);
$dependency_ids = getDependencyIDs($govs, $deps, $rels, $withinNarrative, $withinSentence, $within, false);
$time = time() - $t1;
//echo '"Time to fetch dependencies: "'.$time.' seconds"';
$count = mysql_num_rows($dependency_ids);
//print out search results
if ($count > 0) {
    echo '<h3 class="num-results">' . $count;
    if ($count == 1) {
        echo ' result';
    } else {
        if ($count < $pageLength) {
            echo ' results';