Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
86 views
in Technique[技术] by (71.8m points)

python - Extract Sentences from A String

I am working on a machine learning chatbot project which uses google's speech recognition api.

Now my problem is, when I say 2 or more sentences in one command, speech recognition api returns all sentences in one string, without any fullstop or commas. As a result, it has become harder to seperate sentences. For example, if I say,

Take a photo. Tell me about today's weather. Open Google Chrome.

the speech recognition api returnes: take a photo tell me about todays weather open Google Chrome

so, my chatbot takes this full string as one sentence.

Is there any way to extract sentences from a string like the one above?

(BTW, I am using Python)

question from:https://stackoverflow.com/questions/66058940/extract-sentences-from-a-string

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are about to say multiple commands say words like "and" and split the command based on that word. Now loop through the list and pass each value to your execute function.

If the variable command stores your value split it using command.split(" and ")

I had previously answered a similar question take a look at it: https://stackoverflow.com/a/65872940/12279129


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...