asp 的 分词实现代码

2018-10-15 17:06

阅读:670

<%
a=日本是中国的一个省我们美丽中国的张家界!
b=中国,我们,张家界,日本,美国,苹果
b=split(b,,)
a=split(a,)
fork=0toubound(a)
s=
n=
fori=0toubound(b)
ifinstr(a(k),b(i))>0then
s=s&instr(a(k),b(i))&,&instr(a(k),b(i))+len(b(i))&,
endif
next
s=left(s,len(s)-1)
ifleft(s,len(s)-1)<>len(a(k))thens=s&,&len(a(k))+1
s=sort(split(s,,))
fori=0toubound(s)-1
n=n&mid(a(k),s(i),s(i+1)-s(i))&
next
response.writen&<br>
next

functionsort(ary)
ck=true
doUntilck=false
ck=false
Forf=0toUBound(ary)-1
ifclng(ary(f))>clng(ary(f+1))then
v1=clng(ary(f))
v2=clng(ary(f+1))
ary(f)=v2
ary(f+1)=v1
ck=true
endif
next
loop
sort=ary
endfunction
%>


运行结果

日本是中国的一个省
我们美丽中国的张家界!


评论


亲,登录后才可以留言!