"String" (Comparison Method)
Compare two strings using any distance metric.
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.
范例
打开所有单元关闭所有单元基本范例 (3)
Create an AssessmentFunction for a string question:
Define assessment for a DNA sequence with tolerance:
Any sequence within an EditDistance of two is considered correct:
Set multiple answer keys with custom scores and infer the string method:
Scope (2)
Options (2)
Applications (1)
Define a utility function to make BioSequenceComplement support DNA strings:
Create a QuestionObject for determining DNA complements allowing one mistake in each:
Properties & Relations (1)
Possible Issues (2)
Some metrics only work when comparing strings with equal length:
The "String" comparison method is based on distances, not patterns. Matching of string patterns is not supported:
Instead, specify StringMatchQ as a custom comparator: