<?php /** * @author W-Shadow * @url http://w-shadow.com/ * @copyright 2008 */ error_reporting(E_ALL); require_once 'includes/summarizer.php'; require_once 'includes/html_functions.php'; $summarizer = new Summarizer(); if (!empty($_POST['text'])) { //echo '<pre>'; $text = $_POST['text']; //replace some Unicode characters with ASCII $text = normalizeHtml($text); //generate the summary with default parameters $rez = $summarizer->summary($text); //print_r($rez); //$rez is an array of sentences. Turn it into contiguous text by using implode(). $summary = implode(' ', $rez); //echo '</pre>'; } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div align='center'> <form method='POST' action='test_summarizer.php'> <h3>Text Summarizer</h3> <textarea name='text' cols='50' rows='10'><?php echo !empty($_POST['text']) ? htmlspecialchars($_POST['text']) : ''; ?>
public function __construct($show){ $WebServer = $GLOBALS['WebServer']; $MythRokuDir = $GLOBALS['MythRokuDir']; $RokuDisplayType = $GLOBALS['RokuDisplayType']; $BitRate = $GLOBALS['BitRate']; $this->media = new media( array( 'streamFormat'=>new streamFormat(array('content'=>'mp4')) , 'streamQuality'=>new streamQuality(array('content'=>$RokuDisplayType)) , 'streamBitrate'=>new streamBitrate(array('content'=>$BitRate)) , 'streamUrl'=>new streamUrl() ) ); if(1==0){ //dummy to make editing easier - RSH }elseif(is_a($show,'Weather')){ //handles Weather current conditions, forecast items, and alerts schemae $ShowLength = $show->Delay; $title = "$show->Location"; $title .= empty($show->Temperature) ? "" : ", $show->Temperature"; $title .= empty($show->Description) ? "" : ", $show->Description"; $subtitle = empty($show->Message) ? $show->Conditions : $show->Message; $subtitle .= empty($show->WindDirection) ? "" : ", $show->WindDirection"; $subtitle .= empty($show->WindSpeed) ? "" : "@$show->WindSpeed"; $subtitle .= empty($show->WindGust) ? "" : ", G$show->WindGust"; $subtitle .= empty($show->Humidity) ? "" : ", hum $show->Humidity"; $subtitle .= empty($show->Clouds) ? "" : ", vis $show->Clouds mi."; $genre = empty($show->Until) ? $show->Temperature : $show->Until; $synopsis = "$subtitle $show->Source"; $this->title = new title(array('content'=>$title)); $this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType)); $this->subtitle = new subtitle(array('content'=>$subtitle)); $this->addToAttributes('sdImg', "$show->Icon"); $this->addToAttributes('hdImg', "$show->Icon"); $this->contentId = new contentId(array('content'=>$show->Location)); //$this->contentType = new contentType(array('content'=>'TV')); //$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required $this->synopsis = new synopsis(array('content'=>$synopsis)); $this->genres = new genres(array('content'=>$genre)); $this->runtime = new runtime(array('content'=>$ShowLength)); $this->date = new date(array('content'=>$show->AsOf)); $this->tvormov = new tvormov(array('content'=>'weather')); }elseif(is_a($show,'Program')){ /// MythTV Program schema $ShowLength = convert_datetime($show->EndTime) - convert_datetime($show->StartTime); if($show->isScheduled){ $imgUrl = "$WebServer/$MythRokuDir/images/oval_green.png"; } elseif($show->isRecording){ $imgUrl = "$WebServer/$MythRokuDir/images/oval_blue.png"; $show->Category = 'NOW RECORDING!'; } elseif($show->hasJob) { $imgUrl = "$WebServer/$MythRokuDir/images/oval_orange.png"; $show->Category = 'NOW PROCESSING A JOB!'; } elseif($show->isConflict) { $imgUrl = "$WebServer/$MythRokuDir/images/oval_red.png"; $show->Category = 'SCHEDULE CONFLICT!'; } else { $imgUrl = "$WebServer/$MythRokuDir/images/oval_grey.png"; } $this->title = new title(array('content'=>normalizeHtml($show->Title))); $this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType)); $this->subtitle = new subtitle(array('content'=>normalizeHtml($show->SubTitle))); $this->addToAttributes('sdImg', $imgUrl); $this->addToAttributes('hdImg', $imgUrl); $this->contentId = new contentId(array('content'=>$show->ProgramId)); //$this->contentType = new contentType(array('content'=>'TV')); //$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required $this->synopsis = new synopsis(array('content'=>normalizeHtml($show->Description))); $this->genres = new genres(array('content'=>normalizeHtml($show->Category))); $this->runtime = new runtime(array('content'=>$ShowLength)); if(!is_a($show, 'ProgramTpl)')) $this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->StartTime)))); else $this->date = new date(array('content'=>$show->StartTime)); $this->tvormov = new tvormov(array('content'=>'upcoming')); }elseif(is_a($show,'Guide')){ //handles Pilots/Premieres schema $ShowLength = convert_datetime($show->endtime) - convert_datetime($show->starttime); $ImgType = ($show->subtitle == 'Pilot' ? "rectangle" : "oval"); if($show->recstatus == -1){ $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_blue.png"; $show->category .= ' (WILL RECORD)'; } elseif($show->recstatus == 10 || $show->recstatus == 7){ //inactive or conflict $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_purple.png"; $show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')'; } elseif($show->last && $show->first){ $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_red.png"; if(!empty($show->recstatus) && $show->recstatus != 10 && $show->recstatus != 7) { $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png"; $show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')'; } else { $show->category .= ' (ONLY CHANCE)'; } } elseif($show->last) { $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_orange.png"; if(!empty($show->recstatus) && $show->recstatus != 10 && $show->recstatus != 7) { $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png"; $show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')'; } else { $show->category .= ' (LAST CHANCE)'; } } else { if(!empty($show->recstatus)) { $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_grey.png"; $show->category .= ' (' . $show->getStatusName( $show->recstatus ) . ')'; } else { $imgUrl = "$WebServer/$MythRokuDir/images/". $ImgType . "_green.png"; } } $this->title = new title(array('content'=>normalizeHtml($show->station.' '.$show->title))); $this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType)); $this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle))); $this->addToAttributes('sdImg', $imgUrl); $this->addToAttributes('hdImg', $imgUrl); $this->contentId = new contentId(array('content'=>$show->programid)); //$this->contentType = new contentType(array('content'=>'TV')); //$this->media->streamUrl->setContent("$streamUrl "); //yes the space is required $this->synopsis = new synopsis(array('content'=>normalizeHtml($show->description))); $this->genres = new genres(array('content'=>normalizeHtml($show->category))); $this->runtime = new runtime(array('content'=>$ShowLength)); $this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->starttime)))); $this->tvormov = new tvormov(array('content'=>'new')); }elseif(is_a($show,'Recorded')){ /// TV from Recorded table $ShowLength = convert_datetime($show->endtime) - convert_datetime($show->starttime); $streamfile = $show->storagegroups->dirname . $show->basename; $parms = array('image'=>$streamfile); $streamUrl = "$WebServer/$MythRokuDir/imageSvc.php?" .http_build_query($parms); $parms = array('preview'=>str_pad($show->chanid, 6, "_", STR_PAD_LEFT).rawurlencode($show->starttime)); $imgUrl = "$WebServer/$MythRokuDir/imageSvc.php?" .http_build_query($parms); $this->title = new title(array('content'=>normalizeHtml($show->title))); $this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType)); $this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle))); $this->addToAttributes('sdImg', $imgUrl); $this->addToAttributes('hdImg', $imgUrl); $this->contentId = new contentId(array('content'=>$show->basename)); $this->contentType = new contentType(array('content'=>'TV')); $this->media->streamUrl->setContent("$streamUrl "); //yes the space is required $this->synopsis = new synopsis(array('content'=>normalizeHtml($show->description))); $this->genres = new genres(array('content'=>normalizeHtml($show->category.' ('.$show->programid.' '.$show->airdate.')'))); $this->runtime = new runtime(array('content'=>$ShowLength)); $this->date = new date(array('content'=>date("F j, Y, g:i a", convert_datetime($show->starttime)))); $this->programid = new programid(array('content'=>$show->programid)); $this->airdate = new airdate(array('content'=>$show->airdate)); $this->tvormov = new tvormov(array('content'=>'tv')); $this->delcommand = new delcommand(array('content'=>"$WebServer/mythroku/mythtv_tv_del.php?basename=$show->basename")); }elseif(is_a($show,'VideoMetadata')){ /// Video from VideoMetadata table $videos = StorageGroup::first( array('conditions' => array('groupname = ?', 'Videos')) ); $streamfile = $videos->dirname . $show->filename; $parms = array('image'=>$streamfile); $streamUrl = "$WebServer/$MythRokuDir/imageSvc.php?" .http_build_query($parms); // http://www.mythtv.org/wiki/Video_Library#Metadata_Grabber_Troubleshooting // http://www.mythtv.org/wiki/MythVideo_File_Parsing#Filenames // if(!empty($show->screenshot)){ $screenart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Screenshots')) ); $imgfile = !empty($screenart) && !empty($show->screenshot) ? $screenart->dirname . $show->screenshot : "images/oval_grey.png"; // }elseif(!empty($show->fanart)){ // $fanart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Fanart')) ); // $imgfile = $fanart->dirname . $show->fanart; // }else{ // $coverart = StorageGroup::first( array('conditions' => array('groupname = ?', 'Coverart')) ); // $imgfile = $coverart->dirname . $show->coverfile; // } //TODO coverart and fanart are 5-10X sizeof screenshots. videometadata doesn't contain screenshots for movies. create screenshots and update db $parms = array('image'=>$imgfile); $imgUrl = "$WebServer/$MythRokuDir/imageSvc.php?" .http_build_query($parms); //TODO lookup genres for item::genres. can be an array? $category = VideoCategory::first( array('conditions' => array('intid = ?', $show->category)) ); $this->title = new title(array('content'=>normalizeHtml($show->title))); $this->contentQuality = new contentQuality(array('content'=>$RokuDisplayType)); $this->subtitle = new subtitle(array('content'=>normalizeHtml($show->subtitle))); $this->addToAttributes('sdImg', $imgUrl); $this->addToAttributes('hdImg', $imgUrl); $this->contentId = new contentId(array('content'=>$show->filename)); $this->contentType = new contentType(array('content'=>'Movie')); $this->media->streamUrl->setContent("$streamUrl "); //yes the space is required $this->synopsis = new synopsis(array('content'=>normalizeHtml($show->plot))); $season = '(S'.$show->season.'E'.$show->episode.' '.(new DateTime($show->starttime))->format('Y-m-d').')'; $this->genres = new genres(array('content'=>normalizeHtml(empty($category->category) ? '':$category->category).' '.$season)); $this->runtime = new runtime(array('content'=>$show->length * 60)); $this->date = new date(array('content'=>date("Y-m-d", convert_datetime($show->starttime)))); $this->programid = new programid( array('content'=> sprintf("%02d", $show->season) .'.' .sprintf("%03d",$show->episode) ) ); $this->tvormov = new tvormov(array('content'=>'movie')); $this->starrating = new starrating(array('content'=>$show->userrating * 10)); }else{ parent::__construct($show); } }