2015-04-06 59 views
0

我有一个变量,其中包含一个文本和p标签的字符串,其中p标签指示不同的段落。我想从这个变量中得到一个总结。我找到了一个看起来很容易使用的图书馆。不过,我似乎无法使它与我的变量一起工作。它似乎只使用ob_get_content工作?从变量而不是ob_get_content总结

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

到目前为止,我已经尝试这样做,它似乎并没有因为它在演示确实返回总结?

$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(); 

回答

2

那么,如果你做了什么演示显示和东西不工作,那么我建议你在他们的错误跟踪器中创建一个问题。但对我来说,剧本的作品。也许你应该先检查你实际得到的错误。例如,你不关闭的第一条语句,还有一个;$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(); 

对我来说,上述工程预期。修改针对您的版本:

  1. 尾随分号(;)字符串赋值后,否则你会得到一个语法错误和
  2. 要求类脚本

第一步,你应该总是做当你有一个PHP脚本的问题是查看错误日志文件。这是显示错误的地方。尝试猜测没有意义什么错误可能当你所要做的就是读取错误是什么。

+0

好的,谢谢你,但是当你运行它时总结长度也是0? – 2015-04-06 12:56:52

+0

是的。但我不知道这样的“总结”是什么,因此我不能说这是否正确。无论如何,这不在这个问题的范围之内,不是吗? – arkascha 2015-04-06 13:00:14

+0

是超出范围。谢谢 – 2015-04-06 13:08:35