2007-10的存档

小白生日

2007-10-28 9:35 am

      小白自己说,她生日的前后几天都会运气不好。看来还真如此。

因为是周日,照例睡觉睡到太阳晒屁股了才起来。看外面艳阳高照,以为老天也照顾小白生日呢。哪知道一出门才发现,风比太阳更厉害,西北风才是今天的主角。

到了小白家附近,想找一个卖花的地方,可转悠了好半天也没有找到。唉,只好从路边的花坛里摘来一朵,权当借花献佛罢。

中午找地方吃饭,想到的常去的几个地方都不满意,赛飞亚办酒席闹轰轰,干锅居需要打车太远。最后挑的路口的小土豆,却是果然的难吃。

下午在家待了一会后,陪她去对外经贸跳瑜伽。北风那个吹呀,几乎能冻死人了。在等她的空当,我缩在外经贸的自习室里睡大觉,越睡却越冷。

晚上索性回北太平庄去吃口福居的火锅。美美的吃上一顿,算是终于终止了生日运气不好的“咒语”,收拾心情,从明天开始好运长在!

热烈庆祝小白同学步入“大”龄青年行列!

推荐(0)
收藏

周末shopping

2007-10-22 11:39 am

        周六,张姐婚礼,折腾完后一堆亲戚朋友的来家里唠嗑。于是,我和小蔡就一起出去逛街,顺便买点冬天的装备。

首先是去了一趟金五星。最郁闷的是,买第一件东西的时候,由于我的疏忽大意(还沉醉在讲价成功的喜悦中),导致收到一张 ¥20 的假币(周日去招商银行确认是假币,给没收了)。等我们大包小包的回到家,家里正热闹着。只好又出门,去新街口继续逛。

在小西天的永久专卖店给小白买了一辆26女式自行车——这还是刚刚婚礼上想出来的主意——作生日礼物。本来还想留着给她个惊喜,可是实在心里藏不住,就发短信告诉她了。等到把车骑到她家再出来,天已经开始暗下来了。我们再继续绕回新街口,继续逛。

小白出差旅游去泰山了,趁这机会得赶紧把我要买的东西都买齐了,不然她要是在,那逛街就不会这么轻松了,呵呵。买完东西,晚饭还点了俩菜,为今天的腐败划上一个圆满的句号。

--------------------------------------

总支出:现金 600 + 信用卡 285 。

Shopping list:

  • 外套一件 金五星  ¥65
  • 鞋一双 金五星  ¥40 (找回一张假的 20,总共支出 60)
  • 贴身衣物 金五星  ¥14
  • 羊毛衫2件 新街口 ¥39+¥59
  • 永久26女式自行车一辆 新街口 ¥300
  • 喜酒一回 皂君东里 ¥100
  • 上两个月的网费 ¥75
  • 信用卡刷 ¥285 给小蔡买鞋,小蔡给我垫付了外套 65,羊毛衫 20(假币不收),及最后买第二件羊毛衫的时候 100,所以算下来,等于还了小蔡 100

小蔡的list:

  • 阿迪鞋一双,新街口,¥285
  • 裤子一条,金五星,¥35
  • 外套一件,金五星,¥140
  • 欢乐谷一次,¥160 (周日)
推荐(0)
收藏

所谓的汉语编程

2007-10-18 12:53 pm


#define 趁还 while
#define 那个啥 int
#define 总的来说 main
#define 买 cin
#define 卖 cout
#define 进 >>
#define 出
using namespace std;

那个啥 总的来说 我说 那个啥 啊 是吧
那么就 那个啥 有钱 等于 屁 呀
趁还 我说 有钱 是吧 那么就
那个啥 多少 呀 买 进 多少 呀 卖 出 多少 呀 有钱 去掉 多少 呀
卖 出 多少 呀 得了
拜拜了 啊 呀 得了

推荐(0)
收藏

转:安利的谎言

