python

A

anica_1069

hello, I¢¥m a student of linguistic an I need do this exercises. Can
anybody help me,please?
Thanks


¢Å Read in some text from a corpus, tokenize it, and print the list of
all wh-word types that occur. (wh-words in English are used in
questions, relative clauses and exclamations: who, which, what, and so
on.) Print them in order. Are any words duplicated in this list,
because of the presence of case distinctions or punctuation?

¢Å Create a file consisting of words and (made up) frequencies, where
each line consists of a word, the space character, and a positive
integer, e.g. fuzzy 53. Read the file into a Python list using open
(filename).readlines(). Next, break each line into its two fields
using split(), and convert the number into an integer using int(). The
result should be a list of the form: [['fuzzy', 53], ...].
 
A

Andre Engels

We may be willing to help you with your homework, but we will not be
doing it for you. Please tell us what you have got (whether it be a
non-working a program, a partial program or just some ideas about what
you might need to do) and what you think is stopping you from getting
further.

2009/5/15 said:
hello, I´m a student of linguistic an I need do this exercises. Can
anybody help me,please?
Thanks


â—‘ Read in some text from a corpus, tokenize it, and print the list of
all wh-word types that occur. (wh-words in English are used in
questions, relative clauses and exclamations: who, which, what, and so
on.) Print them in order. Are any words duplicated in this list,
because of the presence of case distinctions or punctuation?

â—‘ Create a file consisting of words and (made up) frequencies, where
each line consists of a word, the space character, and a positive
integer, e.g. fuzzy 53. Read the file into a Python list using open
(filename).readlines(). Next, break each line into its two fields
using split(), and convert the number into an integer using int(). The
result should be a list of the form: [['fuzzy', 53], ...].
 
M

Mike Driscoll

hello, I¢¥m a student of linguistic an I need do this exercises. Can
anybody help me,please?
Thanks

¢Å Read in some text from a corpus, tokenize it, and print the list of
all wh-word types that occur. (wh-words in English are used in
questions, relative clauses and exclamations: who, which, what, and so
on.) Print them in order. Are any words duplicated in this list,
because of the presence of case distinctions or punctuation?


This requires learning file I/O and some string manipulation
techniques. I would probably read each line, split on spaces and then
loop over each word and check for "wh" and add them to a new list.
After reading the file, you'd then use a sort to get them in the right
order.
¢Å Create a file consisting of words and (made up) frequencies, where
each line consists of a word, the space character, and a positive
integer, e.g. fuzzy 53. Read the file into a Python list using open
(filename).readlines(). Next, break each line into its two fields
using split(), and convert the number into an integer using int(). The
result should be a list of the form: [['fuzzy', 53], ...].

I recommend reading the Python Tutorial: http://python.org/doc/

If you're using Python 2.x, then check out http://www.diveintopython.org/

If you're using 3.0, your primary options are the online docs and
"Programming in Python 3" by Summerfield.

- Mike
 
R

Rhodri James

hello, I´m a student of linguistic an I need do this exercises. Can
anybody help me,please?
Thanks

Sorry, we're allergic to homework. If you've got any more specific
questions about how bits of Python work, do ask, but don't ask us to
do your assignments for you. Most tutors can get downright unreasonable
about that sort of thing.
â—‘ Read in some text from a corpus, tokenize it, and print the list of
all wh-word types that occur. (wh-words in English are used in
questions, relative clauses and exclamations: who, which, what, and so
on.) Print them in order. Are any words duplicated in this list,
because of the presence of case distinctions or punctuation?

Some questions you should already have the answers to:

* How do you identify wh-words? I'm guessing for the purposes of
this assignment you've got a list of them. If that's so, look up the
bit of the tutorial about finding out whether something is in a list.
If you have to parse for them, that's a rather harder problem.

* ...but beware of case distinctions -- look up the string methods to
see how to play with the case of a string.

* Tokenizing the string is just a matter of splitting it up where there
are spaces or punctuation. Funnily enough, there's this string method
called "split()" that will do this.

* What does "in order" mean? In the order in which they occur in the
corpus? In alphabetical order? If it's the latter, you'll need to
record the wh-words when they occur in a list and sort it at the end
before printing it out.
â—‘ Create a file consisting of words and (made up) frequencies, where
each line consists of a word, the space character, and a positive
integer, e.g. fuzzy 53. Read the file into a Python list using open
(filename).readlines(). Next, break each line into its two fields
using split(), and convert the number into an integer using int(). The
result should be a list of the form: [['fuzzy', 53], ...].

So you do that. Seriously, this is a pretty complete recipe already.
If you can't see how to do it, re-read the tutorial.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top