For example, if there's a repeating word like "Bob is American. I know a lot of American people. I love them." I know how to print out the first American word that appears when you type in "American 2", but now I know a little bit
How to output the front and back words of all overlapping words as shown in
It's impossible to solve the problem of printing within a sentence unit with a word like this. (I want to solve it without using nltk.))
It's not enough, but I'm attaching the code I wrote.
n = "Bob is American. I know a lot of American people. I love them"
for x in n :
w, num = input ("lowercase letters") and numbers in order with spaces.\n").split()
num = int(num)
N = str(num)
if w not in n:
print("Not found")
else:
for i in N:
i = int(i)
if i < 2:
before_w = n[n.index(w)-1]
after_w = n[n.index(w)+1]
b_w = before_w
a_w = after_w
result = '{0} / {1} / {2}'.format(b_w, w, a_w)
print(result)
else:
b_w = n[n.index(w)-i : n.index(w)]
a_w = n[n.index(w)+1 : n.index(w)+i+1]
b_w = " ".join(b_w)
a_w = " ".join(a_w)
result = '{0} / {1} / {2}'.format(b_words, word, a_words)
print(result)
Thank you so much for reading the long question.
python
860 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 PHP ssh2_scp_send fails to send files as intended
563 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
587 Uncaught (inpromise) Error on Electron: An object could not be cloned
562 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.