<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[明天晴天]]></title>
<description><![CDATA[像空气般不存在的存在]]></description>
<link>http://365999400.qzone.qq.com</link>
<lastBuildDate>Mon, 30 Nov 2009 09:06:55 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Sun, 25 Oct 2009 13:32:45 GMT</pubDate>

<item>
<title><![CDATA[秋歌]]></title>
<link>http://365999400.qzone.qq.com/blog/1256477565</link>
<description><![CDATA[<span style="color:#00ff00;line-height:1.8em;">在一个自然醒来的午后</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我砸了自己的笔记本电脑</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">把手机Mp3通通丢进了河里</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">撕了那些关于软件设计的书</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">穿着黑色背心白色短裤人字拖</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">背着吉他</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">开始去流浪</span><wbr /><br><span style="color:#00ff00;font-family:'Times';line-height:1.8em;"> </span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">不刮胡子不洗澡也不照镜子变得邋遢不堪</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">饿了就唱歌讨钱</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">不给钱我就噪音污染</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">饱了就睡在楼道口、公园里、树林中、湖边上</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">做春秋大梦</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">一路上</span><wbr /></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我对着树哭泣</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我对着天空呐喊</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">若有人诋毁我</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我就捡起石头砸向他</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">表示我的愤怒</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"></span><wbr /><br><span style="color:#00ff00;font-family:'Times';line-height:1.8em;"> </span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">闲来无事时</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我会想象着未来娘子的摸样</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">她应该很贤惠</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我带着她一起流浪</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">在我们吃饱了的晚上</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">她给我捉着身上的虱子</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">轻轻地放在嘴里</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">牙齿磕的一阵乱响</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">然后在草地上亲吻做爱</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">深夜她睡在我的怀里</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">口水湿了我一身</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">倾听着她雷鸣般欢快的呼噜声</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">安然地进入了梦乡</span><wbr /><br> <br><span style="color:#00ff00;font-family:'Times';line-height:1.8em;"></span><wbr /><br><object codeBase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,0,0" height="100" width="410" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="musicFlash**" id="musicFlash0" src="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" ubb="774089081|1|http://www.wanrc.com/Music/yinchang/%E5%A4%A9%E7%A9%BA%E4%B9%8B%E5%9F%8E.mp3|天空之城|0|山野里的居民"><param value="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" name="movie" /><param value="#ffffff" name="bgColor" /><param value="showall" name="scale" /><param value="transparent" name="wmode" /><param value="true" name="menu" /><param value="always" name="allowScriptAccess" /></object><wbr /><br> <!--v:3.2--> ]]></description>
<category><![CDATA[只是寻常]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1256477565#comment</comments>
<qz:effect>134234640</qz:effect>
<pubDate>Sun, 25 Oct 2009 13:32:45 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1256477565</guid>
</item>

<item>
<title><![CDATA[秋归]]></title>
<link>http://365999400.qzone.qq.com/blog/1255254505</link>
<description><![CDATA[<span style="color:#00ff00;line-height:1.8em;">在秋天的某个午后，我回到了家。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">十四个小时的火车犹如一场噩梦，醒来时喜悦和梦途中难过。还好梦终究会过去，人也会醒来。只是为了心的方向，再苦再累也值得。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">曾经，我也在火车上站着到了南方的一个城市，结果在那个陌生的城市里，迷失了方向。那些都是过去的事情了，我不能是忘记，只是有些恨，积累在心头，怎么也消除不了。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">不是我不想，我努力过，但办不到。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">辗转到了归家的公交车，靠着窗口，熟悉的风景渐渐的来了又去。来来往往，这川流不息的人群和车辆。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我把包里的水给了邻座的阿婆，阿婆的孙子发烧说渴。那些准备的水我都不敢喝，因为火车上站在吸烟区，我根本看不到厕所在哪里。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">在城市待太久，初见大片黄色的土地，和迎面吹来的味道，欣喜，有一种踏实的感觉。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">两小时后，终于到了那个有我成长回忆的小县城。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">今年的家乡遭受了干旱，那条哺育了我们的澧水，露出了她黄黄的躯体。我不曾忘记，那些在堤上骑车，眺望夕阳和未来的样子。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">水的一方那么长，寄托了很多希望。随到一处，都是过去的画面。坐六路车，高中时经常过河去治鼻子和新华书店。坐五路车，从镇上到一中上学。棠华——津市的那一趟，是村子连接外面的纽带，从到镇上上初中开始，就不曾离开了。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我是个念旧的人，很珍惜那个过去的自己。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">那曾经心仪的女孩，如今为谁披上了嫁衣呢？长长的小巷，等待的车站，吃饭的小餐馆，那些有关她的记忆，都沉到了心底。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">朋友不一定要多，但一定要铁。那些有酒有歌的岁月，是年少时轻狂。我也不曾忘记你们的摸样，希望你们是幸福的。或许有一天我们还会重聚，只是不需太多的言语，一杯酒足矣。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">半小时后下了车，就到了想念中的村庄。秋天的田野里，洒落的是那一地灿烂的黄。秧苗黄了，沉沉的谷子垂了下来，棉梗枯了，朵朵的白花开了出来。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">秋天是一个喜悦的季节，在农村，不曾悲过。家家的粮仓满了，棉花收了。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">终于毕业了，不需再向爸妈要钱了。他们的负担轻了些，但只要一想起这些年为我所劳累的，心就很愧疚。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">橘子，柿子，村里四处可见，摘来吃吃，也不会有人来说，多着呢！不比城里，什么都是用钱来衡量。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">妈妈做的菜很好吃，那个土鸡炖板栗，怎一个香字了得。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">坐在小桥上，凝望着夕阳，安静的坠入山腰，很美。夜幕拉下来的时候，小屋里的炊烟也升起来了，路上的行人都匆匆地往有灯火的方向赶。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">那一刻是温暖的，因为有家。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">这些年，由于生活条件渐渐好起来，上山打柴的人越来越少，山里的植被很茂盛，环境一天天的好起来，林间的鸟自由自在。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">只要一走在这空旷的田野里，我就忍不住想要歌唱。那种感觉是自由的，轻松的，很愉快。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">当然，不免有感伤的地方。在我们成长的同时，有些人有些事在离去。在这个庞大的家族里，这几年每年都有人离去。所以我现在最希望的就是，每次回去都能看到同样的面孔，一起吃饭，一起聊天，就很好。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">经过那一堆堆的黄土时，会想起他们的样子。那么熟悉，他们教我们为人处事，给我们很多很多的爱，把我们当成生命中的宝贝。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">这次回家也是为了见一些人，因为有些人不见，很可能一辈子再也见不着。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我一直是一个不擅言语的人，在幺爷爷的床前，看着他矍铄有神的眼睛，不像一个得了绝症的老人。年前的冬天还和强在冷水中捉鱼，那时的他好开心。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">所以我说，好好养病，过年回来再看您。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;"><object codeBase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,0,0" height="100" width="410" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="musicFlash**" id="musicFlash0" src="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" ubb="1136501738|1|http://fwscn.com/mp3/sh1943.mp3|上海一九四三|0|jay"><param value="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" name="movie" /><param value="#ffffff" name="bgColor" /><param value="showall" name="scale" /><param value="transparent" name="wmode" /><param value="true" name="menu" /><param value="always" name="allowScriptAccess" /></object><wbr /></span><wbr /></span><wbr /><br> <!--v:3.2--> ]]></description>
<category><![CDATA[安静平淡]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1255254505#comment</comments>
<qz:effect>134234640</qz:effect>
<pubDate>Sun, 11 Oct 2009 09:48:25 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1255254505</guid>
</item>

<item>
<title><![CDATA[城市]]></title>
<link>http://365999400.qzone.qq.com/blog/1253432234</link>
<description><![CDATA[<span style="color:#00ff00;line-height:1.8em;">来这个城市已经两个月有余，开始的时候还有些惊喜，如今已渐渐褪去，转而为平淡。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">人这种动物，身体里面流动着一种不安分的元素，永远的梦想着生活在别处。每天重复着同一种工作，偶尔也会无聊，偶尔也会沮丧，偶尔也会失落。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">在夜幕降临却依然灯火通明的城市街头，独自一个人寻找一个吃饭的地方，一个煲仔饭，或者兰州拉面，抑或跑到西餐厅，吃个什么什么扒。总之，一个人倒也自在。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我不是个开朗的人，没有主动去接近一个人的习惯。我不爱走入别人的眼帘，我有我的世界。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">这个城市有很多的流浪者，他们风餐露宿，栖息在这里的街头某块树荫下，或者公园里的长凳上，或者某个凉爽的屋檐下。他们有他们的苦与乐，不是我们能够涉入和跟随的。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">楼角的走道里面有几张木板，在某个烈日当头的午后，他们一人一瓶啤酒，坐在那里打着扑克，自得其乐。有时候会看见光着膀子，挑着一箩筐的水泥砖灰，楼上楼下，来来往往，大汗淋漓。累了，就在那角落的木板上面躺躺，晚上也睡在那里。他们来自广大农村的民工，为了妻儿，为了家庭，他们背井离乡，来做这个城市的建设者。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我也是来自农村，不喜欢这个嘈杂的城市，这个城市也不属于我，我们格格不入。但我必须在这个城市活下去，所以不得不掩埋了自己。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">外化而内不化。我像一头牛似地拼命工作，讨厌那些煞有介事喜欢指指点点的人。总有一天我也会变成一头牛的，在这个世界横冲直闯，谁拦着我就掀翻谁。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">自由，我们所谓的自由，在这个已经高度规格化的社会里，还剩下多少呢？权和利，又栓出了多少人的心呢？</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">勇敢是来自心的力量，与身体无关。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">在一个人回家的路上，也会想起他们。他们还好吗？他们在哪里呀？他们会不会想起我？</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">我知道，这些孤单的时光需要独自去承受。外面的风雨太大，生命这只船，要驶向自己的远方，需很多默默的承受。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">偶尔也会站在这个城市的上空，仰望，映入眼帘的除了楼房还是楼房，看不见那些山和水。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">不语……。不想，生活就会很快乐。</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><object codeBase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,0,0" height="100" width="410" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="musicFlash**" id="musicFlash0" src="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" ubb="2619037920|1|http://www.scmx.cn/music/2007/%D4%C2%C7%F2%C9%CF%B5%C4%C8%CB.mp3|月球上的人|0|eason"><param value="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" name="movie" /><param value="#ffffff" name="bgColor" /><param value="showall" name="scale" /><param value="transparent" name="wmode" /><param value="true" name="menu" /><param value="always" name="allowScriptAccess" /></object><wbr /></span><wbr /><br> <!--v:3.2--> ]]></description>
<category><![CDATA[安静平淡]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1253432234#comment</comments>
<qz:effect>134234640</qz:effect>
<pubDate>Sun, 20 Sep 2009 07:37:14 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1253432234</guid>
</item>

<item>
<title><![CDATA[想想]]></title>
<link>http://365999400.qzone.qq.com/blog/1246382594</link>
<description><![CDATA[<span style="color:#00ff00;line-height:1.8em;">    突然想写点什么，关于毕业关于离开。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    曾经的曾经那样想，毕业还那么远那么长，我们都不会分开的。所以我们肆意的挥霍着青春，我们狂妄，我们嚣张，我们天不怕地不怕，我们喝醉了深夜还跑到学校文科校区翻女生宿舍的铁门，我们也在下雨天人山人海的街头去看<span style="font-family:'Times';line-height:1.8em;">JAY</span><wbr />的演唱会，为了逃票翻铁门差点还和保安干起架来，我们在凌晨的广州大街一起唱歌溜达，我们一起把<span style="font-family:'Times';line-height:1.8em;">KTV</span><wbr />的麦克风差点唱爆，我们一起下厨整了两大桌的酒席，我们一起在湖里面游泳，我们一起患难与共……。太多太多我们的故事，不是我这一双手能够敲的过来的。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    在深夜的一个人的广州，想起还是会泪流满面，那些哥们，那些同学，那些很纯的感情。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    骨子里是很感性的一个人，但为了生活，有些时候不能不伪装的严严实实。流泪不是因为伤心，而是因为美好，因为一想起过去我就很感动。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    我从不在你们面前哭，因为我得对得起你们给我男人的称号。难得你们一直都那么相信我，男人出来了，一定会挺到最后的，一定不会辜负你们的期望。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    其实每次去送人，鼻子都会酸，再难受也忍着，仰望一些天空，就好了。所以你们送我的时候，我也是坚持笑到火车离开的。当我再也看不到窗外的那些熟悉可爱的脸时，眼中的泪水立刻涌出来。那一刻，我想我是幸福，我可以有那么多美好的回忆和你们。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    也不知道到底流了多久，时间仿佛停在不见你们的前一秒。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    肌肉男，王俊，<span style="font-family:'Times';line-height:1.8em;">B</span><wbr />哥，高人，括号，一水，肌肉男的老姐，阿秀姐，安仔，阿黄，李彬，姗姗以及她们宿舍的一群人，白总，小姐姐，张臻，贱人，张峰……，还有很多很多人，我想即使大学四年我什么都没学到，能记住了你们的名字，就不算白过。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    我想我会永远不会忘记自己没钱用了你们给我钱，我想我永远不会忘记我郁闷了你们陪我一起喝酒，我想我永远不会忘记差学费不能毕业你们帮我凑学费，我想我永远都不会忘记在人生很美好的大学四年有你们的陪伴。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    是的，那样的美好又有谁舍得忘记呢？</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    很奇怪，从什么时候开始我们就相识了呢？从什么时候开始我们就那么好了呢？又从什么时候开始我们就要分开了呢？</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    我想说，这辈子能认识你们，是一件很幸福的事。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    大学这四年，是我人生中很重要的时刻，谢谢你们给了男人一个舞台，让我能活的那么真实那么骄傲那么嚣张那么不可一世那么自由自在。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    敲字的时候情绪总是很难控制，忘记了时间，忘记了空间，忘记了已经与你们分开。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    来广州的时候口袋里揣着从王俊那里拿来的<span style="font-family:'Times';line-height:1.8em;">200</span><wbr />块，买了车票只有一百三十多了，去虎门朋友玩了两天，然后辗转到广州。</span><wbr /><span style="color:#00ff00;line-height:1.8em;">来广州后，睡了一夜地板，由于种种的原因，差点露宿街头。那一刻，是心酸的……。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    来这里整整十天了，在这个很拥挤的城市，没有工作倍感压力。在烈日当头的街上奔波找工作，虽然汗流浃背，但面临生存问题，几乎感觉不到那些热了。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    我想我是讨厌城市，那些拥挤，那些嘈杂，那些钢筋水泥筑起来的冷漠森林，那些在地铁隧道中穿梭的黑色的风，那些浑浊的空气，那些不适合人类居住的环境。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    但有时候不是你不想待就不待的，生活需要我们去接受些什么，努力的在城市干十年吧，然后再回家乡，落叶归根。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    在夜里会特别想一些人，也很想念妈妈。毕业的时候，很想回一趟家。但我知道我不能回，人年轻的时候应该去远方。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    曾经有个人对我说，善良的人都会很幸福的，虽然现在很艰难，但也会好起来的。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    我相信，努力的工作认真的生活，坚持那些自己坚持的。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    离开的时候，我把你们的脸想象成向日葵的样子，挂在阳光最灿烂的地方。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    所以如果想你们了，我会努力的朝着太阳的方向。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">  <object codeBase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,0,0" height="100" width="410" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="musicFlash**" id="musicFlash0" src="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" ubb="557397082|1|http&amp;#58;//vfile&amp;#46;home&amp;#46;news&amp;#46;cn/music/public/vd05/200905/04/56/MUfs05200905040819315056e886&amp;#46;mp3|那年夏天|0|许飞"><param value="http://imgcache.qq.com/music/musicbox_v2_1/img/MusicFlash.swf" name="movie" /><param value="#ffffff" name="bgColor" /><param value="showall" name="scale" /><param value="transparent" name="wmode" /><param value="true" name="menu" /><param value="always" name="allowScriptAccess" /></object><wbr /></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[安静平淡]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1246382594#comment</comments>
<qz:effect>134234640</qz:effect>
<pubDate>Tue, 30 Jun 2009 17:23:14 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1246382594</guid>
</item>

<item>
<title><![CDATA[spider（三）]]></title>
<link>http://365999400.qzone.qq.com/blog/1244391866</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">摘 要</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">      在互联网蓬勃发展的今天，信息浩如烟海。人们在享受互联网带来便利的同时，却也面临着一个如何在海量的内容中准确、快捷地找到自己所需要的信息的问题，由此互联网搜索引擎应运而生。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">     搜索引擎是从WWW上快速而有效地获取信息资源的捷径,而数据采集技术则是搜索引擎的关键。本文围绕WEB数据采集这一前沿性研究领域课题,结合搜索引擎框架的总体要求,实现了具有数据采集功能的网络蜘蛛在互联网中的漫游,并将网页数据存储在本地数据库中,为以后网页搜索引擎的实现打下了良好的基础。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">     最后，通过对网络蜘蛛系统结构和工作原理进行分析，研究了线程调度、页面爬取、解析策略和广度优先，并用Java做出了一个网络蜘蛛的实现程序。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    关键词：搜索引擎；数据采集；网络蜘蛛；线程调度；页面爬取；广度优先</span><wbr /> <br><br><br><span style="color:#00ff00;line-height:1.8em;"><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">    本系统参考了《</span><wbr /></span><wbr />Programming Spiders,Bots,and Aggregator in Java<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">》[3]中的一些基本原理，把原来</span><wbr />C/S<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">结构变成了</span><wbr />B/S<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">结构。在对数据库的设计与分析上，采用完全面向对象的设计方法，从设计对象开始，打破了传统程序从设计表结构开始的设计思路。在解析</span><wbr /></span><wbr />html<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">上，采用</span><wbr />java<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">内置的包中类：</span><wbr />javax.swing.text.html.HTML<span style="font-family:'宋体';line-height:1.8em;">，</span><wbr />javax.swing.text.html.parser<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">，重写了其中的解析方法。</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-size:16px;font-family:'宋体';line-height:1.8em;">    在对数据库操作中，采用了</span><wbr />java hibernate<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">工作，对数据库进行映射，增删改查.而在对数据库结构对象管理的时候，利用</span><wbr /></span><wbr />java spring<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">，进行依次注入统一管理。三层架构的设计，采用</span><wbr />mvc<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">开发模式，使程序更具健壮性和扩展性。</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">    本程序的难点在于多线程的设计和管理，在多线程技术中，将</span><wbr /></span><wbr />url<span style="font-size:16px;font-family:'宋体';line-height:1.8em;">设置成四种状态，模拟四个队列，然后多个</span><wbr />spiderWorker<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">类共享这些队列的数据，一起协调处理资源，类似于生产者和消费者。在对这些数据操作和存储的方式上面，采用同步的方法，即加锁原理。</span><wbr /></span><wbr /></span><wbr /> <br><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">    数据采集是一个相当有前景的领域，因为随着互联网的信息量的增长以及人们对信息的需求，必定需要专门的程序来对互联网中巨大的信息进行处理，然后来为用户提供服务。</span><wbr /></span><wbr /></span><wbr /> <br><div style="text-align:center;"><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">可行性研究</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">3.1 要求</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(1)     </span><wbr />总体简介：这是一个数据采集系统，主要负责从<span style="font-family:'Times';line-height:1.8em;">WEB</span><wbr />文档及描述中获取资料、分析资料、整理资料。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(2)     </span><wbr />功能：能够准确快速抓取网页，分析网页，为用户提供一个简单友好的软件界面</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(3)     </span><wbr />性能：稳定快速，实时控制。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(4)     </span><wbr />输入<span style="font-family:'Times';line-height:1.8em;">/</span><wbr />输出：条形码英文和汉字输入，英文和汉字输出。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(5)     </span><wbr />数据来源：来自于互联网页面。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">3.2 目标</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(1)     </span><wbr />基于<span style="font-family:'Times';line-height:1.8em;">WEB</span><wbr />的数据采集系统，采用<span style="font-family:'Times';line-height:1.8em;">B/S</span><wbr />结构，客户端不需要安装软件，只需要通过浏览器方可运行程序。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(2)     </span><wbr />采用<span style="font-family:'Times';line-height:1.8em;">MVC</span><wbr />的开发模式，运用轻量级框架，<span style="font-family:'Times';line-height:1.8em;">Struts+Spring+hibernate,</span><wbr />有利于软件的开发和维护。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(3)     </span><wbr />减少之前人力的对于数据的采集，利用计算机抓取数据，进行统计和分析。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(4)     </span><wbr />改进设计的结构，完全采用面向对象设计与分析的理念。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">3.3 条件、假定和限制</span><wbr /><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(1)     </span><wbr />硬件配备不齐，内存不够，硬盘容量太小，需升级到<span style="font-family:'Times';line-height:1.8em;">Windows xp professional</span><wbr />。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(2)      </span><wbr />可利用的信息和资源比较单一，只能够分析静态网页，对于动态网页中的动态内容，不能够进行分析。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(3)      </span><wbr />在面对整个互联网时，遇到有些不规范的数据，缺乏异常处理。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">3.4 进行可行性研究的方法</span><wbr /><span style="color:#00ff00;line-height:1.8em;">通过调查之前使用<span style="font-family:'Times';line-height:1.8em;">heritrix</span><wbr />和<span style="font-family:'Times';line-height:1.8em;">Bot</span><wbr />系统，以及对相关的性能进行测试，对原有系统有了较多、较全面的了解，之后来分析所要建立的系统的实现方法。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">确定了总体结构，<span style="font-family:'Times';line-height:1.8em;">java</span><wbr />对<span style="font-family:'Times';line-height:1.8em;">HTTP ,</span><wbr />多线程和数据持久层的封装，以最简洁最容易的方法，构建成为一个初级的数据采集软件。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">3.5 评价尺度</span><wbr /><span style="color:#00ff00;line-height:1.8em;">首先，综合现有系统，以及所具备的硬件，软件资源，技术水平来对所建议的方案进行评价。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">然后<span style="font-family:'Times';line-height:1.8em;">,</span><wbr />要从开发费用，人力资源，各项功能的优先次序，开发时间长短以及对使用人员的普及等方面进行评价。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">3.6 对所建系统的说明</span><wbr /><span style="color:#00ff00;line-height:1.8em;">数据采集系统是对网页数据的抓取、数据分析、数据存储，数据统计分类的一套系统。在B/S下，通过使用数据库技术与数据管理技术，使数据的准确性与安全性得到了很大的保障，并且可满足用户的并行操作。</span><wbr /> <br><br><div style="text-align:center;"><span style="color:#00ff00;font-family:'黑体';line-height:1.8em;">总 结</span><wbr /> </div><span style="color:#00ff00;line-height:1.8em;">我想说从一开始自己只会使用浏览器来浏览网页，到熟悉网络通讯协议，再到编写出网络通讯的程序，从不知道<span style="font-family:'Times';line-height:1.8em;">html</span><wbr />到用<span style="font-family:'Times';line-height:1.8em;">html</span><wbr />页面编写页面，最后可以解析<span style="font-family:'Times';line-height:1.8em;">html</span><wbr />页面，这是一个相当艰辛的过程，在这个过程中我学到了很多知识。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">这个采集系统运用了《<span style="font-family:'Times';line-height:1.8em;">Programming Spiders,Bots,and Aggregator in Java</span><wbr />》中的一些基本原理，并在其基础上进行了扩展，把原来<span style="font-family:'Times';line-height:1.8em;">C/S</span><wbr />结构变成了<span style="font-family:'Times';line-height:1.8em;">B/S</span><wbr />结构。在对数据库的设计与分析上，采用完全面向对象的设计方法，从设计对象开始，打破了传统程序从设计表结构开始的设计思路。在解析<span style="font-family:'Times';line-height:1.8em;">html</span><wbr />上，采用了<span style="font-family:'Times';line-height:1.8em;">java</span><wbr />内置的包中类：<span style="font-family:'Times';line-height:1.8em;">javax.swing.text.html.HTML</span><wbr />，<span style="font-family:'Times';line-height:1.8em;">javax.swing.text.html.parser</span><wbr />，重写了其中解析方法。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">在对数据库的操作中，采用了<span style="font-family:'Times';line-height:1.8em;">java hibernate</span><wbr />工作，对数据库进行映射，增删改查。在控制层，利用<span style="font-family:'Times';line-height:1.8em;">java struts</span><wbr />的结构，进行统一严格限制。并且在对数据库结构对象管理的时候，利用<span style="font-family:'Times';line-height:1.8em;">java spring</span><wbr />，进行依次注入统一管理。三层架构的设计，采用<span style="font-family:'Times';line-height:1.8em;">mvc</span><wbr />开发模式，使程序更具健壮性和扩展性。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">本程序的难点在于多线程的设计和管理，在多线程技术中，将<span style="font-family:'Times';line-height:1.8em;">url</span><wbr />设置成四种状态，模拟四个优先队列，然后多个<span style="font-family:'Times';line-height:1.8em;">spiderWorker</span><wbr />类共享这些队列的数据，一起协调处理资源，类似于生产者和消费者。在对这些数据的操作和存储方式上面，采用同步的方法，即加锁原理。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">在了解《<span style="font-family:'Times';line-height:1.8em;">Programming Spiders,Bots,and Aggregator in Java</span><wbr />》这本书后，基本的设计与编码大约花了一个月的时间。这一个月里，我学会了编写网络<span style="font-family:'Times';line-height:1.8em;">socket</span><wbr />程序，解析<span style="font-family:'Times';line-height:1.8em;">html</span><wbr />技术，<span style="font-family:'Times';line-height:1.8em;">java</span><wbr />的<span style="font-family:'Times';line-height:1.8em;">ssh</span><wbr />框架，多线程技术，数据库技术，正则表达式等等。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">在该系统设计与实现的整个过程中遇到了很多方面的问题，但是多亏了现在互联网的高速发展，遇到问题可以随时上百度和谷歌，而且从网上还可以查阅许多前沿性的资料，分享别人在数据采集这方面的成果，使整个系统的设计过程顺利了不少。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">最后，回顾整个开发过程，很忙碌，但却也很充实。一份耕耘，一份收获，我相信付出总会有回报的。</span><wbr /> <br></span><wbr /></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1244391866#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Sun, 07 Jun 2009 16:24:26 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1244391866</guid>
</item>

<item>
<title><![CDATA[spider（二）]]></title>
<link>http://365999400.qzone.qq.com/blog/1244391562</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">第</span><wbr /><span style="color:#00ff00;line-height:1.8em;">5章 系统详细设计</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">5.1</span><wbr /><span style="color:#00ff00;line-height:1.8em;"> 模型层的设计与实现</span><wbr /> <br><br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.1 自动下载HTTP的设计</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">http</span><wbr />类是对<span style="font-family:'Times';line-height:1.8em;">http</span><wbr />进行各种操作,如图5.1,其中包含的方法如下：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(1)  <span style="font-family:'Times';line-height:1.8em;">Send</span><wbr />（）:发送网页请求。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(2)  <span style="font-family:'Times';line-height:1.8em;">bulitSocket</span><wbr />（）：建立一个<span style="font-family:'Times';line-height:1.8em;">socket</span><wbr />链接。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(3)  <span style="font-family:'Times';line-height:1.8em;">receive</span><wbr />（）：接收服务器端的响应。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(4)  <span style="font-family:'Times';line-height:1.8em;">download</span><wbr />（）:下载网页。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">HTTP类图：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    <wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912032b8966c9adfaf28263f9fe0b225a65eedbdac35e4c3b936ab5a60985069d41def6f83571e33ba530d478d2c8a53cd0ab87292f2cb1d607b6a82dcf015a99259128a69f" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912032b8966c9adfaf28263f9fe0b225a65eedbdac35e4c3b936ab5a60985069d41def6f83571e33ba530d478d2c8a53cd0ab87292f2cb1d607b6a82dcf015a99259128a69f" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.1 http类图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">  以下是<span style="font-family:'Times';line-height:1.8em;">HTTP</span><wbr />工作流程：</span><wbr /> <br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128fcdb6c90fba7310ed2a6825fe1892690bb6fe548ded5d5de96bd6e8e1870c13145e3ce297216e5d05d3fce291e5d5cada091952200e457c7224e8d2a299d46bb980779c" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128fcdb6c90fba7310ed2a6825fe1892690bb6fe548ded5d5de96bd6e8e1870c13145e3ce297216e5d05d3fce291e5d5cada091952200e457c7224e8d2a299d46bb980779c" /></a><wbr /> </div><br><div style="text-align:center;">图5.2 HTTP类工作活动图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.2 网页分析类的设计</span><wbr /></span><wbr /> <span style="color:#00ff00;line-height:1.8em;">(1)  此<span style="font-family:'Times';line-height:1.8em;">HTMLParser</span><wbr />类的功能是对<span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />网页进行分析。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(2)  集成<span style="font-family:'Times';line-height:1.8em;">ParserCallback</span><wbr />类。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(3)  功能:抓取链接，分析标题，文本。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">因为<span style="font-family:'Times';line-height:1.8em;">Web</span><wbr />中的信息都是建立在<span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />协议之上的，所以网络机器人在检索网页时的第一个问题就是如何解析<span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />。在解决如何解析之前，先来介绍下<span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />中的几种数据，如表<span style="font-family:'Times';line-height:1.8em;">5.1</span><wbr />。</span><wbr /> <br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">表5.1 HTML中的几种数据</span><wbr /></div><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">文本</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">除了脚本和标签之外的所有数据</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">注释</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">程序员留下的说明文字，对用户是不可见的</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">简单标签</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">由单个表示的HTML标签</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">开始标签和结束标签</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">用来控制所包含的HTML代码</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">我们在进行解析的时候不用关心所有的标签，只需要对其中几种重要的进行解析即可。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">超链接标签：超链接定义了<span style="font-family:'Times';line-height:1.8em;">WWW</span><wbr />通过<span style="font-family:'Times';line-height:1.8em;">Internet</span><wbr />链接文档的功能。他们的主要目的是使用户能够任意迁移到新的页面，这正是网络机器人最关心的标签。</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">图像映射标签：图像映射是另一种非常重要的标签。它可以让用户通过点击图片来迁移到新的页面中。</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(4）<span style="font-family:'Times';line-height:1.8em;">HTMLParser</span><wbr />类图：</span><wbr /> <br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128ed2b51123125b778482cf5e45bbb6aaf4c0671854b94ff0f66da09557cb1451bf8ef05203e724caee4309ea5b780e3450e9f2605407f93cbce39970f7c878e5904b9ac4" target="_blank"><img style="border:0;" src="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128ed2b51123125b778482cf5e45bbb6aaf4c0671854b94ff0f66da09557cb1451bf8ef05203e724caee4309ea5b780e3450e9f2605407f93cbce39970f7c878e5904b9ac4" /></a><wbr /> </div><br><br><br><div style="text-align:center;">图5.3 <span style="font-family:'Times';line-height:1.8em;">HTMLParser</span><wbr />类图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">（</span><wbr /><span style="color:#00ff00;line-height:1.8em;">5）分析页面过程如下：</span><wbr /> <span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912044999a2aba0ceaf871e423dc555c99d76cdf6a075cfcc3c9850d223ee83a4e0bc887ee8ca22a3d24b112b05c8dbd3b1154340e10870ecaf3387425741900ff7241f7edc" target="_blank"><img style="border:0;" src="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912044999a2aba0ceaf871e423dc555c99d76cdf6a075cfcc3c9850d223ee83a4e0bc887ee8ca22a3d24b112b05c8dbd3b1154340e10870ecaf3387425741900ff7241f7edc" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.4 <span style="font-family:'Times';line-height:1.8em;">HTMLParser</span><wbr />类工作活动图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.3 spider 类的设计</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">线程允许程序处理多个任务。这对<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序是相当有用的，因为他可能需要同时下载多个网页。<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序使用线程的好处还有它可以更容易地在后台执行，并节省不必要的<span style="font-family:'Times';line-height:1.8em;">CPU</span><wbr />周期。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">在使用线程时，他们必须是同步的。可以使用<span style="font-family:'Times';line-height:1.8em;">java</span><wbr />提供的几个内嵌的特性来完成同步。<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />指出对象锁定和临界区。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">除了线程以外，创建大型的<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />还需要一个<span style="font-family:'Times';line-height:1.8em;">SQL</span><wbr />数据库。<span style="font-family:'Times';line-height:1.8em;">Hibernate</span><wbr />来支持各种数据库的操作。将线程，线程同步和<span style="font-family:'Times';line-height:1.8em;">Hibernate</span><wbr />技术结合在一起，可以很大程度上提高<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序的性能。<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr /></span><wbr /><span style="color:#00ff00;line-height:1.8em;">类图如下：<wbr /><a href="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a01a83f77d2dd05f2e9e75e7ac9dab74eef3d7e6d08d3d1260486ac10318853a0cde68a6e92e378b7c67f86b9ebd3657c04b820543cd3938a96c62006e6d66bc3bb0a2c3" target="_blank"><img style="border:0;" src="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a01a83f77d2dd05f2e9e75e7ac9dab74eef3d7e6d08d3d1260486ac10318853a0cde68a6e92e378b7c67f86b9ebd3657c04b820543cd3938a96c62006e6d66bc3bb0a2c3" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.5 <span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />类图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.4 IspiderReportable接口</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">这是一个必须实现的接口，可以通过回调函数接受<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />所遇到的页面。接口定义了<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />向他的控制者发送的几个事件。通过提供对每个事件的处理程序，可以创建各种<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序。下面是他的接口声明：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public interface IspiderReportable{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    // 发现内部连接时调用，url表示程序发现的URL，若返回true则加入作业中，否则不加入。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean foundInternalLink(String url);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    // 发现外部连接时调用，url表示程序所发现的URL，若返回true则把加入作业中，否则不加入</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean foundExternalLink(String url);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    // 当发现其他连接时调用这个方法。其他连接指的是非HTML网页，可能是E-mail或者FTP</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean foundOtherLink(String url);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       // 用于处理网页，这是Spider程序要完成的实际工作。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public void processPage(HTTP page);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       // 用来请求一个被处理的网页。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public void completePage(HTTP page,boolean error);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       // 由Spider程序调用以确定查询字符串是否应删除。如果队列中的字符串应当删除，方法返回真 </span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">public boolean getRemoveQuery();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">// 当Spider程序没有剩余的工作时调用这个方法。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public void SpiderComplete();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean foundExternalLink(String url);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    // 当发现其他连接时调用这个方法。其他连接指的是非HTML网页，可能是E-mail或者FTP</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean foundOtherLink(String url);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       // 用于处理网页，这是Spider程序要完成的实际工作。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public void processPage(HTTP page);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       // 用来请求一个被处理的网页。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">public boolean getRemoveQuery();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">// 当Spider程序没有剩余的工作时调用这个方法。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">5.1.5 spider类的工作流程</span><wbr /> <br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a97d19062b18d7681dbd30cd80d329a940b0dfb5f935bc1c6e00b26f0fa7d5aefcafe1ebdd4e42e313d2964258ab92fddf5517597b5104a649de287fcb612e58b7f07a70" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a97d19062b18d7681dbd30cd80d329a940b0dfb5f935bc1c6e00b26f0fa7d5aefcafe1ebdd4e42e313d2964258ab92fddf5517597b5104a649de287fcb612e58b7f07a70" /></a><wbr /> </div><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.6 <span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />工作流程图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.6 如何利用多线程提高spider性能</span><wbr /></span><wbr /> <span style="color:#00ff00;line-height:1.8em;">    <span style="font-family:'Times';line-height:1.8em;">Internet</span><wbr />中拥有海量的<span style="font-family:'Times';line-height:1.8em;">Web</span><wbr />页面，如果开发出高效的<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序是非常重要的。下面就来介绍下几种提高性能的技术：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    <span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />的多线程技术</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    线程是通过程序的一条执行路线。多线程是一个程序同时运行多个任务的能力。它是在一个程序的内部进行分工合作。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    优化程序的通常方法是确定瓶颈并改进他。瓶颈是一个程序中最慢的部分，他限制了其他任务的运行。据个例子说明：一个<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序需要下载十个页面，要完成这一任务，程序必须向服务器发出请求然后接受这些网页。当程序等待响应的时候其他任务不能执行，这就影响了程序的效率。如果用多线程技术可以让这些网页的等待时间合在一起，不用互相影响，这就可以极大的改进程序性能。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(1) </span><wbr />线程管理类设计：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">通常一个应用程序很容易知道如何它何时能完成任务。但是在多线程<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />的情况下却不是这样的。在<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />能够知道自己完成之前必须满足两个标准：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">无活动的工作线程：不能有正在下载的线程。如果有，他们会在等待队列中加入<span style="font-family:'Times';line-height:1.8em;">URL</span><wbr />，这将使得<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />类继续搜寻。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">无等待队列：等待队列中不能有任何数据，如果有，线程工作类将会处理它，这样不能认为<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />类已经完成。</span><wbr /> <br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a769985c5f4cd63efd1f8a2605be4c9bbeda51142ac3e12b8b56c382faf1a90dfc71f94f7f1b32a28965e43a1bbce4925aa48ff22b1b2dfc37e87e3fa81f678e95629367" target="_blank"><img style="border:0;" src="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a769985c5f4cd63efd1f8a2605be4c9bbeda51142ac3e12b8b56c382faf1a90dfc71f94f7f1b32a28965e43a1bbce4925aa48ff22b1b2dfc37e87e3fa81f678e95629367" /></a><wbr /> </div><br><br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.7 线程管理类类图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">(2)  </span><wbr />线程工作类设计</span><wbr /> <span style="color:#00ff00;line-height:1.8em;">由于<span style="font-family:'Times';line-height:1.8em;">spider</span><wbr />是多线程的，必须有一种方法在不用的线程间分配任务。工作的基本单元是<span style="font-family:'Times';line-height:1.8em;">SpiderWorker</span><wbr />对象。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">如果下载无错误的完成，这一方法会解析<span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />并将每一个链接存储到数据库中，并标注其状态为等待。最后网页会被传给<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />类。其类图如下：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912bce37b04cd1bb2bc754b577170ed1dec98b64fee67244393ede798cd0d99a01c7ec4ed4507dcf1c5a544d8210c33eedf33fa7783a4efb57fc3b9969f0f58281e206a71d7" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912bce37b04cd1bb2bc754b577170ed1dec98b64fee67244393ede798cd0d99a01c7ec4ed4507dcf1c5a544d8210c33eedf33fa7783a4efb57fc3b9969f0f58281e206a71d7" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.8 线程工作类类图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">① 线程工作类一次抓取流程：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439125c1676585562c821027e90da3fbc9cd2f2b7d065f8f2fe618a297e7138bce9c4a193d69541c3c92ecc4f05b25e0813a899133c91d7216b2f92e85e260f21a515563a5156" target="_blank"><img style="width:501px;height:599px;border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439125c1676585562c821027e90da3fbc9cd2f2b7d065f8f2fe618a297e7138bce9c4a193d69541c3c92ecc4f05b25e0813a899133c91d7216b2f92e85e260f21a515563a5156" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.9 线程工作类工作流程图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">② 线程工作类具体处理流程：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f881f1434e58b9efe2e2601fb6466b7b65901bc9f52103bcb2a8e1fca62c97e804251064841e55bf9b9b4082ba8ead66f37a6d00d7e5d2d058fe6069c752356900df7796" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f881f1434e58b9efe2e2601fb6466b7b65901bc9f52103bcb2a8e1fca62c97e804251064841e55bf9b9b4082ba8ead66f37a6d00d7e5d2d058fe6069c752356900df7796" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.10 线程工作类处理流程</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.7 数据库技术</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">当<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序访问一个大型<span style="font-family:'Times';line-height:1.8em;">Web</span><wbr />站点时，必须使用一种有效的方法来存储站点队列。这些队列管理<span style="font-family:'Times';line-height:1.8em;">Spider</span><wbr />程序必须维护大型网页的列表。如果把他们放在内存中将会是性能下降，所以我们可以把他们放在数据库中减少系统资源的消耗。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">数据库加载任务类的设计如下图<span style="font-family:'Times';line-height:1.8em;">5.11</span><wbr />：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(1)此接口是用来定义了对任务的各种操作* 定义了四种状态：运行（<span style="font-family:'Times';line-height:1.8em;">RUNNING</span><wbr />) 、错误(<span style="font-family:'Times';line-height:1.8em;">ERROR</span><wbr />)、等待（<span style="font-family:'Times';line-height:1.8em;">WAITING</span><wbr />）、完成（<span style="font-family:'Times';line-height:1.8em;">COMPLETE</span><wbr />）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(2)方法：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">assignWorkload</span><wbr />（）：加载一个任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">addWorkload</span><wbr />（）：添加一个任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">completeWorkload</span><wbr />（）：完成一个任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">getURLStatus</span><wbr />（）：得到<span style="font-family:'Times';line-height:1.8em;">url</span><wbr />的状态。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">deleteURL</span><wbr />（）：删除一项任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">clear</span><wbr />（）：清空。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a0719955436217fd9fd9b1abdb8aa1fd5caf0dea98ed68c53169b95f03e5e04f8a60213cd9938033893ea37d5f95d12ad76200d0184c18fa7740f337271ec2a6830f072c" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912a0719955436217fd9fd9b1abdb8aa1fd5caf0dea98ed68c53169b95f03e5e04f8a60213cd9938033893ea37d5f95d12ad76200d0184c18fa7740f337271ec2a6830f072c" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.11 数据库管理任务类图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.8 数据访问接口的设计</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">在核心J2EE模式中是这样介绍DAO模式的：为了建立一个健壮的J2EE应用，应该将所有对数据源的访问操作抽象封装在一个公共API中。用程序设计的语言来说，就是建立一个接口，接口中定义了此应用程序中将会用到的所有事务方法。在这个应用程序中，当需要和数据源进行交互的时候则使用这个接口，并且编写一个单独的类来实现这个接口在逻辑上对应这个特定的数据存储。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">项目中DAO的类设计：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128278adf1ea852f5ab7480ccfeb58ec5f37e464d1df42e236b32bac88fec0b38a2b1349fde97ec7a1406f95ce7130f4509e46d12eaccc7e9f3feeb09f8c437df6cf9fc312" target="_blank"><img style="border:0;" src="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439128278adf1ea852f5ab7480ccfeb58ec5f37e464d1df42e236b32bac88fec0b38a2b1349fde97ec7a1406f95ce7130f4509e46d12eaccc7e9f3feeb09f8c437df6cf9fc312" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.12 数据库操作接口类图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">5.2</span><wbr /><span style="color:#00ff00;line-height:1.8em;"> 控制层的设计与实现</span><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.1 WorkAction类设计：</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(1)  此<span style="font-family:'Times';line-height:1.8em;">action</span><wbr />类的功能是用来处理客户端的一个请求。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(2)  集成<span style="font-family:'Times';line-height:1.8em;">dicpatchAction</span><wbr /> 类，利用请求的参数进行分发。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">(3)  此类包含三个方法 <span style="font-family:'Times';line-height:1.8em;">start</span><wbr />（） ,<span style="font-family:'Times';line-height:1.8em;">end</span><wbr />（） , <span style="font-family:'Times';line-height:1.8em;">getResult</span><wbr />（），如下图<span style="font-family:'Times';line-height:1.8em;">5.13</span><wbr />。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">①      <span style="font-family:'Times';line-height:1.8em;">start</span><wbr /> （）：开始抓取任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">②      <span style="font-family:'Times';line-height:1.8em;">end</span><wbr /> （）：结束抓取任务。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">③      <span style="font-family:'Times';line-height:1.8em;">getResult</span><wbr />（）：得到抓取结果统计分析数据。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439125e886739be21f291c7e4f10e7cd9494f0d1db6c8a10c35d2db5a389afb48fe2476ee14744de62a53af19f7990dd9c7397293f967fed584ac47373819e24677d179766dfc" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439125e886739be21f291c7e4f10e7cd9494f0d1db6c8a10c35d2db5a389afb48fe2476ee14744de62a53af19f7990dd9c7397293f967fed584ac47373819e24677d179766dfc" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.13 控制层<span style="font-family:'Times';line-height:1.8em;">WorkAction</span><wbr />类图</span><wbr /></div><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.2 控制层WorkAction工作流程：</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912942ad04bec42f8866f7420bc634ffd2d2b38773e8b3385dd6aca8b63ab2d6bdcd74c32e7e48e7ad51c33411a0abd18427241c7bb041ac4a0ed16610cc4d4abaf18ab6aa5" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912942ad04bec42f8866f7420bc634ffd2d2b38773e8b3385dd6aca8b63ab2d6bdcd74c32e7e48e7ad51c33411a0abd18427241c7bb041ac4a0ed16610cc4d4abaf18ab6aa5" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.14 控制层<span style="font-family:'Times';line-height:1.8em;">WorkAction</span><wbr />工作流程图</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">5.3</span><wbr /><span style="color:#00ff00;line-height:1.8em;"> 表示层的设计与实现</span><wbr /><span style="color:#00ff00;line-height:1.8em;">表示层包括三个页面：<span style="font-family:'Times';line-height:1.8em;">index.jsp,running.jsp,result.jsp</span><wbr />。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">index.jsp</span><wbr />：系统的首页面，进行参数配置，比如可以设置网络蜘蛛抓取的首页面的<span style="font-family:'Times';line-height:1.8em;">URL</span><wbr />地址，开启的线程数目，是否为环球网络蜘蛛，是否为下载页面到本地，是否分析抓取其他链接，本地下载文件夹设置等等。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">running.jsp</span><wbr />：系统运行时的界面，可以随时停止网络蜘蛛的抓取任务，而回到抓取结果页面。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">result.jsp</span><wbr />：网络蜘蛛结果分析页面，对抓取的页面进行分析统计，统计数据：显示抓取链接的总数、分析网页总数、下载页面总数、完成链接总数、错误链接总数、<span style="font-family:'Times';line-height:1.8em;">mp3</span><wbr />链接总数、图片链接总数。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">5.3.1 首页面的设计</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391220bf1cc6bd3cd849ed4ef68f85ff891aba6a02bc53ecb963e5e55dd618a90a8b3823211e63f77eba226cf441e8233a0cc6d6ba952c6fd468b4e239c19a07c08efb6155a4" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391220bf1cc6bd3cd849ed4ef68f85ff891aba6a02bc53ecb963e5e55dd618a90a8b3823211e63f77eba226cf441e8233a0cc6d6ba952c6fd468b4e239c19a07c08efb6155a4" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.15 数据采集系统首页面图</span><wbr /></div><br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.3.2 统计结果的实现</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912565264b418013b1f31ad4bfbe438b6b67c9f7ab4405c1b9a6834d07a45a9aadd1ba7b4a8f0ce79c4d706802192a6d9e1eb2c18cb5f75a565b4ae549184679694b21ff67b" target="_blank"><img style="border:0;" src="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912565264b418013b1f31ad4bfbe438b6b67c9f7ab4405c1b9a6834d07a45a9aadd1ba7b4a8f0ce79c4d706802192a6d9e1eb2c18cb5f75a565b4ae549184679694b21ff67b" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">图5.16 数据采集统计结果页面图</span><wbr /></div> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1244391562#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Sun, 07 Jun 2009 16:19:22 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1244391562</guid>
</item>

<item>
<title><![CDATA[spider（一）]]></title>
<link>http://365999400.qzone.qq.com/blog/1244389738</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#33ff00;line-height:1.8em;">第</span><wbr /><span style="color:#33ff00;line-height:1.8em;">4章 需要分析与设计</span><wbr /></div><span style="color:#33ff00;line-height:1.8em;">4.1</span><wbr /><span style="color:#33ff00;line-height:1.8em;"> 系统的提出</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">我们现在已经生活在一个相当数字化的时代中,通信技术、计算机和网络技术的快速发展正极大地影响着整个人类社会。然而，它们在给人们带来方便的同时也带来了许多问题，使我们一方面惊叹于信息爆炸，另一方面又不得不面对知识贫乏的苦恼。信息过量难以消化，信息真假难以辨别，信息安全难以保证，信息形式相异难以统一处理等问题逐渐暴露出来。人们开始考虑：“如何才能不被信息淹没，而是有效地发现以及利用信息。”面对这一挑战，基于<span style="font-family:'Times';line-height:1.8em;">web</span><wbr />的数据采集系统应运而生.</span><wbr /> <br> <br><span style="color:#33ff00;line-height:1.8em;">4.2</span><wbr /><span style="color:#33ff00;line-height:1.8em;"> 系统功能分析</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">当前网络发展迅速，各种网站比比皆是。但在竞争日益激烈的网络经济中，只有赢得用户，才能最终赢得竞争的优势。作为一个网站的管理员或拥有者，应该知道用户都在他的网站上干什么，知道网站哪些部分最为用户喜爱，哪些让用户感到厌烦，什么地方出了安全漏洞，什么样的改动带来了显著的用户满意度，什么样的改动反而丢失了用户等等。“知己知彼”，才能“百战不殆”。而基于<span style="font-family:'Times';line-height:1.8em;">WEB </span><wbr />数据采集正好能满足这些需求。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">数据是对事实、概念或指令的一种表达形式，可由人工或自动化装置进行处理。数据的形式可以是数字、文字、图形或声音等。数据经过解释并赋予一定的意义之后，便成为信息。数据采集的基本目的是从大量的、可能是杂乱无章的数据中提取并推导出对于某些特定的人们来说是有价值、有意义的数据。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">基于WEB 数据采集实际上就是从WEB 文档及其描述中获取信息, WEB 文档文件采集以及基于概念索引或Agent 技术的资源搜索也应该归于此类。Web 信息资源类型众多，目前WWW </span><wbr /><span style="color:#33ff00;line-height:1.8em;">信息资源已经成为网络信息资源的主体，它有极速发展给人们的生活带来了质的提高。但</span><wbr /><span style="color:#33ff00;line-height:1.8em;">人们在享受互联网带来便利的同时，却也面临着一个如何在海量的内容中准确、快捷地找到自己所需要的信息的问题，所以，如何获得这些数据源就成为了搜索引擎核心的内容，基于WEB的数据采集系统就是利用网络蜘蛛在互联网上抓取分析网页，为搜索引擎提供可利用数据。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">数据采集贯穿于社会生产和社会生活的各个领域。数据采集技术的快速发展及其在生活中应用的深入，正极大地影响着</span><wbr /><span style="color:#00ff00;line-height:1.8em;">人类社会发展的进程。 </span><wbr /><br></span><wbr /><br> <br><span style="color:#00ff00;line-height:1.8em;">4.3 </span><wbr />系统功能设计</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">该数据采集系统按面向对象程序设计思想，分析得出图<span style="font-family:'Times';line-height:1.8em;">4.1</span><wbr />系统用例图：</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391253a5bf9e3da687d998a04546e6fa3ef44735e3ce50119017f8535464c7fc13a412eaaf8f01ad2941df3015d61248ee9e9fe27897976ea7d1852f21c4558d55dcbd003502" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391253a5bf9e3da687d998a04546e6fa3ef44735e3ce50119017f8535464c7fc13a412eaaf8f01ad2941df3015d61248ee9e9fe27897976ea7d1852f21c4558d55dcbd003502" /></a><wbr /> <br><br></span><wbr /><br><br><div style="text-align:center;"><span style="color:#33ff00;line-height:1.8em;">图4.1系统用例图</span><wbr /></div> <br><span style="color:#33ff00;line-height:1.8em;">4.4 Spider(</span><wbr /><span style="color:#33ff00;line-height:1.8em;">网络蜘蛛设计)</span><wbr /> <br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#33ff00;line-height:1.8em;">4.4.1 spider工作原理</span><wbr /></span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">我们来看看网络<span style="font-family:'Times';line-height:1.8em;">spider</span><wbr />如何下载整个互联网。假定我们从一家门户网站的首页出发，先下载这个网页，然后通过分析这个网页，可以找到藏在它里面的所有超链接，也就等于知道了这家门户网站首页所直接连接的全部网页，诸如雅虎邮件、雅虎财经、雅虎新闻等等。我们接下来访问、下载并分析这家门户网站的邮件等网页，又能找到其他相连的网页。我们让计算机不停地做下去，就能下载整个的互联网。当然，我们也要记载哪个网页下载过了，以免重复。在网络<span style="font-family:'Times';line-height:1.8em;">spider</span><wbr />中，我们使用一个<span style="font-family:'Times';line-height:1.8em;">t_link</span><wbr />表来记录我们已经完成的爬取情况。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">现在的互联网非常巨大，不可能通过一台或几台计算机服务器就能完成下载任务。比如雅虎公司宣称他们索引了 <span style="font-family:'Times';line-height:1.8em;">200</span><wbr /> 亿个网页，假如下载一个网页需要一秒钟，下载这 <span style="font-family:'Times';line-height:1.8em;">200</span><wbr /> 亿个网页则需要 <span style="font-family:'Times';line-height:1.8em;">634</span><wbr /> 年。因此，一个商业的网络<span style="font-family:'Times';line-height:1.8em;">spider</span><wbr />需要有成千上万个服务器，并且由快速网络连接起来。如何建立这样复杂的网络系统，如何协调这些服务器的任务，就是网络设计和程序设计的艺术了。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">在<span style="font-family:'Times';line-height:1.8em;">Java</span><wbr />中，网络<span style="font-family:'Times';line-height:1.8em;">spider</span><wbr />大体需要一下几个方面的知识：</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">(1)  多线程的自动<span style="font-family:'Times';line-height:1.8em;">HTTP</span><wbr />下载。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">(2)  <span style="font-family:'Times';line-height:1.8em;">HTML</span><wbr />文件的格式解析。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">(3)  把解析后的文件存入数据库。</span><wbr /> <br><span style="font-family:'黑体';line-height:1.8em;"></span><wbr /> <br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#33ff00;line-height:1.8em;">4.4.2 spider具体设计</span><wbr /></span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">(1)  对抓取目标的描述或定义：预先给定的初始抓取种子样本； </span><wbr /><br><span style="color:#33ff00;line-height:1.8em;">(2)  对网页或数据的分析与过滤：对错误的无用的网页和链接予以丢弃</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">(3)  对<span style="font-family:'Times';line-height:1.8em;">URL</span><wbr />的搜索策略：广度优先的搜索策略。 </span><wbr /><br> <br><span style="color:#33ff00;line-height:1.8em;">4.5 </span><wbr /><span style="color:#33ff00;line-height:1.8em;">数据库设计</span><wbr /><br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#33ff00;line-height:1.8em;">4.5.1 数据库需求分析</span><wbr /></span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">由于数据采集系统需要分析网页的数据，并将其结构化。所以必须建立数据库来对其分析的结果进行管理。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">建立三个表对象：Html ,Attribute,Link。</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">Html</span><wbr />对象用来存储整个页面结构化以后的数据，其属性如下<span style="font-family:'Times';line-height:1.8em;">:</span><wbr /> </span><wbr /><br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr />  String url; //网页的http地址     </span><wbr /><br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr />  String title;//标题 </span><wbr /><br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr />  Set attributes;//属性集合</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr />  String paragraphText;//文本内容</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr />  String encode；//网页的字符编码</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">               Attribute</span><wbr />对象用来存储页面链接，其属性如下：</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> <span style="font-weight:bold"><wbr />int</span><wbr /> id ; //属性id主键</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> String attValue;  //属性值</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> String attType;    //类型</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> String attContent; //描述</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">Link</span><wbr />对象用来存储用来作为抓取地址的链接，其属性如下：</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> <span style="font-weight:bold"><wbr />int</span><wbr /> id;  //属性id主键</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> String url;  //链接地址</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />private</span><wbr /> String desc;  //链接描述</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">     <span style="font-weight:bold"><wbr />private</span><wbr /> <span style="font-weight:bold"><wbr />char</span><wbr />  Status;  //</span><wbr />链接状态</span><wbr /> <br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#33ff00;line-height:1.8em;">4.5.2 数据库概念结构设计</span><wbr /></span><wbr /> <br><span style="color:#33ff00;font-family:'Times';line-height:1.8em;">    <wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439120b811327afc03f40b0e27dceaebab45789c804071ac6a6a6d71a670cac002fea1a2f9b01a5df0ada02842e6ec35bdfa69672c6d9896c85d0ca571a05cf9c56b1dcf060a1" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439120b811327afc03f40b0e27dceaebab45789c804071ac6a6a6d71a670cac002fea1a2f9b01a5df0ada02842e6ec35bdfa69672c6d9896c85d0ca571a05cf9c56b1dcf060a1" /></a><wbr /> <br><br></span><wbr /><br><div style="text-align:center;"><span style="color:#33ff00;line-height:1.8em;">图<span style="font-family:'Times';line-height:1.8em;">4.2 </span><wbr />对象关系图</span><wbr /></div><br><span style="color:#33ff00;line-height:1.8em;">4.6</span><wbr /><span style="color:#33ff00;line-height:1.8em;">设计方案</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">本系统采用B/S结构，所有的程序及数据都放在服务器上。在语言方面使用JAVA语言，在数据库使用的MYSQL，WEB服务器使用Tomcat服务器。</span><wbr /><br><span style="color:#33ff00;line-height:1.8em;">基本处理流程如图4.3所示：</span><wbr /> <br><span style="color:#33ff00;line-height:1.8em;">         <wbr /><a href="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439120edfb8ac9564c3a7346d8decd14fd21e25b24c6d4f007adaae912e8444f9fc967e5f6eae2ec0d729df4584eb64055b85ca843e412944e85b0b62112880df8fbe2c29d114" target="_blank"><img style="border:0;" src="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439120edfb8ac9564c3a7346d8decd14fd21e25b24c6d4f007adaae912e8444f9fc967e5f6eae2ec0d729df4584eb64055b85ca843e412944e85b0b62112880df8fbe2c29d114" /></a><wbr /> <br><br></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1244389738#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Sun, 07 Jun 2009 15:48:58 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1244389738</guid>
</item>

<item>
<title><![CDATA[LPAnalyzer（四）]]></title>
<link>http://365999400.qzone.qq.com/blog/1243531597</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">控制层的设计与实现 </span><wbr /></div><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />5<span style="font-family:'黑体';line-height:1.8em;">.3.1 workServlet类图：</span><wbr /></span><wbr /> </span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391286fb4ba621a4229f9f2920c6ad7c2ef3904ce84690c300d6b797f97c288e1f67dd1bfd18999025be7c042c5bde1711313ae90043515f4be0ed7b19ce8c7f52d6c7599aac" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391286fb4ba621a4229f9f2920c6ad7c2ef3904ce84690c300d6b797f97c288e1f67dd1bfd18999025be7c042c5bde1711313ae90043515f4be0ed7b19ce8c7f52d6c7599aac" /></a><wbr /> </span><wbr /><br><br><span style="color:#00ff00;line-height:1.8em;">5.3.2 控制层分词全过程（活动图） </span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912186f5b558ee5295598d332ea7c8d40d7ab0d13db55c2a3014a0975f0a1d577bbec02cc6b8ee57c429eeae2ea8a5e8a4abddf7810ac3053f5114d1aedbee69a16802e61ad" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912186f5b558ee5295598d332ea7c8d40d7ab0d13db55c2a3014a0975f0a1d577bbec02cc6b8ee57c429eeae2ea8a5e8a4abddf7810ac3053f5114d1aedbee69a16802e61ad" /></a><wbr /> </span><wbr /><br><br><span style="color:#00ff00;line-height:1.8em;">5.2.4 分词系统页面</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391240f37d8b8c26842d8f6fe3fbb1aff5950aa2b4dcbff66b41182052ba06f2ae437de3d5ca3c904084e30b1d45dd668a7a6771936bcd39c7b014ea04c5e8cb7d2551103990" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391240f37d8b8c26842d8f6fe3fbb1aff5950aa2b4dcbff66b41182052ba06f2ae437de3d5ca3c904084e30b1d45dd668a7a6771936bcd39c7b014ea04c5e8cb7d2551103990" /></a><wbr /> </span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1243531597#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Thu, 28 May 2009 17:26:37 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1243531597</guid>
</item>

<item>
<title><![CDATA[LPAnalyzer（三）]]></title>
<link>http://365999400.qzone.qq.com/blog/1243531351</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">逻辑层的设计与实现</span><wbr /></div><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.1  分词器</span><wbr /></span><wbr /></span><wbr /><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">设计</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">      该类设计参考了<span style="font-family:'Times';line-height:1.8em;">lucene</span><wbr />中<span style="font-family:'Times';line-height:1.8em;">StandardTokenizer</span><wbr />类，只是<span style="font-family:'Times';line-height:1.8em;">StandardTokenizer</span><wbr />在处理中文时，是按字切分，没有做任何相关的处理。该类扩展了<span style="font-family:'Times';line-height:1.8em;">StandardTokenizer</span><wbr />类的功能，在接收一个字符串输入流的时候，按照一个可切分单元的性质来交给相关的处理类。比如接收的若是中文字符串，就交给中文处理类（<span style="font-family:'Times';line-height:1.8em;">CJKCell</span><wbr />），是英文字符串，就交给英文处理类(<span style="font-family:'Times';line-height:1.8em;">CharCell</span><wbr />)，是数字字符串，就交给数字处理类（<span style="font-family:'Times';line-height:1.8em;">NumCell</span><wbr />）。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    该类继承了<span style="font-family:'Times';line-height:1.8em;">Tokenizer   </span><wbr />，重写了<span style="font-family:'Times';line-height:1.8em;">next</span><wbr />方法，改方法的功能是接收一个字符串输入流，返回一个切分的词流。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">类设计（如图<span style="font-family:'Times';line-height:1.8em;">5.5</span><wbr />）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912d65fc38e7981a6d379ebe1e5ded5a87eef3afcfda16c8acdf722bb08eb498139419a50b3fea543781e8f0c4848ede50a230ffff0aa17b2d3b3b54373ec3feff50e4f8331" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912d65fc38e7981a6d379ebe1e5ded5a87eef3afcfda16c8acdf722bb08eb498139419a50b3fea543781e8f0c4848ede50a230ffff0aa17b2d3b3b54373ec3feff50e4f8331" /></a><wbr /> <br><br></span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.2 具体分析类设计</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">     Cell接口代表一个可切分的处理单元，比如 “我爱中华人民共和国”，就是一个可以切分最小单元。Cell接口有三个抽象方法:</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（1）    receive：接收一个可切分单元</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（2）    process：处理一个可切分单元</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（3）    iterator: 返回一个切分后存储词（Token类型）的链表的迭代器</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">类的具体设计（如图5.6）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b13.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f22ee62959c23a2272b9da50b1f9fd229b24c5460245d80dc5c55419ab8201d295b436ce3797e95e81961a4f7c6198cd0e2cb074b46fb94219f0bebeb79d520b3a5ade0d" target="_blank"><img style="border:0;" src="http://b13.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f22ee62959c23a2272b9da50b1f9fd229b24c5460245d80dc5c55419ab8201d295b436ce3797e95e81961a4f7c6198cd0e2cb074b46fb94219f0bebeb79d520b3a5ade0d" /></a><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;">5.2.3 </span><wbr />LPTokenizer<span style="font-family:'黑体';line-height:1.8em;">类中获得一个分词过程（</span><wbr />next<span style="font-family:'黑体';line-height:1.8em;">方法 活动图）</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912e16066f8b3de01c5493228519f730b7dff28756f792331c01badf203a0276391ba56bbe90304381c4060194eabb753a7fb3f6b232a038fb6f16d6cf66a3a71f76b294921" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912e16066f8b3de01c5493228519f730b7dff28756f792331c01badf203a0276391ba56bbe90304381c4060194eabb753a7fb3f6b232a038fb6f16d6cf66a3a71f76b294921" /></a><wbr /> <br><br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">此过程代码如下：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />public</span><wbr /> Token next() <span style="font-weight:bold"><wbr />throws</span><wbr /> IOException {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">             <span style="font-weight:bold"><wbr />while</span><wbr /> (tokenIteractor == <span style="font-weight:bold"><wbr />null</span><wbr /> || !tokenIteractor.hasNext()) {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">         segLength = 0;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                             segLength = input.read(segmentBuff);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                      <span style="font-weight:bold"><wbr />if</span><wbr />(segLength &lt;= 0)</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                <span style="font-weight:bold"><wbr />return</span><wbr /> <span style="font-weight:bold"><wbr />null</span><wbr />;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                  iters =dealWith();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                             Iterator it=iters.iterator();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />while</span><wbr />(it.hasNext()){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                      Iterator iter=(Iterator)it.next(); <br><br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">                                       <span style="font-weight:bold"><wbr />while</span><wbr />(iter.hasNext()){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                 Token token = (Token)iter.next();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                  tokens.add(token);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                }} tokenIteractor=tokens.iterator();}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">       <span style="font-weight:bold"><wbr />return</span><wbr /> tokenIteractor.next(); </span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">5.2.4 LPTokenizer类中处理一次处理切分单元过程（dealWith方法 活动图）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912b52726e92b7ec0b26e146daf662ec1c66d41242d36c4ddc3c00267ef4eb67c13008d96096faaec17b5067e7f67241c866dc5938e7c22d8f705b0e440000e4b3278fab563" target="_blank"><img style="border:0;" src="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912b52726e92b7ec0b26e146daf662ec1c66d41242d36c4ddc3c00267ef4eb67c13008d96096faaec17b5067e7f67241c866dc5938e7c22d8f705b0e440000e4b3278fab563" /></a><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">此过程核心代码：</span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">public List  dealWith(){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">            boolean flag=false;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">            List list= new LinkedList();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">          Iterator&lt;Token&gt; iter=null;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">            char current = '\0';</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">            segmentBuff[0] = toDBC(segmentBuff[0]);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     current = segmentBuff[0];</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     inputStatus=dictionary.getCharType(current);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">       for(int i = 0;i&lt;segLength;i++){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">           segmentBuff<span style="font-style:italic"><wbr /> = toDBC(segmentBuff<span style="font-style:italic"><wbr />);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     current = segmentBuff<span style="font-style:italic"><wbr />;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     inputStatus=dictionary.getCharType(current);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                      if(i==0){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                contextInit();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                      }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     if( flag==false &amp;&amp; inputStatus==4 &amp;&amp; lastStatus==3){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                flag = true;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                length++;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         if(i!=segLength-1)</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                            continue;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                              }else if(inputStatus==lastStatus &amp;&amp; inputStatus!=0 &amp;&amp; inputStatus!=4 ){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                            length++;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         if(i!=segLength-1)</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                            continue;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                   }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">             switch(lastStatus){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">               case 1:   cell=CJKCell;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.receive(segmentBuff, offset, length);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.process();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         iter= cell.iterator();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         break;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                    case 2:   cell=charCell;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.receive(segmentBuff, offset, length);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.process();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         iter= cell.iterator();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                           break;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                    case 3:   cell=numCell;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.receive(segmentBuff, offset, length);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         cell.process();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                         iter= cell.iterator();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                          break;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                       default:   if(i+1&lt;segLength) </span><wbr /></span><wbr /><br><br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">     inputStatus=dictionary.getCharType(toDBC(segmentBuff<span style="font-style:italic"><wbr />));</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                i+=1;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                lastStatus=inputStatus;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                break;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                  }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                  if(i!=segLength-1){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     offset=i;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     i=i-1;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     length=0;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                     flag=false;</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                            lastStatus=inputStatus; }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                   if(iter!=null){</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                   list.add(iter);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                  }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">               return list; }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="font-weight:bold"><wbr /><span style="font-size:16px;line-height:1.8em;"><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.5 中文分析类中文处理一次切分（活动图）</span><wbr /></span><wbr /></span><wbr /></span><wbr /> <br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439127fce201ba33fb939eaab509a9e6681561c0f725c6d82c2f35f25833465719f461941b55c4a811160de0544e77df71f5e1816f44d193d74bec4ce6e7502a996ebcb09a557" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439127fce201ba33fb939eaab509a9e6681561c0f725c6d82c2f35f25833465719f461941b55c4a811160de0544e77df71f5e1816f44d193d74bec4ce6e7502a996ebcb09a557" /></a><wbr /> <br><br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">此过程代码：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />public</span><wbr /> <span style="font-weight:bold"><wbr />void</span><wbr /> process() {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">               tokens = <span style="font-weight:bold"><wbr />new</span><wbr /> LinkedList&lt;Token&gt;();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                    String w=<span style="font-weight:bold"><wbr />null</span><wbr />;      </span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                    isMatch= <span style="font-weight:bold"><wbr />new</span><wbr /> <span style="font-weight:bold"><wbr />boolean</span><wbr />[length];</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                   <span style="font-weight:bold"><wbr />if</span><wbr />(length==1){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                              w = (<span style="font-weight:bold"><wbr />new</span><wbr /> String(seq, begin, 1));</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                              <span style="font-weight:bold"><wbr />if</span><wbr />(!dictionary.isStopWord(w))</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                { token = <span style="font-weight:bold"><wbr />new</span><wbr /> Token(w,begin, end+1);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                 tokens.add(token);}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                   }<span style="font-weight:bold"><wbr />else</span><wbr />{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />for</span><wbr />(<span style="font-weight:bold"><wbr />int</span><wbr /> i=begin;i&lt;offset+length;i++){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />if</span><wbr />(dictionary.isStopWord(String.<span style="font-style:italic"><wbr />valueOf</span><wbr />(seq<span style="font-style:italic"><wbr />))){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                 maxLength--;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                 <span style="font-weight:bold"><wbr />continue</span><wbr />;}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                      dictTreeNode=dicSeg.getDictTreeNode();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                      flag=0;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                <span style="font-weight:bold"><wbr />if</span><wbr />(dictionary.isCHNum(seq<span style="font-style:italic"><wbr />)){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                 flag=1;}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                         searchMaxMatch(i ,i);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                         <span style="font-weight:bold"><wbr />if</span><wbr />(token!=<span style="font-weight:bold"><wbr />null</span><wbr />){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                    tokens.add(token);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                        }<span style="font-weight:bold"><wbr />else</span><wbr />{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                 <span style="font-weight:bold"><wbr />if</span><wbr />(isMatch<span style="font-style:italic"><wbr />==<span style="font-weight:bold"><wbr />true</span><wbr />){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                            maxLength--;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                            <span style="font-weight:bold"><wbr />continue</span><wbr />;}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                             <span style="font-weight:bold"><wbr />if</span><wbr />(flag==1){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                            searchCount(begin,end);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                           tokens.add(token);</span><wbr /> <br><br><span style="color:#00ff00;line-height:1.8em;">}<span style="font-weight:bold"><wbr />else</span><wbr />{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />if</span><wbr />(i==begin ){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">w = (<span style="font-weight:bold"><wbr />new</span><wbr /> String(seq, i, 2));</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />if</span><wbr />(!dictionary.isStopWord(w))</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">{  isMatch<span style="font-style:italic"><wbr />=<span style="font-weight:bold"><wbr />true</span><wbr />;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">token = <span style="font-weight:bold"><wbr />new</span><wbr /> Token(w,i,i+2);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">tokens.add(token);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />if</span><wbr />(wordMap.containsKey(w)){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">wordMap.put(w, wordMap.get(w)+1);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                                                                                        }<span style="font-weight:bold"><wbr />else</span><wbr />{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">wordMap.put(w, 1) }}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">  }<span style="font-weight:bold"><wbr />else</span><wbr /> <span style="font-weight:bold"><wbr />if</span><wbr />(i!=begin &amp;&amp; maxLength&lt;2){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">   w = (<span style="font-weight:bold"><wbr />new</span><wbr /> String(seq, i-1, 2));</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />if</span><wbr />(!dictionary.isStopWord(w))</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">{  isMatch<span style="font-style:italic"><wbr />=<span style="font-weight:bold"><wbr />true</span><wbr />;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    token = <span style="font-weight:bold"><wbr />new</span><wbr /> Token(w,i-1,i+1);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    tokens.add(token);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          <span style="font-weight:bold"><wbr />if</span><wbr />(wordMap.containsKey(w)){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">wordMap.put(w, wordMap.get(w)+1);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">}<span style="font-weight:bold"><wbr />else</span><wbr />{</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">wordMap.put(w, 1);</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">         }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">      }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">   }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">token = <span style="font-weight:bold"><wbr />null</span><wbr />;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">maxLength--;} }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">}</span><wbr /> <br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.2.6 中文分析（CJKCELLImpl</span><wbr /><span style="color:#00ff00;line-height:1.8em;">）类中最大长度匹配动态规划算法（活动图）<wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912871911c36b98dcc7a917d9674f116682af2f7b1db0b569552b1a6715d29cd5e27baabcd33d0248a8e11273a1ecb53bce3527425b58ffa206499cf06cf4938be4d2498800" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912871911c36b98dcc7a917d9674f116682af2f7b1db0b569552b1a6715d29cd5e27baabcd33d0248a8e11273a1ecb53bce3527425b58ffa206499cf06cf4938be4d2498800" /></a><wbr /> <br><br></span><wbr /></span><wbr /></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">5.2.7 分词器自主加入新词的过程（活动图）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391233651a6046b6547854f296f40ba8f381afd4f48acdf7a508f51a7ebd2daadbed6ca7723099f1a0b70321085ad5a98e5521b33558106107953e1729df58a0af7c8fc61e55" target="_blank"><img style="border:0;" src="http://b8.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e4391233651a6046b6547854f296f40ba8f381afd4f48acdf7a508f51a7ebd2daadbed6ca7723099f1a0b70321085ad5a98e5521b33558106107953e1729df58a0af7c8fc61e55" /></a><wbr /> <br><br></span><wbr /><br><span style="font-weight:bold"><wbr /><span style="color:#00ff00;line-height:1.8em;">5.2.8 LPAnalyzer 类图</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912114966d4cb8e4b06135c080589acc5408e8d11f0135a47ea3d222a36a449d26aeabe49497a4128a0d78186a9df6f2721f285fd72686ad67bf85983b711b1d5ccfaf3bd5e" target="_blank"><img style="border:0;" src="http://b9.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912114966d4cb8e4b06135c080589acc5408e8d11f0135a47ea3d222a36a449d26aeabe49497a4128a0d78186a9df6f2721f285fd72686ad67bf85983b711b1d5ccfaf3bd5e" /></a><wbr /> <br><br><br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">   此类代码：</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">  package com.lp.analysis;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">  public class LPAnalyzer extends Analyzer {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          private Dictionary dictionary;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          private Map  &lt;String , Integer&gt; wordMap;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">      public LPAnalyzer(){</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          dictionary=Dictionary.load();</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          wordMap=new  HashMap(); ;</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">          public TokenStream tokenStream(String fileName, Reader reader) {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                       return   new LPTokenizer(reader,dictionary,wordMap);}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">   public Dictionary getDictionary() {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                       return dictionary;}</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">   public Map&lt;String, Integer&gt; getWordMap() {</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">                   return wordMap;</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">    }</span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">  }</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><br></span><wbr /> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1243531351#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Thu, 28 May 2009 17:22:31 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1243531351</guid>
</item>

<item>
<title><![CDATA[LPAnalyzer（二）]]></title>
<link>http://365999400.qzone.qq.com/blog/1243530869</link>
<description><![CDATA[<div style="text-align:center;"><span style="color:#00ff00;line-height:1.8em;">系统详细设计</span><wbr /></div><span style="color:#00ff00;line-height:1.8em;">5.1 </span><wbr /><span style="color:#00ff00;line-height:1.8em;">模型层的设计与实现</span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.1词段</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">DicSeg是用来存储词库的类，其数据结构是层次性的树状哈希结构。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（1）属性  </span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">NodeState</span><wbr />是整数类型，表示该节点状态，即是否为词的结尾。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">dictTreeNode</span><wbr />是<span style="font-family:'Times';line-height:1.8em;">Map</span><wbr />类型，表示持有下一层节点的引用。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（2）方法</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-family:'Times';line-height:1.8em;">addWord</span><wbr />为该类的主要方法，即加入一个词到树状哈希结构的词段中。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">（3）类图（如图<span style="font-family:'Times';line-height:1.8em;">5.1</span><wbr />）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912b04fbae24c1f0794513a7a35190f46cc36b6dded58dcff117b3e3b04baac958e94da60cba134a6d7f6c6e49cb1b256f94c6e3d75b27c403a767f53aba8b51313a3994f2e" target="_blank"><img style="border:0;" src="http://b17.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912b04fbae24c1f0794513a7a35190f46cc36b6dded58dcff117b3e3b04baac958e94da60cba134a6d7f6c6e49cb1b256f94c6e3d75b27c403a767f53aba8b51313a3994f2e" /></a><wbr /> <br><br></span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.2 词典</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">     词典依赖词段，包含加载各种性质词以及判断该词词性的各种方法。</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">  类图（如图5.2）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f934a4cc9ec08dd0b5e591e856a079329fce8733392f015279fba6230c11828da840c72e0426d6c8bf01f23a4ac2ebc4e7bca2e0c95cad8647bec72358ead30525987431" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912f934a4cc9ec08dd0b5e591e856a079329fce8733392f015279fba6230c11828da840c72e0426d6c8bf01f23a4ac2ebc4e7bca2e0c95cad8647bec72358ead30525987431" /></a><wbr /></span><wbr /> <br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.3 构造树状哈希结构</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">    树状哈希构造过程采用自顶向下的递归构造</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;">构造流程（如图5.3）</span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439127045a681928a9d0c3809f3356aad109e0d512f48da7a384d2885bb45ec290729c9ebaabc17072f110172d9d5ea046424f6834fbb052e139db94447919de8aa0305d608ff" target="_blank"><img style="border:0;" src="http://b19.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e439127045a681928a9d0c3809f3356aad109e0d512f48da7a384d2885bb45ec290729c9ebaabc17072f110172d9d5ea046424f6834fbb052e139db94447919de8aa0305d608ff" /></a><wbr /> <br><br></span><wbr /><br><span style="color:#00ff00;line-height:1.8em;">图5.3构造树状哈希结构活动图</span><wbr /> <br><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.4 加载词库</span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-size:16px;font-family:'黑体';line-height:1.8em;">词库的词是存放在二进制文件中的，一个词占一行。在加载的过程中，因为只有常用词语的数量巨大，所以其存储结构才是树状哈希。其他的词的数量较少，直接用</span><wbr />HashSet<span style="font-size:16px;line-height:1.8em;"><span style="font-family:'黑体';line-height:1.8em;">存储。</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr /><span style="font-size:16px;font-family:'黑体';line-height:1.8em;">其过程（如图</span><wbr />5.4<span style="font-size:16px;font-family:'黑体';line-height:1.8em;">）</span><wbr /></span><wbr /></span><wbr /> <br><span style="color:#00ff00;line-height:1.8em;"><wbr /><a href="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912ba90b93ebb10e608b3fbcd06f2fe5e9b4f78e867904ff6a0756d9fff0693aa501f81d2076ce78ca8b015b5793dd23f29369d22ed80aa92f3e7f74a27024cf2e877beeae0" target="_blank"><img style="border:0;" src="http://b16.photo.store.qq.com/http_imgload.cgi?/rurl4_b=fa2f9548bcbe5184ac588b7af9e43912ba90b93ebb10e608b3fbcd06f2fe5e9b4f78e867904ff6a0756d9fff0693aa501f81d2076ce78ca8b015b5793dd23f29369d22ed80aa92f3e7f74a27024cf2e877beeae0" /></a><wbr /> <br><br></span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-family:'黑体';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">5.1.5加载词时递归构造哈希树状结构代码</span><wbr /></span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;"><span style="font-weight:bold"><wbr />    public</span><wbr /> <span style="font-weight:bold"><wbr />void</span><wbr /> addWord(<span style="font-weight:bold"><wbr />char</span><wbr /> seg[], <span style="font-weight:bold"><wbr />int</span><wbr /> begin, <span style="font-weight:bold"><wbr />int</span><wbr /> end) {</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                   <span style="font-weight:bold"><wbr />try</span><wbr />{</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />if</span><wbr /> (dictTreeNode == <span style="font-weight:bold"><wbr />null</span><wbr />) {</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                      dictTreeNode = <span style="font-weight:bold"><wbr />new</span><wbr /> HashMap(2, 0.8F);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                             }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">         Character keyChar = new Character(seg[begin]);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                             DicSeg ds = (DicSeg) dictTreeNode.get(keyChar);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">        <span style="font-weight:bold"><wbr />if</span><wbr /> (ds == <span style="font-weight:bold"><wbr />null</span><wbr />) {</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                      ds = <span style="font-weight:bold"><wbr />new</span><wbr /> DicSeg();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                 dictTreeNode.put(keyChar, ds);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                              }</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />if</span><wbr /> (begin &lt; end)</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                      ds.addWord(seg, begin + 1, end);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                             <span style="font-weight:bold"><wbr />else</span><wbr /> <span style="font-weight:bold"><wbr />if</span><wbr /> (begin == end) {</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                                      ds.setNodeState(1);</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">      }}<span style="font-weight:bold"><wbr />catch</span><wbr />(Exception e){e.printStackTrace();</span><wbr /></span><wbr /> <br><span style="font-family:'Times';line-height:1.8em;"><span style="color:#00ff00;line-height:1.8em;">                   }</span><wbr /></span><wbr /> <br><br><br> <!--v:3.2--> ]]></description>
<category><![CDATA[毕业设计]]></category>
<author><![CDATA[365999400@qq.com(明天晴天)]]></author>
<comments>http://365999400.qzone.qq.com/blog/1243530869#comment</comments>
<qz:effect>134218241</qz:effect>
<pubDate>Thu, 28 May 2009 17:14:29 GMT</pubDate>
<guid>http://365999400.qzone.qq.com/blog/1243530869</guid>
</item>

</channel>
</rss>

