Search
 
SCRIPT & CODE EXAMPLE
 

C

levenshtein c

 entier DistanceDeLevenshtein(caractere chaine1[1..longueurChaine1],
                              caractere chaine2[1..longueurChaine2])
   // D est un tableau de longueurChaine1+1 rangées et longueurChaine2+1 colonnes
   // D est indexé à partir de 0, les chaînes à partir de 1
   déclarer entier D[0..longueurChaine1, 0..longueurChaine2]
   // i et j itèrent sur chaine1 et chaine2
   déclarer entier i, j, coûtSubstitution
 
   pour i de 0 à longueurChaine1
       
  
    
      
        D
        [
        i
        ,
        0
        ]
        ]
        :=
        i
      
    
    {displaystyle D[i,0]]:=i}
  
{displaystyle D[i,0]]:=i}
   pour j de 0 à longueurChaine2
       
  
    
      
        D
        [
        0
        ,
        j
        ]
        ]
        :=
        j
      
    
    {displaystyle D[0,j]]:=j}
  
{displaystyle D[0,j]]:=j}
 
   pour i de 1 à longueurChaine1
      pour j de 1 à longueurChaine2
          si chaine1[i] = chaine2[j] alors coûtSubstitution := 0
          sinon coûtSubstitution:= 1    
          
  
    
      
        D
        [
        i
        ,
        j
        ]
        ]
        :=
      
    
    {displaystyle D[i,j]]:=}
  
{displaystyle D[i,j]]:=} minimum(
             D[i-1, j  ] + 1,                 // effacement du nouveau caractère de chaine1
             D[i,   j-1] + 1,                 // insertion dans chaine2 du nouveau caractère de chaine1
             D[i-1, j-1] + coûtSubstitution   // substitution
          )
 
   renvoyer D[longueurChaine1, longueurChaine2]
Comment

PREVIOUS NEXT
Code Example
C :: unity read text file line by line 
C :: write varriable in file C 
C :: #include <stdio.h int main() { int x = 10, *y, **z; y = &x; z = &y; printf(""%d %d %d"", *y, **z, *(*z)); return 0; } 
C :: C programming statician 
C :: or gmode inline image 
C :: convert integer to float in c 
C :: C How to use enums for flags? 
C :: terrenery opertori with return in c 
C :: pygraphviz show 
C :: sort vectors c 
C :: changing an item in an array in c 
C :: aws solution architect vs developer associate 
C :: how to stop scanf from adding a new line in c 
C :: print name of file argv c 
Dart :: flutter listtile shape 
Dart :: asset image in circle avatar flutter 
Dart :: flutter label align top 
Dart :: rupee icon in flutter 
Dart :: hide keyboard flutter 
Dart :: FirebaseOptions cannot be null when creating the default app 
Dart :: Flutter - BoxShadow Widget 
Dart :: int to char dart 
Dart :: flutter remove map 
Dart :: Attribute application@icon value=(@mipmap/launcher_icon) from AndroidManifest.xml:17:9-45 
Dart :: inr symbol in flutter 
Dart :: Flutter how to use ListTile Threeline 
Dart :: dart enum 
Dart :: for in loop dart 
Dart :: flutter materialpageroute no animation 
Dart :: flutter dart sort list of objects 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =