![]() |
| ||
| How to sort word (from file) frequancy in decrease order? I need help I wont to find most 10 frequency word of specific file for that I have written this code import sys but it only get the word and its frequency sample output Quote:
and its read the file again and again. also it did not sort the output as you can see how I can sort output in decrease order to be able to stop print after 10 words? please help me ASAP |
| ||
| Re: How to sort word (from file) frequancy in decrease order? I need help There are mistakes like your last line should be i = i + 1. Also string functions are builtin since version 2.2, module re is not needed. Here is one way to do this with version 2.5 # count words in a text and show the first ten items |
| ||
| Re: How to sort word (from file) frequancy in decrease order? I need help thank you very much it was very helpfull but is there way to control number of word to be enter by user like rather than most 10 frequancy word he can enter 11 , 50 or 44 most frequancy word ..etc and can I remove the marks like (? "" [] ) ..etc ineed only words and can python bult user interfac (buttun ,text box etc) and how ? if not how can I ingreat cod to be user interfac (buttun ,text box etc) |
| ||
| Re: How to sort word (from file) frequancy in decrease order? I need help ... can I remove the marks like (? "" [] ) .. etc ineed only words Instead of word = word.rstrip('.,') use word = word.rstrip('.,?"[]()') ... control number of word to be enter by user Where you now have if n < 10: use if n < select: where variable select is an integer from the user's input ... can python bult user interfac (buttun ,text box etc) and how ? Python has a simple GUI toolkit called Tkinter supplied that can do all that for you. You need to study up on that, it's a whole new ball of wax. Here would be a typical example: # a look at the Tkinter Text widget |
| ||
| Re: How to sort word (from file) frequancy in decrease order? I need help your reply was so helpful but how can I make an integer from the user's input (select)? Is python provide search in directory file contain subfile and folder for example file name is cars and subfile is Toyota,Honda and BMW and Toyota conain folder name camry and corola, honda contain accord and BMW contan folder name X5 Is there way to enter name of parent file(cars) and search in all sub file(Toyota,Honda and BMW)? |
| ||
| Re: How to sort word (from file) frequancy in decrease order? I need help 1 Attachment(s) this is modify code # a look at the Tkinter Text widget but unfortinatly when I wont to search in (not English text) for example (Arabic) file it will not read it probably it print text like 3ÇáäíÇÈÉ 28Ýí 11Úáì 11ÊÜÊÜãÜÉ 10ãä 10Úä 7Ãä 6ÈÓÈÈ 5ÎÈÑ 5ÇáãÓáãæä the sample file in attach I use text1.insert(tk.INSERT, freq) to inset to the text pleas I need your help for this and previous one |
| All times are GMT -4. The time now is 2:09 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC