(Correction) The problem of data disappearing when code is executed to delete the term

Asked 2 years ago, Updated 2 years ago, 95 views

Hi, everyone Through the what I asked earlier, I was able to correct the disused term deletion code and get the result of actually deleting the disused term.

But when I turned the code, I found that when I deleted the term, more than half of the data was lost.

I'll show you the chords.

If you run it up to here, you'll see that the tokenized_list has 1800 lines of data. Below is the result.

Continue executing the code.

Right below is the code for the deletion of the term.

If print (clean_words[991]) is executed here,

The 991st data says no, and even when you actually save the result, only the 990th data is stored. The rest of the data seems to have been lost.

How do I modify the code?

jupyter-notebook konlpy text-mining

2022-09-20 08:56

1 Answers

# What you are doing and what you are explaining
a = [
[1,23,34],
[2,3,4,5]
]
b = [2]
c = []
for i in a:
    z = 0
    for ii in b:
        if ii in i:
            z += 1
    if z < 1:
        c.append(i)
# Maybe what you want
a = [
[1,23,34],
[2,3,4,5]
]
b = [2]
c = []
for i in a:
    for ii in b:
        if ii in i:
            i.remove(ii)
    c.append(i)


2022-09-20 08:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.