"String" (Comparison Method)
Details
- By default, the "String" comparison method considers two strings to be equivalent if they are identical.
- The distance metric and the corresponding tolerance can be set using the DistanceFunction and Tolerance option. EditDistance is the default distance function.
- The DistanceFunction is only used for nonzero Tolerance. Other distance metrics include HammingDistance, SmithWatermanSimilarity and DamerauLevenshteinDistance.
- When multiple values in the answer key are within the tolerance range of an answer, the closest value is selected.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Create an AssessmentFunction for a string question:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-0ejk4z


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-rykph


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-rb4zg9

Define assessment for a DNA sequence with tolerance:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-32jeoh

Any sequence within an EditDistance of two is considered correct:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-z5ztpt

Set multiple answer keys with custom scores and infer the string method:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-r36nx4


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-t1mlg3

Get more details from the result:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-f80xda

Scope (2)Survey of the scope of standard use cases
Perform category assessment involving strings:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-6dy4ka


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-burxqo

Assess each element of a list separately:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-qs4gp6


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-gz9wp9

Options (2)Common values & functionality for each option

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-s7mppw


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-49iogn


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-zipfql

Compute equivalent comparisons directly:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-crpxqr


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-r05far

Using different distance metrics might produce different results:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-f4e5qc


https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-85keyh

Applications (1)Sample problems that can be solved with this function
Define a utility function to make BioSequenceComplement support DNA strings:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-knxmym
Create a QuestionObject for determining DNA complements allowing one mistake in each:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-7zmszr

Properties & Relations (1)Properties of the function, and connections to other functions
Possible Issues (2)Common pitfalls and unexpected behavior
Some metrics only work when comparing strings with equal length:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-3fosjl


The "String" comparison method is based on distances, not patterns. Matching of string patterns is not supported:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-b22h9u

Instead, specify StringMatchQ as a custom comparator:

https://wolfram.com/xid/0fl3i4cwfo64rnp7eu29abc66-dev1ua
