0

I want to write a program where the user decides whether or not two sentences are similar.

I already made some comparisons with word embeddings and cosine similarity. Now, the user should look through the results of the cosine similarity and decide whether these sentences are really so similar like the automatic comparison suggests.

I cannot find any tool or library that is designed for this and standard input doesn't let me do what I want.

This is what I want to do:

potential_similars = [(sent1, sent2), (sent3, sent4), (sent5, sent6), (sent6, sent8)]
approved_simil = []
not_approved_simil = []
for tup in potential_similars:
  query = input("should " , tup[0], " and ", tup[1], " be regarded as similar? Type Y if yes and N otherwise")
  if query == "Y":
    approved_simil.append(tup)
  elif query == "N":
    not_approved_simil.append(tup)
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
dumbchild
  • 275
  • 4
  • 11
  • 3
    And what's the _problem_ with what you've posted? I guess `TypeError: input expected at most 1 argument...`, in which case did you research that? Have you read e.g. https://stackoverflow.com/q/43243627/3001761? – jonrsharpe Mar 10 '21 at 09:34
  • 1
    `query = input(f"should {tup[0]} and {tup[1]} be regarded as similar? Type Y if yes and N otherwise")` – balderman Mar 10 '21 at 09:36
  • 1
    "standard input doesn't let me do what I want." What exactly is it that you want `input` to do? What happens when you try to run the code, and how is that different from what you want to happen? – Karl Knechtel Mar 10 '21 at 09:37
  • 1
    In your own words, when you write something like `input(x, y, z)`, what do you think the commas mean? What do you want them to mean? Is this perhaps based off of how you use them somewhere else, for example, when you call `print`? – Karl Knechtel Mar 10 '21 at 09:38
  • thank you all, I didnt realize it was as simple as that – dumbchild Mar 10 '21 at 09:47

1 Answers1

1

input just wants one string. Join the strings together before passing them to the input:

query = input("".join(("should " , tup[0], " and ", tup[1], " be regarded as similar? Type Y if yes and N otherwise")))
don-joe
  • 600
  • 1
  • 4
  • 12