I am looking for an algorithm, preferably in Python, that will help me find substrings, long N characters, from existing strings closest to the target string N of the long character.
Consider the target string, for example, 4 characters long:
targetString -> '1111'
Suppose this is a string that I have with me (I will generate substrings of this to match "best alignment"):
nonEmptySubStrings -> ['110101']
The substrings specified above are 4 characters long:
nGramsSubStrings -> ['0101', '1010', '1101']
I want to write / use a "Magic Function" that will select the line closest to targetString:
someMagicFunction -> ['1101']
Some more examples:
nonEmptySubStrings -> ['101011'] nGramsSubStrings -> ['0101', '1010', '1011'] someMagicFunction -> ['1011'] nonEmptySubStrings -> ['10101'] nGramsSubStrings -> ['0101', '1010'] someMagicFunction -> ['0101', '1010']
Is this βmagic functionβ a well-known substring problem?
I really want to find mines. the number of changes to nonEmptySubStrings so that targetString is used as a substring.
source share