Demo entry 6745740

main

   

Submitted by anonymous on May 27, 2018 at 17:07
Language: Matlab. Code size: 553 Bytes.

1.	function [wordnum, sentnum] = stranalyze(str)  
2.	B = isstrprop(str,'alpha');  
3.	len=length(B);  
4.	sentnum=0;  
5.	wordnum=0;  
6.	flag_Old = 0;  
7.	flag_Pre = 0;  
8.	for i=1:len  
9.	   if isletter(str(i)) || str(i)=='-'  
10.	       flag_Pre=1;  
11.	   else  
12.	       flag_Pre=0;  
13.	   end  
14.	   if flag_Old==1 && flag_Pre==0  
15.	       wordnum=wordnum+1;  
16.	   end  
17.	   flag_Old=flag_Pre;  
18.	   if str(i)=='!' || str(i)=='.' || str(i)=='?'  
19.	        sentnum=sentnum+1;  
20.	   end
21.	   end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).