2007-10-17 12:17 pm

        其实究其本质,所有的企业宣传都一样——夸大一部分对企业有利的,只字不提对他们不利的部分。只是这样的选择性宣传,有些企业没有说谎,他们只是“不小心忽略”了,而另外一些企业,则是完全的黑白颠倒,比如安利。

1,当安利谈起营养、他们仅仅告诉你真相的一部分。

——安利会告诉你补充充分维生素和矿物质的美妙事情以及缺乏这些矿物质的要发
生的可怕后果。当然他们会告诉你他们的产品是补充这些营养成分的最佳产品。但是他
们永远会“忽略”告诉你均衡的饮食就可以补充足够的营养成分。而你只需要简单的补
充足够食物就可以了。

2、安利会反复宣称大部分中国人(在美国他们宣称大部分美国人)都是营养缺乏。

——他们忘记告诉你大部分穷苦的中国人需要的是把更多的金钱放在有营养的食物
上,而不是大量维生素上;他们更不会告诉你只要你准确依照《美国食物指引》上的指
引去调理你的饮食,那就没有缺乏的可能。 阅读全文...

推荐(0)
收藏

体检纪事

2007-10-12 1:13 pm

早上早早的起床,因为今天要去体检,9:10 公司的班车从公司楼下发车,团检。

昨天因为去 华尔街英语 领光盘,完了后一直走路回家,回到家已经快 9 点了。而 诚志体检地图) 昨天给我发的短信里说,过了晚 8 点就不要进食了。而那时,我正在华尔街里被一个课程顾问忽悠着呢。

诚志体检离公司并不远,如果不是大家都饿着肚子,可能感觉就一会的功夫。到了体检区,先抽血——一口气抽了 3 瓶,不会是抽血的护士看我闭着眼睛顺便多抽了些吧?接下来去看了牙,医生说有牙结石,建议我去洗牙。接下来做了心电图——往双脚,双手,肚皮上贴了一堆的传感器,在旁边的屏幕上看到熟悉的折线,幸好不是直线。然后是 B 超,往身上滴了好些润滑剂一类的东西,凉飕飕的,接着用一个探头样的东西在肚皮上滑来滑去——想起 Friends 里 Richeal 找不到自己肚子里的 baby 的情景来了。再然后是 X 胸透,我刚刚站好,那个医生就回来跟我说完事了。

外科过后是内科,一个慈祥的老奶奶级别的医生,一边检查还一边喃喃,说什么血压刚刚及格啦(60/90),心率不齐啦什么的,最后跟我说,没有什么问题,害得我白担心了好一会。身高居然降了一厘米(168),体重却不出意料的上升到63kg了。

最后是眼科和耳鼻喉。视力降的太快了,站在测视力的地方,我两只眼睛一起看还看不清楚多少,捂住一只眼睛后,就都只看得见最上面三排了。明天赶紧去配一副好点的眼镜,以后天天戴着吧。结膜炎还得继续滴药,不过现在已经不那么痒了。

我自己感觉这次体检最大的收益就是,耳鼻喉科的那个医生看到我油性耳朵,里面很脏之后,帮我掏了耳朵。完了之后,感觉听声音都清楚了不少。

因为出来的太迟,等所有的检查都做完以后,免费早餐供应已经没有粥了,只好拿了个面包,啃了几口觉得太难吃。算了,还是赶紧回去吃饭去吧。

推荐(0)
收藏

王者归来

2007-10-11 10:05 am

http://v.iask.com --> http://pay.sina.com.cn

在新浪的一年里,先后换了 3 个地方了:最开始在 17 层南区大屋里做爱问视频,那时候爱问视频还是有类似于现在新浪播客的前台的,有推荐页,有评星页,有最新上传视频列表——这些页面大都是我做的,后台的数据生成也是我写的程序定时跑出来的;后来爱问视频的前台撤下来了,换成了新浪播客,我也随即被借调到新浪播客做接口,用户在新浪播客上传一个视频,meta 数据会在新浪播客的服务器与爱问存储,爱问搜索的服务器之间来回传送,我就负责这个 web service 接口; 再后来回到爱问,去了小屋,做起了爱问视频搜索后台的维护,播客视频增加按星级,点击排序,爱问视频后台改版升级,定向抓站等等。这期间,从小屋搬出来到 zhangchu 手下,zhangchu 离职,又回到 zhongwei1 的组里。

