how to remove (.) from strings in matlab

15 Ansichten (letzte 30 Tage)
hiba rashed
hiba rashed am 16 Dez. 2016
Kommentiert: Image Analyst am 18 Dez. 2016
about classify text document
  5 Kommentare
John BG
John BG am 17 Dez. 2016
have you tried
L=I{1}
L(L=='.')=[]
Image Analyst
Image Analyst am 18 Dez. 2016
Are you sure you don't want to do something like
str = 'I live in a city called hilla this city located in.the center of iraq it is not too large hilla contain many resturants in here road.these resturants make very good and delicious food.one of city that near by called najaf'
dotLocations = find(str == '.')
% Assume tos are periods - end of sentence.
% Make sure the next character is Capitalized
str(dotLocations+1) = upper(str(dotLocations+1))
% Now replace dot with dot space since sentences
% don't start immediately after a period.
str = strrep(str, '.', '. ')
% Make sure the string ends with a period.
if ~strcmp(strtrim(str(end)), '.')
% Get rid of leading and trailing spaces and end with a period.
str = [strtrim(str), '.']
end
Now there are some places where you have a period at places that don't make grammatical sense, like 'in.the' but unless you want to put in a grammar analyzer, it's not possible to know whether to remove that period or replace it with a space.
Same problem for where period are totall missing, like 'of iraq it is not'. Only a full grammatical analysis would know that it's supposed to be 'of iraq. It is not' and to add the period and capitalize the next sentence.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephen23
Stephen23 am 16 Dez. 2016
Use strrep, which is designed to perform the task that you want:
>> str = '.Hello.World.';
>> strrep(str,'.','')
ans = HelloWorld
  7 Kommentare
hiba rashed
hiba rashed am 17 Dez. 2016
Bearbeitet: Stephen23 am 17 Dez. 2016
I have text but it doesn't work this is the code
I = textscan(f,'%s',100);
strrep(I{1},'.','');
I contain this:
I live in a city called hilla
this city located in.the center of iraq
it is not too large hilla contain many resturants
in here road.these resturants make very good and delicious
food.one of city that near by called najaf.
Stephen23
Stephen23 am 17 Dez. 2016
Bearbeitet: Stephen23 am 17 Dez. 2016
@hiba rashed: try something like this:
I = strrep(I{1},'.',' ')
I(end) = '.'

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

John BG
John BG am 16 Dez. 2016
do you mean this?
L='1.- Telegraph http://www.telegraph.co.uk/news/2016/12/13/spain-plans-replace-nazi-time-zone-gmt/';
>> L(L=='.')=[]
L =
1- Telegraph http://wwwtelegraphcouk/news/2016/12/13/spain-plans-replace-nazi-time-zone-gmt/
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by