Esempio n. 1
0
}
// make this return true if you want the html output from my program
function printOutput()
{
    return false;
}
//**********************************************************************
// Here is where the magic happens
include "Geotagger.php";
// As I make the code more efficient and readable I might change how
// this works, but for now this is up to date.
$text = $argv[1];
// get the text from the command line
$boundingBox = [];
if (count($argv) > 2) {
    $boundingBox["west"] = $argv[2];
    $boundingBox["north"] = $argv[3];
    $boundingBox["east"] = $argv[4];
    $boundingBox["south"] = $argv[5];
}
$tagger = new Geotagger();
$results = $tagger->SimpleRun($text, $boundingBox);
// $results is now an array of search results from Nominatim, sorted in
// order by score from the disambiguator
if ($results) {
    // print out the first result:
    echo "Best Result: " . $results[0]["display_name"] . "\n";
    echo "Coordinates: " . $results[0]["lat"] . "," . $results[0]["lon"] . "\n";
} else {
    echo "No results found.\n";
}
Esempio n. 2
0
$text = $_POST['text'];
$boundingBox = [];
foreach (["west", "north", "east", "south"] as $direction) {
    if ($_POST[$direction]) {
        $boundingBox[$direction] = $_POST[$direction];
    }
}
if (count($boundingBox) < 4) {
    if ($boundingBox) {
        echo "Error: not all arguments specified for bounding box, so ignoring bounds";
    }
    $boundingBox = [];
}
include "Geotagger.php";
function debugMode()
{
    return true;
}
function debugPrint($mailMsg)
{
    echo "<br>" . $mailMsg . "<br>";
}
function printOutput()
{
    return true;
}
set_time_limit(0);
$tagger = new Geotagger();
echo "Input text: " . $text . "<br><br>";
$tagger->run($text, $boundingBox);
$tagger->printTimes();
Esempio n. 3
0
include "Geotagger.php";
if (count($argv) != 3) {
    echo "Error: wrong number of command line arguments.";
    exit(1);
}
$inputFileName = $argv[1];
$outputFileName = $argv[2];
$inputFile = fopen($inputFileName, "r");
$outputFile = fopen($outputFileName, "w");
fwrite($outputFile, "id\ttype\tDisambiguator\tTermType\tActualLat\tActualLon\t");
fwrite($outputFile, "ParserTime\tNominatimTime\tDisambiguationTime\t");
fwrite($outputFile, "PhraseCount\tBestCalculatedLat\tBestCalculatedLon\t");
fwrite($outputFile, "DistanceToResult1\tDistanceToResult2\tDistanceToResult3\tDistanceToResult4\tDistanceToResult5\t");
fwrite($outputFile, "ScoreOfResult1\tScoreOfResult2\tScoreOfResult3\tScoreOfResult4\tScoreOfResult5\n");
while (!feof($inputFile)) {
    $tagger = new Geotagger();
    $line = str_replace("\r", "", str_replace("\n", "", fgets($inputFile)));
    if (strlen($line) < 1) {
        continue;
    }
    $lineSplit = explode("\t", $line);
    if (count($lineSplit) != 5) {
        echo "Error: input file should have 5 tab-delimited columns. Found a line with " . count($lineSplit) . "\n";
        echo "Offending line: " . $line;
        exit(2);
    }
    $id = $lineSplit[0];
    $text = $lineSplit[1];
    $type = $lineSplit[2];
    $realLat = $lineSplit[3];
    $realLon = $lineSplit[4];