How to scan a user-input sentence/phrase for the individual words

조회 수: 2 (최근 30일)
I'm writing a text to speech program in the Malay Language for a project. I have created a GUI with an editbox for the user-input. For starters, how do I scan the user-input sentence for words?
Using these words, I will match them with their corresponding *.wav file from a database of Malay words (Malay is written with English alphabets too)

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 27일
A rudimentary way as a starter
InputText='This is is my testing speech.';
Words=textscan(InputText,'%s');
Words{:}
  댓글 수: 2
Jan Donyada
Jan Donyada 2011년 8월 27일
InputText='This is is my testing speech.';
Words=textscan(InputText,'%s');
Words{:}
what does the last line do?
Fangjun Jiang
Fangjun Jiang 2011년 8월 27일
The last line just shows you the result in Command Window, in case you are not familiar with the cell array referencing (using {} instead of ()). The first word will be in Words{1}, second words in Words{2}, etc.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Chaowei Chen
Chaowei Chen 2011년 8월 27일
Just a subtle improvement to Jiang's approach. (To get rid of the period symbol)
InputText='This is is my testing speech.';
Words2=regexp(InputText,'\w*','match')
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2011년 8월 27일
Agree! There are many other things to be taken care of too, like InputText='This''s my testing speech.'.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by