搬过来搬过去,总是漂泊不定。而维护的工作又总是千篇一律,没有什么激情。所有的任务都是非常琐碎的,不像开发期间,能看着一件产品在自己手中慢慢成型,成熟直至发布。

不过事情总会好转,生活总会灿烂,这不,又要搬了。这次是转到游戏事业部,做U币支付,恰好是搬回原来的小屋,更巧的是,我原来坐的那个靠窗的位置现在还是空着的——明天体检回来后就搬,赶在没有新人占去我的原位置之前搬进去,哈哈^_^

明天开始回归 PHP+MySql 开发了。

推荐(0)
收藏

看病记

2007-10-10 3:10 pm

        从前天晚上看完李连杰的最新电影《游侠》开始,右眼就感觉有点发痒。到昨天上午对新视频搜索后台进行压力测试的时候,眼睛不停的流泪,几乎看不清屏幕。幸亏压力测试进行的还算顺利,通过修改一个 决定如何取得摘要的参数(从动态生成改成超过长度直接截断),检索后台的承压能力从10个并发每秒提升到40个并发,而且 io 的压力仍然不是很大,只是 cpu 不够用了(后台机器是一个普通的双核机器,硬盘都没有做 raid,只是把服务分散到 4 块不同的硬盘上而已)。这样我们能够确定等播客搜索的后台切换到新系统上来,后台还可以精简下 2 台机器(把当前 2 台独立的合并机器撤下来,合并服务放到检索服务机一起)。

测试结束后,我立即打电话问人事部门关于我的医疗保险卡的问题。幸运的是,医保卡刚刚发下来了。在一堆未整理的卡片中翻出自己的医保卡和条形码,自己往上面贴了照片,拿着就往中关村医院跑。

医院居然是下午 5 点下班,5 点以后就算急诊了——真黑!而且中关村医院这种社区医院急诊没有眼科!于是打车去北医三院。

挂号 5 块,诊疗费 6 块,开了一小瓶从日本进口的滴眼液,28.83 。一个小小的结膜炎,一下子就花去了 40 块。医生最后叮嘱道:如果这两天眼睛有发红或者发肿的现象,赶紧再来复查一下。心里想,医院真是个吃钱的地方,想想中关村修电脑一般都是检查不要钱,修不好也不要钱,可这医院,随便看看就算检查过了,开个药,也不管“修”的好“修”不好,先收了钱再说。

不过人去医院看病,图的就是个心安。开个药,也不管是不是真的管用,看了医生,用了药,心里踏实了,过一两天,病就真的好了。

周五去体检,好好检查一下。

推荐(0)
收藏

转:从HTML文件中抽取正文的简单方案

2007-10-10 2:19 pm

原文: 从HTML文件中抽取正文的简单方案

 

The Easy Way to Extract Useful Text from Arbitrary HTML

从HTML文件中抽取正文的简单方案

作者:alexjc

