Pour faire un quizz tolérant sur l'ortho , ça peut être utile

[EDIT]
Je viens de faire une recherche , l'algo de Levenshtein était déjà sur le forum anglais.
Code : Tout sélectionner
;http://www.developpez.net/forums/d644186/dotnet/contribuez/algorithme-evaluer-similarite-entre-2-chaines/
Procedure Min(a, b, c)
Min = a
If b < Min
Min = b
EndIf
If c < Min
Min = c
EndIf
ProcedureReturn Min
EndProcedure
Procedure Max(a, b)
If a>b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
; <summary>
; Computes the Levenshtein distance between 2 strings
; Based on the algorithm described here :
; http://en.wikipedia.org/wiki/Levenshtein_distance
; </summary>
; <param name="a">first string To compare</param>
; <param name="b">second string To compare</param>
; <param name="caseSensitive">true If Case should be considered, false otherwise</param>
; <returns>the Levenshtein distance between the 2 strings</returns>
Procedure ComputeDistance(a.s, b.s, caseSensitive)
If caseSensitive=0
a = LCase(a)
b = LCase(b)
EndIf
m.i = Len(a)
n.i = Len(b)
Dim d(m, n)
For i = 0 To m
d(i, 0) = i
Next i
For i = 0 To n
d(0, i) = i
Next i
For i = 1 To m
For j = 1 To n
If Mid(a,i-1, 1) = Mid(b,j-1,1)
cost = 0
Else
cost = 1
EndIf
d(i, j) = Min(d(i - 1, j) + 1, d(i, j - 1) + 1, d(i - 1, j - 1) + cost)
Next j
Next i
ProcedureReturn d(m, n)
EndProcedure
; <summary>
; Computes the correlation coefficient between 2 strings, based on the Levenshtein distance
; </summary>
; <param name="a">first string To compare</param>
; <param name="b">second string To compare</param>
; <param name="caseSensitive">true If Case should be considered, false otherwise</param>
; <returns>The correlation coefficient between the 2 strings. This value can range from 0 (completely different strings) To 1 (identical strings)</returns>
Procedure.d ComputeCorrelation(a.s, b.s, caseSensitive)
distance = ComputeDistance(a, b, caseSensitive)
longest = Max(Len(a), Len(b))
ProcedureReturn 1.0 - distance / longest
EndProcedure
a.s="Purebasic c'est super cool"
b.s="purebasic c super coul"
threshold.d = 0.8
coef.d = ComputeCorrelation(a, b, 0)
If coef > threshold
MessageRequester("","Bonne réponse !")
Else
MessageRequester("","Mauvaise réponse !")
EndIf