A
A
Al982022-04-10 08:12:36
Python
Al98, 2022-04-10 08:12:36

How to change the emotional coloring of the text?

How can the emotional coloring of the first text be changed to the second? through the algorithm and matrix.
I enter two texts and try to replace the second with the first. So that the program reads each word, skips if there is a word and changes it to another (from the second) if it does not repeat.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seven5674, 2022-04-10
@seven5674

xs of course, did I understand correctly what you want
and the initial conditions are not clear
if it’s stupid in the forehead and with the restrictions that you have, then you can

c = set(text1.split()).difference(set(text2.split()))
for i, w in enumerate(text1.split()):
    if w in c:
        print("{} -> {}".format(w, text2.split()[i]))
    else:
        print(w)

and that
Сергей
сегодня
получил
двойку -> отлично
на
уроке.
Дома
ждет
его
наказание. -> подарок.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question