译者:恋花蝶(http://blog.csdn.net/lanphaday)

原文地址:http://ai-depot.com/articles/the-easy-way-to-extract-useful-text-from-arbitrary-html/

译者导读:这篇文章主要介绍了从不同类型的HTML文件中抽取出真正有用的正文内容的一种有广泛适应性的方法。其功能类似于CSDN近期推出的“剪影”,能 够去除页眉、页脚和侧边栏的无关内容,非常实用。其方法简单有效而又出乎意料,看完后难免大呼原来还可以这样!行文简明易懂,虽然应用了人工神经网络这样 的算法,但因为FANN良好的封装性,并不要求读者需要懂得ANN。全文示例以Python代码写成,可读性更佳,具有科普气息,值得一读。

You’ve finally got your hands on the diverse collection of HTML documents you needed. But the content you’re interested in is hidden amidst adverts, layout tables or formatting markup, and other various links. Even worse, there’s visible text in the menus, headers and footers that you want to filter out. If you don’t want to write a complex scraping program for each type of HTML file, there is a solution.

每个人手中都可能有一大堆讨论不同话题的HTML文档。但你真正感兴趣的内容可能隐藏于广告、布局表格或格式标记以及无数链接当中。甚至更糟的是,你希望那 些来自菜单、页眉和页脚的文本能够被过滤掉。如果你不想为每种类型的HTML文件分别编写复杂的抽取程序的话,我这里有一个解决方案。

This article shows you how to write a relatively simple script to extract text paragraphs from large chunks of HTML code, without knowing its structure or the tags used. It works on news articles and blogs pages with worthwhile text content, among others…

本文讲述如何编写与从大量HTML代码中获取正文内容的简单脚本,这一方法无需知道HTML文件的结构和使用的标签。它能够工作于含有文本内容的所有新闻文章和博客页面……

Do you want to find out how statistics and machine learning can save you time and effort mining text?

你想知道统计学和机器学习在挖掘文本方面能够让你省时省力的原因吗?

The concept is rather simple: use information about the density of text vs. HTML code to work out if a line of text is worth outputting. (This isn’t a novel idea, but it works!) The basic process works as follows:

答案极其简单:使用文本和HTML代码的密度来决定一行文件是否应该输出。(这听起来有点离奇,但它的确有用!)基本的处理工作如下:

  1. Parse the HTML code and keep track of the number of bytes processed.

一、解析HTML代码并记下处理的字节数。

  1. Store the text output on a per-line, or per-paragraph basis.

二、以行或段的形式保存解析输出的文本。

  1. Associate with each text line the number of bytes of HTML required to describe it.

三、统计每一行文本相应的HTML代码的字节数

  1. Compute the text density of each line by calculating the ratio of text to bytes.

四、通过计算文本相对于字节数的比率来获取文本密度

  1. Then decide if the line is part of the content by using a neural network.

五、最后用神经网络来决定这一行是不是正文的一部分。

You can get pretty good results just by checking if the line’s density is above a fixed threshold (or the average), but the system makes fewer mistakes if you use machine learning — not to mention that it’s easier to implement!

仅仅通过判断行密度是否高于一个固定的阈值(或者就使用平均值)你就可以获得非常好的结果。但你也可以使用机器学习(这易于实现,简直不值一提)来减少这个系统出现的错误。

Let’s take it from the top…

现在让我们从头开始……

Converting the HTML to Text

转换HTML为文本

What you need is the core of a text-mode browser, which is already setup to read files with HTML markup and display raw text. By reusing existing code, you won’t have to spend too much time handling invalid XML documents, which are very common — as you’ll realise quickly.

你需要一个文本模式浏览器的核心,它应该已经内建了读取HTML文件和显示原始文本功能。通过重用已有代码,你并不需要把很多时间花在处理无效的XML文件上。

As a quick example, we’ll be using Python along with a few built-in modules: htmllib for the parsing and formatter for outputting formatted text. This is what the top-level function looks like:

我们将使用Python来完成这个例子,它的htmllib模块可用以解析HTML文件,formatter模块可用以输出格式化的文本。嗯,实现的顶层函数如下:

def extract_text(html):

# Derive from formatter.AbstractWriter to store paragraphs.

writer = LineWriter()

# Default formatter sends commands to our writer.

formatter = AbstractFormatter(writer)

# Derive from htmllib.HTMLParser to track parsed bytes.

parser = TrackingParser(writer, formatter)

# Give the parser the raw HTML data.

parser.feed(html)

parser.close()

# Filter the paragraphs stored and output them.

return writer.output()

The TrackingParser itself overrides the callback functions for parsing start and end tags, as they are given the current parse index in the buffer. You don’t have access to that normally, unless you start diving into frames in the call stack — which isn’t the best approach! Here’s what the class looks like:

TrackingParser覆盖了解析标签开始和结束时调用的回调函数,用以给缓冲对象传递当前解析的索引。通常你不得不这样,除非你使用不被推荐的方法——深入调用堆栈去获取执行帧。这个类看起来是这样的:

class TrackingParser(htmllib.HTMLParser):

"""Try to keep accurate pointer of parsing location."""

def __init__(self, writer, *args):

htmllib.HTMLParser.__init__(self, *args)

self.writer = writer

def parse_starttag(self, i):

index = htmllib.HTMLParser.parse_starttag(self, i)

self.writer.index = index

return index

def parse_endtag(self, i):

self.writer.index = i

return htmllib.HTMLParser.parse_endtag(self, i)

The LineWriter class does the bulk of the work when called by the default formatter. If you have any improvements or changes to make, most likely they’ll go here. This is where we’ll put our machine learning code in later. But you can keep the implementation rather simple and still get good results. Here’s the simplest possible code:

LinWriter的大部分工作都通过调用formatter来完成。如果你要改进或者修改程序,大部分时候其实就是在修改它。我们将在后面讲述怎么为它加上机器学习代码。但你也可以保持它的简单实现,仍然可以得到一个好结果。具体的代码如下:

class Paragraph:

def __init__(self):

self.text = ''

self.bytes = 0

self.density = 0.0

class LineWriter(formatter.AbstractWriter):

def __init__(self, *args):

self.last_index = 0

self.lines = [Paragraph()]

formatter.AbstractWriter.__init__(self)

def send_flowing_data(self, data):

# Work out the length of this text chunk.

t = len(data)

# We've parsed more text, so increment index.

self.index += t

# Calculate the number of bytes since last time.

b = self.index - self.last_index

self.last_index = self.index

# Accumulate this information in current line.

l = self.lines[-1]

l.text += data

l.bytes += b

def send_paragraph(self, blankline):

"""Create a new paragraph if necessary."""

if self.lines[-1].text == '':

return

self.lines[-1].text += 'n' * (blankline+1)

self.lines[-1].bytes += 2 * (blankline+1)

self.lines.append(Writer.Paragraph())

def send_literal_data(self, data):

self.send_flowing_data(data)

def send_line_break(self):

self.send_paragraph(0)

This code doesn’t do any outputting yet, it just gathers the data. We now have a bunch of paragraphs in an array, we know their length, and we know roughly how many bytes of HTML were necessary to create them. Let’s see what emerge from our statistics.

这里代码还没有做输出部分,它只是聚合数据。现在我们有一系列的文字段(用数组保存),以及它们的长度和生成它们所需要的HTML的大概字节数。现在让我们来看看统计学带来了什么。

Examining the Data

数据分析

Luckily, there are some patterns in the data. In the raw output below, you’ll notice there are definite spikes in the number of HTML bytes required to encode lines of text, notably around the title, both sidebars, headers and footers.

幸运的是,数据里总是存在一些模式。从下面的原始输出你可以发现有些文本需要大量的HTML来编码,特别是标题、侧边栏、页眉和页脚。

While the number of HTML bytes spikes in places, it remains below average for quite a few lines. On these lines, the text output is rather high. Calculating the density of text to HTML bytes gives us a better understanding of this relationship.

虽然HTML字节数的峰值多次出现,但大部分仍然低于平均值;我们也可以看到在大部分低HTML字节数的字段中,文本输出却相当高。通过计算文本与HTML字节数的比率(即密度)可以让我们更容易明白它们之间的关系:

The patterns are more obvious in this density value, so it gives us something concrete to work with.

密度值图更加清晰地表达了正文的密度更高,这是我们的工作的事实依据。

Filtering the Lines

过滤文本行

The simplest way we can filter lines now is by comparing the density to a fixed threshold, such as 50% or the average density. Finishing the LineWriter class:

过滤文本行的最简单方法是通过与一个阈值(如50%或者平均值)比较密度值。下面来完成LineWriter类:

def compute_density(self):

"""Calculate the density for each line, and the average."""

total = 0.0

for l in self.lines:

l.density = len(l.text) / float(l.bytes)

total += l.density

# Store for optional use by the neural network.

self.average = total / float(len(self.lines))

def output(self):

"""Return a string with the useless lines filtered out."""

self.compute_density()

output = StringIO.StringIO()

for l in self.lines:

# Check density against threshold.

# Custom filter extensions go here.

if l.density > 0.5:

output.write(l.text)

return output.getvalue()

This rough filter typically gets most of the lines right. All the headers, footers and sidebars text is usually stripped as long as it’s not too long. However, if there are long copyright notices, comments, or descriptions of other stories, then those are output too. Also, if there are short lines around inline graphics or adverts within the text, these are not output.

这个粗糙的过滤器能够获取大部分正确的文本行。只要页眉、页脚和侧边栏文本并不非常长,那么所有的这些都会被剔除。然而,它仍然会输出比较长的版本声明、注释和对其它故事的概述;在图片和广告周边的比较短小的文本,却被过滤掉了。

To fix this, we need a more complex filtering heuristic. But instead of spending days working out the logic manually, we’ll just grab loads of information about each line and use machine learning to find patterns for us.

要解决这个问题,我们需要更复杂些的启发式过滤器。为了节省手工计算需要花费的无数时间,我们将利用机器学习来处理每一文本行的信息,以找出对我们有用的模式。

Supervised Machine Learning

监督式机器学习

Here’s an example of an interface for tagging lines of text as content or not:

这是一个标识文本行是否为正文的接口界面:

The idea of supervised learning is to provide examples for an algorithm to learn from. In our case, we give it a set documents that were tagged by humans, so we know which line must be output and which line must be filtered out. For this we’ll use a simple neural network known as the perceptron. It takes floating point inputs and filters the information through weighted connections between “neurons” and outputs another floating point number. Roughly speaking, the number of neurons and layers affects the ability to approximate functions precisely; we’ll use both single-layer perceptrons (SLP) and multi-layer perceptrons (MLP) for prototyping.

所 谓的监督式学习就是为算法提供学习的例子。在这个案例中,我们给定一系列已经由人标识好的文档——我们知道哪一行必须输出或者过滤掉。我们用使用一个简单 的神经网络作为感知器,它接受浮点输入并通过“神经元”间的加权连接过滤信息,然后输后另一个浮点数。大体来说,神经元数量和层数将影响获取最优解的能 力。我们的原型将分别使用单层感知器(SLP)和多层感知器(MLP)模型。

To get the neural network to learn, we need to gather some data. This is where the earlier LineWriter.output() function comes in handy; it gives us a central point to process all the lines at once, and make a global decision which lines to output. Starting with intuition and experimenting a bit, we discover that the following data is useful to decide how to filter a line:

我们需要找些数据来供机器学习。之前的LineWriter.output()函数正好派上用场,它使我们能够一次处理所有文本行并作出决定哪些文本行应该输出的全局结策。从直觉和经验中我们发现下面的几条原则可用于决定如何过滤文本行:

  • Density of the current line.
  • 当前行的密度
  • Number of HTML bytes of the line.
  • 当前行的HTML字节数
  • Length of output text for this line.
  • 当前行的输出文本长度
  • These three values for the previous line,
  • 前一行的这三个值
  • … and the same for the next line.
  • 后一行的这三个值

For the implementation, we’ll be using Python to interface with FANN, the Fast Artificial Neural Network Library. The essence of the learning code goes like this:

我们可以利用FANN的Python接口来实现,FANN是Fast Artificial Neural NetWork库的简称。基本的学习代码如下:

from pyfann import fann, libfann

# This creates a new single-layer perceptron with 1 output and 3 inputs.

obj = libfann.fann_create_standard_array(2, (3, 1))

ann = fann.fann_class(obj)

# Load the data we described above.

patterns = fann.read_train_from_file('training.txt')

ann.train_on_data(patterns, 1000, 1, 0.0)

# Then test it with different data.

for datin, datout in validation_data:

result = ann.run(datin)

print 'Got:', result, ' Expected:', datout

Trying out different data and different network structures is a rather mechanical process. Don’t have too many neurons or you may train too well for the set of documents you have (overfitting), and conversely try to have enough to solve the problem well. Here are the results, varying the number of lines used (1L-3L) and the number of attributes per line (1A-3A):

尝试不同的数据和不同的网络结构是比较机械的过程。不要使用太多的神经元和使用太好的文本集合来训练(过拟合),相反地应当尝试解决足够多的问题。使用不同的行数(1L-3L)和每一行不同的属性(1A-3A)得到的结果如下:

The interesting thing to note is that 0.5 is already a pretty good guess at a fixed threshold (see first set of columns). The learning algorithm cannot find much better solution for comparing the density alone (1 Attribute in the second column). With 3 Attributes, the next SLP does better overall, though it gets more false negatives. Using multiple lines also increases the performance of the single layer perceptron (fourth set of columns). And finally, using a more complex neural network structure works best overall — making 80% less errors in filtering the lines.

有 趣的是作为一个猜测的固定阈值,0.5的表现非常好(看第一列)。学习算法并不能仅仅通过比较密度来找出更佳的方案(第二列)。使用三个属性,下一个 SLP比前两都好,但它引入了更多的假阴性。使用多行文本也增进了性能(第四列),最后使用更复杂的神经网络结构比所有的结果都要更好,在文本行过滤中减 少了80%错误。

Note that you can tweak how the error is calculated if you want to punish false positives more than false negatives.

注意:你能够调整误差计算,以给假阳性比假阴性更多的惩罚(宁缺勿滥的策略)。

Conclusion

结论

Extracting text from arbitrary HTML files doesn’t necessarily require scraping the file with custom code. You can use statistics to get pretty amazing results, and machine learning to get even better. By tweaking the threshold, you can avoid the worst false positive that pollute your text output. But it’s not so bad in practice; where the neural network makes mistakes, even humans have trouble classifying those lines as “content” or not.

从任意HTML文件中抽取正文无需编写针对文件编写特定的抽取程序,使用统计学就能获得令人惊讶的效果,而机器学习能让它做得更好。通过调整阈值,你能够避免出现鱼目混珠的情况。它的表现相当好,因为在神经网络判断错误的地方,甚至人类也难以判定它是否为正文。

Now all you have to figure out is what to do with that clean text content!

现在需要思考的问题是用这些“干净”的正文内容做什么应用好呢?

推荐(0)
收藏

PHP的一个bug

2007-10-10 11:12 am

“Fatal error:Maximum execution time of 0 seconds exceeded”

php.ini 设置:

max_execution_time = 0 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)

这里报错并不是因为脚本执行时间超时,而是输入时间超时,属于错误定位不准确,导致出错信息无效甚至误导编程者。

我的 minicraw 脚本在某些服务器上总是死掉,找了半天,才在 google 上找到答案。其实应该是:Maximum input time of 60 seconds exceeded。解决办法:将 max_input_time = 60 改为 max_input_time = 0 即可。

推荐(0)
收藏
得到OpenID
使用OpenID提供商
35OpenID 35OpenID MyOpenID MyOpenID Flickr Flickr
Google Google Yahoo Yahoo! AOL AOL
Blogger Blogger LiveJournal LiveJournal Verisign Verisign
ClaimID ClaimID Technorati Technorati Vidoop Vidoop
OpenID OpenID 帮助
您还没有登录,请登录后继续操作。
提示:您必需打开Cookie才能使用本系统
请输入您的 OpenID OpenID 登录:
例如:http://yourname.openid.35.com
close