Re: From JoyceUlysses.txt -- words occurring exactly once

Liste des GroupesRevenir à cl python 
Sujet : Re: From JoyceUlysses.txt -- words occurring exactly once
De : list1 (at) *nospam* tompassin.net (Thomas Passin)
Groupes : comp.lang.python
Date : 05. Jun 2024, 12:10:19
Autres entêtes
Message-ID : <mailman.93.1717699659.2909.python-list@python.org>
References : 1 2 3 4 5 6
User-Agent : Mozilla Thunderbird
On 6/5/2024 12:33 AM, dn via Python-list wrote:
On 31/05/24 14:26, HenHanna via Python-list wrote:
On 5/30/2024 2:18 PM, dn wrote:
On 31/05/24 08:03, HenHanna via Python-list wrote:
>
Given a text file of a novel (JoyceUlysses.txt) ...
>
could someone give me a pretty fast (and simple) Python program that'd give me a list of all words occurring exactly once?
>
               -- Also, a list of words occurring once, twice or 3 times
>
>
>
re: hyphenated words        (you can treat it anyway you like)
>
        but ideally, i'd treat  [editor-in-chief]
                                [go-ahead]  [pen-knife]
                                [know-how]  [far-fetched] ...
        as one unit.
>
>
>
Split into words - defined as you will.
Use Counter.
>
Show some (of your) code and we'll be happy to critique...
>
>
hard to decide what to do with hyphens
                and apostrophes
              (I'd,  he's,  can't, haven't,  A's  and  B's)
>
>
2-step-Process
>
           1. make a file listing all words (one word per line)
>
           2.  then, doing the counting.  using
                               from collections import Counter
  Apologies for lateness - only just able to come back to this.
 This issue is not Python, and is not solved by code!
 If you/your teacher can't define a "word", the code, any code, will almost-certainly be wrong!
  One of the interesting aspects of our work is that we can write all manner of tests to try to ensure that the code is correct: unit tests, integration tests, system tests, acceptance tests, eye-tests, ...
 However, there is no such thing as a test (or proof) that statements of requirements are complete or correct!
(nor for any other previous stages of the full project life-cycle)
 As coders we need to learn to require clear specifications and not attempt to read-between-the-lines, use our initiative, or otherwise 'not bother the ...'. When there is ambiguity, we should go back to the user/client/boss and seek clarification. They are the domain/subject-matter experts...
 I'm reminded of a cartoon, possibly from some IBM source, first seen in black-and-white but here in living-color: https://www.monolithic.org/blogs/presidents-sphere/what-the-customer-really-wants
That one's been kicking around for years ... good job in finding a link for it!

That has been the sad history of programming and dev.projects - wherein we are blamed for every short-coming, because no-one else understands the nuances of development projects.
Of course, we see this lack of clarity all the time in questions to the list.  I often wonder how these askers can possibly come up with acceptable code if they don't realize they don't truly know what it's supposed to do.

If we don't insist on clarity, are we our own worst enemy?
 

Date Sujet#  Auteur
30 May 24 * From JoyceUlysses.txt -- words occurring exactly once28HenHanna
30 May 24 +* Re: From JoyceUlysses.txt -- words occurring exactly once15dn
31 May 24 i`* Re: From JoyceUlysses.txt -- words occurring exactly once14HenHanna
1 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Peter J. Holzer
1 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Thomas Passin
5 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1dn
5 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Grant Edwards
5 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Thomas Passin
7 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Mats Wichmann
8 Jun 24 i +* Re: From JoyceUlysses.txt -- words occurring exactly once2Larry Martell
8 Jun 24 i i`- Re: From JoyceUlysses.txt -- words occurring exactly once1Stefan Ram
8 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Thomas Passin
8 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1<avi.e.gross
8 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Thomas Passin
9 Jun 24 i +- Re: From JoyceUlysses.txt -- words occurring exactly once1<avi.e.gross
9 Jun 24 i `- Re: From JoyceUlysses.txt -- words occurring exactly once1Grant Edwards
31 May 24 +* Re: From JoyceUlysses.txt -- words occurring exactly once2Pieter van Oostrum
31 May 24 i`- Re: From JoyceUlysses.txt -- words occurring exactly once1Grant Edwards
31 May 24 +- Re: From JoyceUlysses.txt -- words occurring exactly once1dieter.maurer
31 May 24 +- Re: From JoyceUlysses.txt -- words occurring exactly once1Thomas Passin
1 Jun 24 `* Re: From JoyceUlysses.txt -- words occurring exactly once8Mats Wichmann
3 Jun 24  `* Re: From JoyceUlysses.txt -- words occurring exactly once7Edward Teach
3 Jun 24   +* Re: From JoyceUlysses.txt -- words occurring exactly once5Grant Edwards
4 Jun 24   i`* Re: From JoyceUlysses.txt -- words occurring exactly once4Edward Teach
4 Jun 24   i +- Re: From JoyceUlysses.txt -- words occurring exactly once1Grant Edwards
4 Jun 24   i +- Re: From JoyceUlysses.txt -- words occurring exactly once1<avi.e.gross
5 Jun 24   i `- Re: From JoyceUlysses.txt -- words occurring exactly once1Chris Angelico
4 Jun 24   `- Re: From JoyceUlysses.txt -- words occurring exactly once1dieter.maurer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal