比如说有两个字符串:
我是一只小花猫
我是一之小花猫这两个字符串相似度大概是92.85请问在Oracle中怎么计算呢,谢谢

解决方案 »

  1.   

    这个需求比较特别,好像以前有人问过关于汉字语义的解释的,学问比较高,oracle是没办法做到的。
      

  2.   

    这个问题确实很有难度;
    我的思路是在Procedure中来实现,将其中一个字符串进行多次分解,然后与第二个字符串进行比较。思路是这样,但是算法很重要。
      

  3.   

    楼主,百度、google肯定能帮到你。
      

  4.   

    --CSDN超级大笨狼。CREATE        function get_semblance_By_2words
    (
    @word1 varchar(50),
    @word2 varchar(50)  
    )
    returns nvarchar(4000)
    as
    begin
    declare @re int
    declare @maxLenth int
    declare @i int,@l int
    declare @tb1 table(child varchar(50))
    declare @tb2 table(child varchar(50))
      set @i=1
    set @l=2
    set @maxLenth=len(@word1)
    if len(@word1)<len(@word2) 
    begin
    set @maxLenth=len(@word2)
    end
    while @l<=len(@word1) 
    begin
    while @i<len(@word1)-1
    begin
    insert @tb1 (child) values( SUBSTRING(@word1,@i,@l) ) 
    set @i=@i+1
    end
    set @i=1
    set @l=@l+1
    end


    set @i=1
    set @l=2


    while @l<=len(@word2) 
    begin
    while @i<len(@word2)-1
    begin
    insert @tb2 (child) values( SUBSTRING(@word2,@i,@l) ) 
    set @i=@i+1
    end
    set @i=1
    set @l=@l+1
    end
     
     select @re=isnull(max( len(a.child)*100/  @maxLenth ) ,0) from @tb1 a, @tb2 b where a.child=b.child
    return @re
    end
     
     
     GO
     
    --测试
    --select dbo.get_semblance_By_2words('我是谁','我是谁啊') 
    --75
    --相似度