从变量而不是ob_get_content汇总

从变量而不是ob_get_content汇总

问题描述:

I have a variable which contains a string of text and p tags, where The p tags indicate the different paragraphs. What i want from this variable is to create a summary. I've found a library which looks to be easy to use. However i cant seem to make it work with my variables. It only seem to work using ob_get_content?

Library: https://github.com/freekrai/summarizer

So far i've tried this and it does not seem to return the summary as it does in the demo?

$full_text_strip = "<p>Counter-Strike: Global Offensive majors have a history of spurring serious roster overhauls. The moves following the results of ESL Katowice continue to reinforce tradition.</p><p>Penta Sports proved many doubters wrong by following up its first top-eight finish at a major at DreamHack Winter late last year with another top-eight finish at ESL Katowice. While the German squad did fall in the quarterfinal round to eventual champion Fnatic, the team proved without a doubt to be the best in Germany and among the best in Europe.</p>"

$st = new Summarizer();

$summary = $st->get_summary($full_text_strip);
echo $summary;
echo $st->how_we_did();

我有一个变量,其中包含一串text和p标签,其中p标签表示不同的段落。 我想从这个变量得到的是创建一个摘要。 我找到了一个看起来很容易使用的库。 但是我似乎无法使它与我的变量一起工作。 它似乎只能使用ob_get_content? p>

库: https:// github.com/freekrai/summarizer p>

到目前为止,我已经尝试了这个并且它似乎没有像在演示中那样返回摘要吗? p> \ n

  $ full_text_strip =“&lt; p&gt;反恐精英:全球进攻性专业有着刺激严重名册改革的历史。随着ESL卡托维兹的成果继续加强传统。&lt; / p&gt;  ;&lt; p&gt; Penta Sports在去年年底在DreamHack Winter的一个主要赛事中取得了第一个前八名的成绩,并在ESL卡托维兹再次进入前八名,这让很多怀疑者感到错误。而德国队则在四分之一决赛中落败 最终的冠军Fnatic,该团队毫无疑问地证明了它是德国最好的,也是欧洲最好的。&lt; / p&gt;“
 
 $ st = new Summarizer(); 
 
 $ summary = $ st  - &gt; get_summary($ full_text_strip); 
echo $ summary; 
echo $ st-&gt; how_we_did();  
  code>  pre> 
  div>

Well, if you did what the demo shows and things do not work, then I suggest you create an issue in their bug tracker. However for me the script works. Maybe you should start by checking what errors you actually get. For example you do not close the first statement, there is a ; missing after the content of $full_text_strip...

<?php

require 'summarizer.class.php';

$full_text_strip = "<p>Counter-Strike: Global Offensive majors have a history of spurring serious roster overhauls. The moves following the results of ESL Katowice continue to reinforce tradition.</p><p>Penta Sports proved many doubters wrong by following up its first top-eight finish at a major at DreamHack Winter late last year with another top-eight finish at ESL Katowice. While the German squad did fall in the quarterfinal round to eventual champion Fnatic, the team proved without a doubt to be the best in Germany and among the best in Europe.</p>";

$st = new Summarizer();

$summary = $st->get_summary($full_text_strip);
echo $summary;
echo $st->how_we_did();

The above works for me as expected. Modifications against your version:

  1. trailing semicolon (;) after the string assignment, otherwise you get a syntax error and
  2. require the class script

The first step you should always do when you have an issue with a php script is to look into the error log file. That is where errors are shown. No sense in trying to guess what the error might be when all you have to do is read what the error is.