Example #1
0
  <?php 
for ($i = 0; $i < count($results); $i++) {
    $doc = $documents[$i];
    $meta = $doc->metadata;
    $matches = indri_documentMatches($results[$i]->document, $annotatedResults->getAnnotations(), $nodes);
    $snippet = indri_buildsnippet($doc->text, $matches, $doc->positions, 250);
    $title = substr($snippet, 0, 50) . "...";
    $title = isset($meta["docno"]) ? $meta["docno"] : $title;
    $title = isset($meta["title"]) ? $meta["title"] : $title;
    $prefix = "";
    if (isset($meta["docno"]) and isset($meta["title"])) {
        $prefix = $meta["docno"] . ": ";
    }
    $beginlink = isset($meta["url"]) ? "<a href=\"" . $meta["url"] . "\">" : "";
    $endlink = isset($meta["url"]) ? "</a>" : "";
    $cachedlink = indri_buildlink($_REQUEST, $results[$i]->document);
    $nextlink = indri_nextlink($_REQUEST, $startdoc + 10);
    ?>
     <div id="result">
        <h2><?php 
    echo $prefix . $beginlink . $title . $endlink;
    ?>
</h2>
        <div id="snippet">
          <?php 
    echo $snippet;
    ?>
        </div>
        [ <a href="<?php 
    echo $cachedlink;
    ?>
Example #2
0
    function printResult($entry, $primary, $annotations, $nodes, $indri_param)
    {
        $doc = $entry[1];
        $meta = $doc->metadata;
        $result = $entry[2];
        $range = new position($result->begin, $result->end);
        $matches = indri_documentMatches($result->document, $annotations, $nodes, $range);
        $snippet = indri_buildsnippet($doc->text, $matches, $doc->positions, $indri_param['snippet_length'], $range);
        $title = substr($snippet, 0, 50) . "...";
        $title = isset($meta["docno"]) ? $meta["docno"] : $title;
        $title = isset($meta["path"]) ? substr($meta["path"], strrpos($meta["path"], '/') + 1, strlen($meta["path"])) : $title;
        $title = isset($meta["url"]) ? $meta["url"] : $title;
        $title = isset($meta["title"]) && strlen($meta["title"]) > 0 ? $meta["title"] : $title;
        $title = preg_replace("/^http:\\/\\//", "", $title);
        $prefix = "";
        $beginlink = isset($meta["url"]) ? "<a href=\"" . $meta["url"] . "\">" : "";
        $endlink = isset($meta["url"]) ? "</a>" : "";
        $cachedlink = indri_buildlink($_REQUEST, $result->document);
        if ($primary === true) {
            ?>
    <div id="result">
       <div id="resulttitle">
          <?php 
            echo $prefix . $beginlink . $title . $endlink;
            ?>
       </div>
       <div id="snippet">
          <?php 
            echo $snippet;
            ?>
       </div>
       <span id="url">
          <?php 
            echo preg_replace("/^http:\\/\\//", "", $meta["url"]);
            ?>
       </span>
       <span id="cachedlink">
       <a href="<?php 
            echo $cachedlink;
            ?>
">Cached</a>
       </span>
       <!-- [ Score = <?php 
            echo number_format(exp($result->score), 7);
            ?>
 ] -->
<?php 
            if ($this->count > 1) {
                $end = strlen($this->base[0]) - strlen(strrchr($this->base[0], "/")) + 1;
                if ($end > 7) {
                    $base_prefix = substr($this->base[0], 0, $end);
                } else {
                    // don't reduce to http://
                    $base_prefix = $this->base[0];
                }
                $clean_base = preg_replace("/^http:\\/\\//", "", $base_prefix);
                ?>
   - 
        <span id="morelink">
        <a href="query.php?query=<?php 
                echo indri_escapeurl($_REQUEST['query']);
                ?>
&prefix=<?php 
                echo indri_escapeurl($base_prefix);
                ?>
">More from <?php 
                echo $clean_base;
                ?>
...</a>
       </span>
<?php 
            }
            ?>
   </div>
   <?php 
        } else {
            $end = strlen($this->base[0]) - strlen(strrchr($this->base[0], "/")) + 1;
            if ($end > 7) {
                $base_prefix = substr($this->base[0], 0, $end);
            } else {
                // don't reduce to http://
                $base_prefix = $this->base[0];
            }
            $clean_base = preg_replace("/^http:\\/\\//", "", $base_prefix);
            ?>
    <div id="indentedresult">
       <div id="indresulttitle">
       <?php 
            echo $prefix . $beginlink . $title . $endlink;
            ?>
       </div>
       <div id="snippet">
          <?php 
            echo $snippet;
            ?>
       </div>
       <span id="url">
          <?php 
            echo preg_replace("/^http:\\/\\//", "", $meta["url"]);
            ?>
       </span>
       <span id="cachedlink">
       <a href="<?php 
            echo $cachedlink;
            ?>
">Cached</a>
       </span>
       <!-- [ Score = <?php 
            echo number_format(exp($result->score), 7);
            ?>
 ] -->
       - <span id="morelink">
       <a href="query.php?query=<?php 
            echo indri_escapeurl($_REQUEST['query']);
            ?>
&prefix=<?php 
            echo indri_escapeurl($base_prefix);
            ?>
">More from <?php 
            echo $clean_base;
            ?>
...</a>
      </span>
   </div>
   <?php 
        }
    }