Prev: How to create a 3D matrix based on the vectors of X,Y,Z?
Next: Problem using SVM (support vector machines) different methods
From: Sandy S on 1 Mar 2010 02:22 roberson(a)ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message <fg8p0j$fi9$1(a)canopus.cc.umanitoba.ca>... > In article <fg8ljd$dq1$1(a)fred.mathworks.com>, > Lauren D <ld(a)mathworks.com> wrote: > >I have to remove all punctuation and spaces from a sentence. > >I'm using a for loop and if statement to do the removal. Is > >there a function to remove all spaces in a string? If not > >what is the statement to check if a string location is ~= to > >a space? How do you specify a space in a statement? > > stringname(ismember(stringname,' ,.:;!')) = []; > > This assumes that - is not considered punctuation, which is > debatable: the m-dash could probably be legitimately considered > punctuation, but you would have to find the unicode for that > if you wanted to distinguish it from the hyphen and n-dash; > then you also have the problem that the m-dash is sometimes > rendered in ascii as a double-hyphen, and if you are processing > such text you'd want that to be punctuation but not single dashes... > > The above also assumes that brackets and braces and the various > quotation marks are not considered punctuation, nor the backslash > and not the solidus. > > You might also wish to consider investigating the isspace() > function. > > -- > "Beware of bugs in the above code; I have only proved it correct, > not tried it." -- Donald Knuth Thanks dude...That was helpful!! -SANDEEP. |