1

I use the pipeline in python to translate reviews into the English language using this instruction

translated = pipe(reviews['review'][0])

And the result was a list:

[{'translation_text': '“Excellent”. Cleanliness and helpful staff.'}]

I want only this part '“Excellent”. Cleanliness and helpful staff.' to be printed.

how can I do it?

1 Answer 1

1

You can index into the list and dictionary -- accessing the first element using [0], and accessing the sole value of the dictionary using ['translation_text']:

translated = pipe(reviews['review'][0])[0]['translation_text']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.