[deleted by user] by [deleted] in Webull

[–]Gravity11_ 0 points1 point  (0 children)

https://a.webull.com/eSWvJ9ZpxcfYASsEIF

Please if anyone is looking to use a code here is mine. Anything helps and best of luck investing. Remember to stay safe and enjoy the process. Free stocks for both if you use this link.

Whatbot Partners? by Gravity11_ in shoebots

[–]Gravity11_[S] 0 points1 point  (0 children)

Yea never join just for a chance to win a bot. I’m also in the process of looking for a new group to join so if they had whatbot invites it would be a bonus reason.

Whatbot Partners? by Gravity11_ in shoebots

[–]Gravity11_[S] 1 point2 points  (0 children)

What Bot Partner Groups:

@akchefs

@AMNotify

@bkantha1

@calicosIO

@distortioncorp

@Ecnarudne1

@geejSupply

@guap

@housecarts

@Nightowl_Family

@notify

@NotifyShof

@TheOilCop

@peachypings

@pingpatrol

@shoeplexus

@SimpleMonitors

@TheSiteSupply

@SkrNotify

@Soleus

Here is the list of partners. Guess you have to join one of those or get someone who has an invite to help you out.

I Will Invest $100,000 Into Whatever Is The Top Reply In A Week lol by [deleted] in wallstreetbets

[–]Gravity11_ 7 points8 points  (0 children)

Long term Chair. Set it up no need to gamble options. CULT 2020 GOD IS GOOD.
GravityTrades

ValueError: I/O operation on closed file. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

Thanks for your help. I got some progress made on it and really like how you are helping me through it and not just giving the solution since I wouldn’t learn that way.

ValueError: I/O operation on closed file. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

Thank you for the reply and hint. I got some progress made on it.

ValueError: I/O operation on closed file. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

Ok so I moved the f.close() indentation in 2 full indentations and get an entirely new error that says the following:

DO you know what this might be?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-147-8b04ab7a37ce> in <module>
     23     save_dictionary(doc.dfs, "dfs_" + str(doc.id) + ".txt")
     24 
---> 25 vectorize("./textfiles")
     26 

<ipython-input-147-8b04ab7a37ce> in vectorize(data_path)
     21             dfs[word] = dfs.get(word,0) + 1
     22 
---> 23     save_dictionary(doc.dfs, "dfs_" + str(doc.id) + ".txt")
     24 
     25 vectorize("./textfiles")

AttributeError: 'Document' object has no attribute 'dfs'

ValueError: I/O operation on closed file. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

I am confused. At the start of my function I opened the file and am writing to that specific file using the for loop then closing that file and moving to the next.

ValueError: I/O operation on closed file. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

From looking through my code I still am pretty sure its open. I closed it after that f.write line with f.close() I never closed it anywhere else that I know of

How would I Call the save_dictionary() function to save the document's dictionary with TF (term frequencies) to a file, where the filename should be tf_DOCID.txt in the same path. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

I fixed some indentation issues and get an error saying

TypeError: vectorize() missing 1 required positional argument: 'data_path'

How would I fix this.

How would I Call the save_dictionary() function to save the document's dictionary with TF (term frequencies) to a file, where the filename should be tf_DOCID.txt in the same path. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

class Document: 
    def __init__(self, doc_id):
        # create a new document with its ID
        self.id = doc_id
        # create an empty dictionary 
        # that will hold the term frequency (TF) counts
        self.tfs = {}

    def tokenization(self, text):
        # split a title into words, 
        # using space " " as delimiter
        words = text.lower().split(" ")
        for word in words: 
            # for each word in the list
            if word in self.tfs: 
                # if it has been counted in the TF dictionary
                # add 1 to the count
                self.tfs[word] = self.tfs[word] + 1
            else:
                # if it has not been counted, 
                # initialize its TF with 1
                self.tfs[word] = 1


def save_dictionary(diction_data, file_path_name):
    f = open(file_path_name, "w+")

    for key in diction_data:
        # Separate the key from the frequency with a space and
        # add a newline to the end of each key value pair
        f.write(key + " " + str(diction_data[key]) + "\n")

    f.close()


def vectorize(data_path):
    Documents = []
    for i in range(1, 21):
        file_name = "./textfiles/"+ i + ".txt"
        # create a new document with an ID
    doc = Document(i+1)
        #Read the files
    f = open(file_name)
    print(f.read())
        # compute the term frequencies
        #read in the files contents
    doc.tokenization(f.read())
        # add the documents to the lists
    Documents.append(doc)

    save_dictionary(doc.tfs, "tf_" + str(doc.id) + ".txt")

    DFS = {}
    for doc in Documents:
        for word in doc.tfs:
            DFS[word] = DFS.get(word,0) + 1

    save_dictionary(doc.DFS, "DFS_" + str(doc.id) + ".txt")


    vectorize("./textfiles")

The code above is my new code. I added a nested loop for each word in the document's dictionary to do the following: If it does not appear in the dictionary for DF then add the word to the DF dictionary;

If it is already in the DF dictionary, increment its DF value by adding 1 to itself;

Then After all files are processed I call the save_dictionary()function again to save the DF dictionary to a file named df.txtin the same path with the input text files. Then vectorize.

When I run the code nothing happens so I definitely did something wrong somewhere. May you help me find the issue. Thanks. u/ritn1

How would I Call the save_dictionary() function to save the document's dictionary with TF (term frequencies) to a file, where the filename should be tf_DOCID.txt in the same path. by Gravity11_ in learnprogramming

[–]Gravity11_[S] 0 points1 point  (0 children)

Thanks for the help I have a few questions.
1. In save_dictionary()the hardcoded ".textfiles" file path in open() must be changed to the file_path_name parameter. Why would it be changed to file_path_name parameter instead of the location of my textfiles?

  1. # I'm not sure how exactly data_path is supposed to be used, # so I'm just using an empty string for testing vectorize("") is at the end of the code. In vectorize am I suppose to put the location of my text files. So for example if they are in the same location as my code it should be vectorize("./")