Beispiel #1
0
/**
Converts a list of words to a list of word ID's
*/
function wordIDList($words)
{
    if (strlen($words) > 0) {
        $exploded = explode(' ', trim($words));
        if (strpos($words, ',')) {
            $exploded = explode(',', trim($words));
        }
        $listformat = "";
        $i = 0;
        foreach ($exploded as $word) {
            if ($i == 0) {
                $listformat = $listformat . getWordID($word);
            } else {
                $listformat = $listformat . ", " . getWordID($word) . " ";
            }
            $i += 1;
        }
        return $listformat;
    } else {
        return "";
    }
}
Beispiel #2
0
$withinNarrative = $_GET['within'] == 'narrative';
$within = numberList($_GET['results']);
//paging
$page = $_GET['page'];
$pageLength = $_GET['pagelength'];
//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") {