Typing tutor help script needed, please

Discussion in 'Perl Misc' started by Throw, Oct 28, 2005.

  1. Throw

    Throw Guest

    G'day everyone!

    I would like to design typing tutor exercises for Afrikaans (and other
    languages possibly). This is for a GPL project. For this, I need a
    script that can extract words from a long list of words, based on which
    letters those words contain, and write then write output to a file.
    Does anyone know of an existing script for this, or can anyone write me
    one, please?

    Preferably I must be able to extract words which contain only certain
    letters (they need not contain all of those letters, but they may not
    contain any other letters). It would be nice if I can also extract
    words which do not contain certain letters.

    Any help will be greatly appreciated. I'm on a Windows 2000 machine
    with Perl, Python, Tcl/Tk and Java.

    Thanks!
    Samuel (throw aka voetleuce aka leuce)
     
    Throw, Oct 28, 2005
    #1
    1. Advertising

  2. "Throw" <> wrote in
    news::

    [ List of newsgroups trimmed. Follow-ups set. ]

    > I would like to design typing tutor exercises


    Then, by all means, do design it.

    As it stands, you are asking us to come up with an algorithm, and write an
    implementation of it.

    The fact that you posted to both Python and Perl groups should have been
    enough of a clue to you that your question was about neither.

    You might want to try comp.programming for this type of question. If,
    and/or when, you decide to write the program in Perl, please read the
    posting guidelines for this group before posting here.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 28, 2005
    #2
    1. Advertising

  3. #---Input data

    #List of words; every word or sentence on one line
    #If from file: WORDS = open(fileName).readlines()
    WORDS = """\
    Afrikaans
    Anna
    Bread
    red
    word
    bored
    python""".split('\n')

    #---Main program
    import re

    PATTERN = ['[^(%s)]+','[%s]+']
    FILENAME = ['not_%s.txt','%s.txt']

    def filter(letters='bdeor',words=WORDS,contain=True,ignoreCase=True):
    pattern = PATTERN[contain]%'|'.join(list(letters))
    if ignoreCase:
    allowed = re.compile(pattern,re.IGNORECASE)
    else:
    allowed = re.compile(pattern)
    result = []
    for word in words:
    match = allowed.match(word)
    if match and match.group(0) == word: result.append(word)
    print result
    output = open(FILENAME[contain]%letters,'w')
    output.write('\n'.join(result))
    output.close()



    if __name__ == '__main__':
    filter()

    ---------------
    This should do it.

    Stani
    --
    http://pythonide.stani.be
    http://pythonide.stani.be/manual/html/manual.html
     
    SPE - Stani's Python Editor, Oct 28, 2005
    #3
  4. Throw

    Anno Siegel Guest

    Throw <> wrote in comp.lang.perl.misc:
    >
    > G'day everyone!
    >
    > I would like to design typing tutor exercises for Afrikaans (and other
    > languages possibly). This is for a GPL project. For this, I need a
    > script that can extract words from a long list of words, based on which
    > letters those words contain, and write then write output to a file.
    > Does anyone know of an existing script for this, or can anyone write me
    > one, please?


    For the letters a, d, f and g:

    perl -ne 'print if /^[adfg]+$/' < /list/of/words > words_with_adfg

    For other combinations, change both occurrences of "adfg".

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
     
    Anno Siegel, Oct 28, 2005
    #4
  5. <reinstated the context that was omitted by SPE>

    > Throw wrote:
    >> I must be able to extract words which contain only
    >> certain letters (they need not contain all of those letters,
    >> but they may not contain any other letters).


    SPE - Stani's Python Editor wrote:
    > #---Input data
    >
    > #List of words; every word or sentence on one line
    > #If from file: WORDS = open(fileName).readlines()
    > WORDS = """\
    > Afrikaans
    > Anna
    > Bread
    > red
    > word
    > bored
    > python""".split('\n')
    >
    > #---Main program
    > import re
    >
    > PATTERN = ['[^(%s)]+','[%s]+']
    > FILENAME = ['not_%s.txt','%s.txt']
    >
    > def filter(letters='bdeor',words=WORDS,contain=True,ignoreCase=True):
    > pattern = PATTERN[contain]%'|'.join(list(letters))
    > if ignoreCase:
    > allowed = re.compile(pattern,re.IGNORECASE)
    > else:
    > allowed = re.compile(pattern)
    > result = []
    > for word in words:
    > match = allowed.match(word)
    > if match and match.group(0) == word: result.append(word)
    > print result
    > output = open(FILENAME[contain]%letters,'w')
    > output.write('\n'.join(result))
    > output.close()
    >
    >
    >
    > if __name__ == '__main__':
    > filter()
    >
    > ---------------
    > This should do it.
    >


    Am I underestimating the task, it looks simple enough for the simplest grep?

    # perl -n -e "print if /^[bdeor]+$/i" words.txt
    red
    bored
     
    RedGrittyBrick, Oct 28, 2005
    #5
  6. Throw

    Throw Guest

    [Posting from Google, hence non-compliance to posting netiquette]

    A. Sinan Unur wrote:

    > ... please read the

    posting guidelines for this
    > group before posting here.


    Will http://www.faqs.org/faqs/perl-faq/part2/ suffice? Or do you have
    a different, more restrictive FAQ in mind? AFAIK my initial post was
    not contrary to the posting guidelines for this group.

    Besides, I had hoped that my subject line should have made it clear
    that I'm a non-programmer looking for a kind volunteer to write a
    script for me to use without me having to learn scripting. Did I fail
    in that? If so, tell me how I should have structured my subject line
    better, please.

    > The fact that you posted to both Python and Perl groups
    > should have been

    enough of a clue to you that
    > your question was about neither.


    I think the fact that I included the word "wanted" in the in the
    subject line should also have been a clue that I'm not asking a
    question about the language, but that I'm requesting something in the
    language. Again, if I have failed in that, please tell me how you
    would have done it, and perhaps I can learn from you, yes?

    I'll respond to the other posts once I have a proper newsreader
    configured... I hate it that you can't do proper replies with Google
    Groups.
     
    Throw, Oct 29, 2005
    #6
  7. Throw

    Guest

    Throw <> wrote:
    > A. Sinan Unur wrote:


    >> ... please read the

    > posting guidelines for this
    >> group before posting here.


    > Will http://www.faqs.org/faqs/perl-faq/part2/ suffice? Or do you have
    > a different, more restrictive FAQ in mind? AFAIK my initial post was
    > not contrary to the posting guidelines for this group.


    Obviously you have not read the posting guidelines.

    Try:

    http://www.theone.ru/lists/comp.lang.perl.misc/msg00208.html

    > Besides, I had hoped that my subject line should have made it clear
    > that I'm a non-programmer looking for a kind volunteer to write a
    > script for me to use without me having to learn scripting. Did I fail
    > in that? If so, tell me how I should have structured my subject line
    > better, please.


    Most people here earn their living from writing programmes... why
    do you expect to have one written for you for free?

    >> The fact that you posted to both Python and Perl groups
    >> should have been

    > enough of a clue to you that
    >> your question was about neither.


    > I think the fact that I included the word "wanted" in the in the
    > subject line should also have been a clue that I'm not asking a
    > question about the language, but that I'm requesting something in the
    > language. Again, if I have failed in that, please tell me how you
    > would have done it, and perhaps I can learn from you, yes?


    No, you did not include the 'wanted' in your subject line.

    Axel
     
    , Oct 29, 2005
    #7
  8. Throw <> wrote:


    > I'm a non-programmer looking for a kind volunteer to write a
    > script for me



    Job postings are off-topic in discussion newsgroups.

    There are other forums for job offerings, such as:

    http://jobs.perl.org


    > I think the fact that I included the word "wanted" in the in the
    > subject line



    You did not include the word "wanted" in the subject line.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Oct 29, 2005
    #8
  9. "Throw" <> wrote in news:1130566762.105930.119110
    @g44g2000cwa.googlegroups.com:

    > [Posting from Google, hence non-compliance to posting netiquette]
    >
    > A. Sinan Unur wrote:
    >
    >> ... please read the posting guidelines for this
    >> group before posting here.

    >
    > Will http://www.faqs.org/faqs/perl-faq/part2/ suffice? Or do you have
    > a different, more restrictive FAQ in mind? AFAIK my initial post was
    > not contrary to the posting guidelines for this group.


    Searching Google for

    comp.lang.perl.misc guidelines

    would yield

    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

    This URL is also given in my signature.

    > Besides, I had hoped that my subject line should have made it clear
    > that I'm a non-programmer looking for a kind volunteer to write a
    > script


    This is not the place for that.

    http://jobs.perl.org/

    >> The fact that you posted to both Python and Perl groups
    >> should have been enough of a clue to you that your question
    >> was about neither.

    >
    > I think the fact that I included the word "wanted" in the in the


    Really?

    > I'll respond to the other posts once I have a proper newsreader
    > configured... I hate it that you can't do proper replies with Google
    > Groups.


    You definitely *can* compose proper replies with Google Groups.

    Sinan
    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Oct 30, 2005
    #9
  10. Throw

    Guest

    A. Sinan Unur wrote:
    > You definitely *can* compose proper replies with Google Groups.


    True. I'm stuck with Google most of the time because of corporate
    firewalls. But I've replied to many posts, and have yet to be flamed
    for an improperly formatted reply (a stupid reply, yes, but not an
    improperly formatted one). But you are encouraged to use other (better)
    readers if possible.

    --
    http://DavidFilmer.com
     
    , Oct 31, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    595
    Big Brian
    Oct 14, 2003
  2. Throw
    Replies:
    4
    Views:
    388
    RedGrittyBrick
    Oct 28, 2005
  3. vbgunz
    Replies:
    2
    Views:
    332
    vbgunz
    May 13, 2008
  4. JimLad
    Replies:
    0
    Views:
    499
    JimLad
    Jan 26, 2010
  5. Justin brainy
    Replies:
    4
    Views:
    179
    Shadowfirebird
    Mar 10, 2011
Loading...

Share This Page