上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页
摘要: CHAPTER 3Processing Raw Text 处理原始文本The most important source of texts is undoubtedly the Web. It’s convenient to have existing text collections to explore, such as the corpora we saw in the previous chapters. However, you probably have your own text sources in mind, and need to learn how to access t 阅读全文
posted @ 2011-08-05 21:51 牛皮糖NewPtone 阅读(2658) 评论(1) 推荐(0) 编辑
摘要: 博主懒人...练习未做完,下回补全...2.8Exercises练习 1. ○ Create a variable phrase containing a list of words. Experiment with the operations described in this chapter, including addition, multiplication, indexing, slicing, and sorting. List_practice=['Hello','World!']List_practice+['Pythoner' 阅读全文
posted @ 2011-08-05 21:36 牛皮糖NewPtone 阅读(2392) 评论(0) 推荐(0) 编辑
摘要: 转载请注明出处“一块努力的牛皮糖”:http://www.cnblogs.com/yuxc/新手上路,翻译不恰之处,恳请指出,不胜感谢2.7Further Reading深入阅读 Extra materials for this chapter are posted at http://www.nltk.org/ , including links to freely available resources on the Web. The corpus methods are summarized in the Corpus HOWTO, at http://www.nltk.org/howt 阅读全文
posted @ 2011-08-05 21:26 牛皮糖NewPtone 阅读(703) 评论(0) 推荐(0) 编辑
摘要: 转载请注明出处“一块努力的牛皮糖”:http://www.cnblogs.com/yuxc/新手上路,翻译不恰之处,恳请指出,不胜感谢2.6Summary 小结 • A text corpus is a large, structured collection of texts. NLTK comes with many corpora, e.g., the Brown Corpus, nltk.corpus.brown. 文本语料库是一个大型的结构化的一系列的文本。NLTK包含了许多语料库,例如,Brown Corpus,nltk.corpus.brown。 • Some text corp 阅读全文
posted @ 2011-08-05 21:24 牛皮糖NewPtone 阅读(2010) 评论(1) 推荐(0) 编辑
摘要: 新手上路,翻译不恰之处,恳请指出,不胜感谢Updated log1st:2011/8/6 2nd:新图标更换,原图标实在不喜欢那~相信有不少童鞋会喜欢~1.2 A Closer Look at Python: Texts as Lists of Words 进一步学习Python:将文本视作单词列表You’ve seen some important elements of the Python programming language. Let’s take a few moments to review them systematically.Lists 列表What is a text? 阅读全文
posted @ 2011-08-05 16:40 牛皮糖NewPtone 阅读(1757) 评论(0) 推荐(0) 编辑
摘要: 这个问题是这个样子滴:有一个无序、元素个数为n(n为偶数)的正整数数组arr,要求:如何能把这个数组分割为元素个数为n/2的两个子数组,并使两个子数组的的和最接近。问题来源: http://hi.baidu.com/hell74111/blog/item/b6155d94f46717067bf48024.html我的思路是:(1)把数组拆成2个子数组A和B(2)用A中的每个元素与B中的每个元素比较,数组值之和的绝对值小于原来的值就交换其实并不难,关键在于我突然犯2了...我写了个测试数组a=[1,2,3,4,5,6].然后想当然地以为分成的两个数组各元素之和应该相等的。结果在那苦苦耗了半天,想 阅读全文
posted @ 2011-08-02 18:14 牛皮糖NewPtone 阅读(2053) 评论(1) 推荐(1) 编辑
摘要: 给出任意一个十进制整数n,计算它的b进制展开式from __future__ import divisionimport mathdef baseb(b,q): aList=[] while q!=0: a=int(math.fmod(q,b)) q=math.floor(q/b) aList.append(str(a)) expansion=''.join(aList) print expansion运行结果如下>>> baseb(2,100)0010011 阅读全文
posted @ 2011-08-02 11:53 牛皮糖NewPtone 阅读(536) 评论(0) 推荐(0) 编辑
摘要: 一道中学生的题目困扰了我好久啊,从吃晚饭时间到现在...求x的n次方的末两位数。令y=x**n,则y的末两位数与x的末两位数有关。规律就是从2开始,每20个数是一个循环View Code for x in range(2, 100): #x为底数 y=x%100 #y为幂的最后两位 s="" for n in range(2,201): #n为指数 init=y #init保留上一次y的值 y=y*x #每次乘以一个x y = y % 100 #对y用100取模,值为最后两位数 if y==init: # 如果本次算值与上次计算值相同,则不需继续计算 break if y= 阅读全文
posted @ 2011-08-01 19:20 牛皮糖NewPtone 阅读(744) 评论(0) 推荐(0) 编辑
摘要: 这是一道从别人博客里看到的趣味题:[题目]1元钱一瓶汽水,喝完后两个空瓶换一瓶汽水,问:你有20元钱,最多可以喝到几瓶汽水?我想当然地以为是20—>10—>5—>2—>1,漏了一瓶...还是写个程序来解决一下:设每次买一瓶,攒够2个空瓶就换一瓶汽水:def qishui1( m ): s = 0 # 喝去的汽水瓶数 k = 0 #空瓶数 while m>0: m=m-1 #买 1瓶 s=s+1 k=k+1 while k==2: k=0 s=s+1 #换一瓶汽水,喝掉 k=k+1 #又多出来一个空瓶 return s,km = 20s,k=qishui1(m)pr 阅读全文
posted @ 2011-08-01 17:55 牛皮糖NewPtone 阅读(1497) 评论(1) 推荐(0) 编辑
摘要: 作为一个Python菜鸟,之前一直懵懂于urllib和urllib2,以为2是1的升级版。今天看到老外写的一篇《Python: difference between urllib and urllib2》才明白其中的区别。You might be intrigued by the existence of two separate URL modules in Python -urllibandurllib2. Even more intriguing: they are not alternatives for each other. So what is the difference be 阅读全文
posted @ 2011-08-01 17:10 牛皮糖NewPtone 阅读(61168) 评论(0) 推荐(2) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 24 下一页