PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Dennis de Swart   PHP Stanford Core NLP Adapter   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Stanford Core NLP Adapter
Natural language processing using Stanford server
Author: By
Last change: Increased execution time, improved error messages, updated README
Date: 6 years ago
Size: 1,675 bytes


Class file image Download

 * Important notes:
 * - To use the online API : set ONLINE_API to TRUE
 * - To use Java CoreNLP : set ONLINE_API to FALSE
 * - ONLINE_API is set to FALSE by default. You can change this setting in "bootstrap.php"
 * - OpenIE annotator is only available on the Java version

require_once __DIR__.'/bootstrap.php'; // bootstrap also contains the config
 * Demo usage
    // instantiate the class
$coreNLP = new CorenlpAdapter();

$text1 = 'I will meet Mary in New York at 10pm';

// Second text
$text2 = 'The Golden Gate Bridge was designed by Joseph Strauss.';
 * Display result
    // this makes it easier to read
echo '<pre>';

// show complete output
headerText('The "Server Memory Object" (below) contains all the server output');

// first text tree
headerText('FIRST TEXT: Part-Of-Speech tree');

// second text tree
headerText('SECOND TEXT: Part-Of-Speech tree');
// get IDs for a tree
headerText('EVERY TREE HAS UNIQUE IDs: this shows the Word-tree-IDs for the second tree');

// this is just a helper function for a nice header
function headerText($header){
'<br />***'.str_repeat('*', strlen($header)).'***<br />';
'** '.$header.' **<br />';
'***'.str_repeat('*', strlen($header)).'***<br /><br />';