Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'win32': 0.03; '"__main__":': 0.09; '%s"': 0.09; '__name__': 0.09; 'lines:': 0.09; 'sfxlen:2': 0.11; 'python': 0.11; 'def': 0.12; "'w')": 0.16; '(key,': 0.16; '2.7.2': 0.16; 'codecs': 0.16; 'subject:student': 0.16; 'tokens:': 0.16; 'urllib': 0.16; 'subject:python': 0.16; 'student': 0.16; 'bit': 0.19; 'appears': 0.22; 'import': 0.22; 'print': 0.22; 'error': 0.23; 'skip:l 30': 0.24; 'to:2**1': 0.27; 'tried': 0.27; 'to:no real name:2**1': 0.29; 'words': 0.29; 'code': 0.31; 'lines': 0.31; 'url:wiki': 0.31; 'received:98.138.87': 0.31; 'url:wikipedia': 0.31; 'skip:c 30': 0.32; 'run': 0.32; 'raw': 0.33; 'trouble': 0.34; 'could': 0.34; 'but': 0.35; 'charset:us-ascii': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'highest': 0.39; 'to:addr:python.org': 0.39; 'university': 0.39; 'first': 0.61; 'information': 0.63; 'name': 0.63; 'skip:n 10': 0.64; 'regards.': 0.65; 'url:ar': 0.68; 'skip:r 30': 0.69; 'to:addr:python-list- request': 0.84; 'url:%85': 0.84; 'url:%b9': 0.84; 'pfxlen:2': 0.91 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 738071.10449.bm@omp1007.mail.ne1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1414201662; bh=F9wjXkF3VndbkXGJHT+0unYt+0N6MKk0Xf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JzaXR5IG9mIGpvcmRhbiAuIA0KaSBoYXZlIGEgdHJvdWJsZSB1c2luZyB0aGUgdG9rZW5pemVyIHRvIGZpbmQgdGhlIGZyZXF1ZW5jeSBsaXN0IGZvciBVUkwgdXNpbmcgYXJhYmljIHRleHQuYW5kIGlhbSB1c2luZyBweXRob24gMi43LjIgb24gd2luWFAsSSB0cmllZCB0aGlzIGNvZGUgYnV0IGV2ZXJ5IHRpbWUgaSBydW4gdGhlIGMBMAEBAQE- X-Mailer: YahooMailClassic/810 YahooMailWebService/0.8.203.733 Date: Fri, 24 Oct 2014 18:47:42 -0700 From: heba abukaff Subject: python student at university of jordan. To: python-list@python.org, python-list-request@python.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414201665 news.xs4all.nl 2850 [2001:888:2000:d::a6]:51926 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79644 Hi, my name is heba ibrahim abukaff from jordan ,iam a computer information system student at university of jordan . i have a trouble using the tokenizer to find the frequency list for URL using arabic text.and iam using python 2.7.2 on winXP,I tried this code but every time i run the code appears error with first line COULD YOU HELP ME. WITH REGARDS. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 > import re, codecs import nltk from urllib import request url = "http://ar.wikipedia.org/wiki/%D9%85%D9%88%D9%82%D8%B9_%D9%88%D9%8A%D8%A8" response = request.urlopen(url) raw = response.read().decode('utf8') print(raw) import re, codecs import nltk from nltk.probability import * def construct_frequency_list(words): outfile = codecs.open(r'raw.txt' , 'w') fd = nltk.probability.FreqDist() for w in words: fd.inc(w) print "Total number of words: %d Vocbulary size : %d" % (fd.N(), fd.B()) print "word with highest count: %s" % (fd.max()) tokenlist = fd.iteritems() for (key, value) in tokenlist: print>>outfile, "%s\t%d" % (key, value) outfile.close() def read_textfile(raw ): lines = codecs.open(raw ,'r','utf_8').readlines() outfile = codecs.open(r'raw.txt' ,'w','utf_8') counter = 0 wordlist = [] for line in lines: tokens = line.rstrip().lstrip().split() for t in tokens: wordlist.append(t) print>>outfile, '%s\t%d' % (t, len(t)) counter += len(t) outfile.close() return wordlist if __name__ == "__main__": words = read_textfile(r'raw .txt') construct_frequency_list(words) print "Done!"