Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class and methods
#1
I have this code but it doesn't seem to work.

class textanalysis(object):
    
Class Analysis(object):   
  def _init_(self, text):
        #enlever la ponctuation
        formater = text.replace(',','').replace('.','').replace('!','').replace('?','')
        #transformer en minuscule
        formater = formater.lower()
        self.fmt = formater
        
    def freqall(self):
        mots = self.fmt.split(' ')
        #creer un dictionnaire
        dico = {}
        
        for word in set(mots):    #set est utiliser pour qu'il n'y ait pas de repetitions
            dico[word] = self.fmt.count(word)
            
            return dico
        
    def freq0f(self, word):
        freqdico = self.freqall()
        if word in freqdico:
            return frqdico[word]
        else:
            return 0
If I enter a text, I receive an error:
Error:
" TypeError: textanalysis() takes no arguments "
Anyone can help me fix the error?
Thanks
Output:
buran write May-12-2024, 06:26 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
Class and methods - by Saida2024 - May-12-2024, 02:09 AM
RE: Class and methods - by ebn852_pan - May-12-2024, 07:21 AM
RE: Class and methods - by deanhystad - May-13-2024, 04:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Class and methods ebn852_pan 15 1,061 May-23-2024, 11:57 PM
Last Post: ebn852_pan
  Class test : good way to split methods into several files paul18fr 4 678 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  Structuring a large class: privite vs public methods 6hearts 3 1,280 May-05-2023, 10:06 AM
Last Post: Gribouillis
  access share attributed among several class methods drSlump 0 1,145 Nov-18-2021, 03:02 PM
Last Post: drSlump
  a function common to methods of a class Skaperen 7 2,869 Oct-04-2021, 07:07 PM
Last Post: Skaperen
  Listing All Methods Of Associated With A Class JoeDainton123 3 2,478 May-10-2021, 01:46 AM
Last Post: deanhystad
  too many methods in class - redesign idea? Phaze90 3 2,647 Mar-05-2021, 09:01 PM
Last Post: deanhystad
  Special Methods in Class Nikhil 3 2,487 Mar-04-2021, 06:25 PM
Last Post: Nikhil
  cant able to make methods interact with each other in the class jagasrik 2 1,940 Sep-16-2020, 06:52 PM
Last Post: deanhystad
  Question about naming variables in class methods sShadowSerpent 1 2,113 Mar-25-2020, 04:51 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020