(prevValue, originalCharset)
Function for retrieving parameters needed for common prediction (good
    samaritan) feature.

    prevValue: retrieved query output so far (e.g. 'i').

    Returns commonValue if there is a complete single match (in kb.partRun
    of txt/common-outputs.txt under kb.partRun) regarding parameter
    prevValue. If there is no single value match, but multiple, commonCharset is
    returned containing more probable characters (retrieved from matched
    values in txt/common-outputs.txt) together with the rest of charset as
    otherCharset.
Function for retrieving parameters needed for common prediction (good
    samaritan) feature.
Function for retrieving parameters needed for common prediction ( good samaritan ) feature .
def goGoodSamaritan(prevValue, originalCharset):
    """
    Function for retrieving parameters needed for common prediction (good
    samaritan) feature.

    prevValue: retrieved query output so far (e.g. 'i').

    Returns commonValue if there is a complete single match (in kb.partRun
    of txt/common-outputs.txt under kb.partRun) regarding parameter
    prevValue. If there is no single value match, but multiple, commonCharset is
    returned containing more probable characters (retrieved from matched
    values in txt/common-outputs.txt) together with the rest of charset as
    otherCharset.
    """

    if kb.commonOutputs is None:
        initCommonOutputs()

    predictionSet = set()
    commonValue = None
    commonPattern = None
    countCommonValue = 0

    # If the header (e.g. Databases) we are looking for has common
    # outputs defined
    if kb.partRun in kb.commonOutputs:
        commonPartOutputs = kb.commonOutputs[kb.partRun]
        commonPattern = commonFinderOnly(prevValue, commonPartOutputs)

        # If the longest common prefix is the same as previous value then
        # do not consider it
        if commonPattern and commonPattern == prevValue:
            commonPattern = None

        # For each common output
        for item in commonPartOutputs:
            # Check if the common output (item) starts with prevValue
            # where prevValue is the enumerated character(s) so far
            if item.startswith(prevValue):
                commonValue = item
                countCommonValue += 1

                if len(item) > len(prevValue):
                    char = item[len(prevValue)]
                    predictionSet.add(char)

        # Reset single value if there is more than one possible common
        # output
        if countCommonValue > 1:
            commonValue = None

        commonCharset = []
        otherCharset = []

        # Split the original charset into common chars (commonCharset)
        # and other chars (otherCharset)
        for ordChar in originalCharset:
            if chr(ordChar) not in predictionSet:
                otherCharset.append(ordChar)
            else:
                commonCharset.append(ordChar)

        commonCharset.sort()

        return commonValue, commonPattern, commonCharset, originalCharset
    else:
        return None, None, None, originalCharset
def goGoodSamaritan ( prevValue , originalCharset ) : if kb . commonOutputs is None : initCommonOutputs ( ) predictionSet = set ( ) commonValue = None commonPattern = None countCommonValue = 0 # If the header (e.g. Databases) we are looking for has common # outputs defined if kb . partRun in kb . commonOutputs : commonPartOutputs = kb . commonOutputs [ kb . partRun ] commonPattern = commonFinderOnly ( prevValue , commonPartOutputs ) # If the longest common prefix is the same as previous value then # do not consider it if commonPattern and commonPattern == prevValue : commonPattern = None # For each common output for item in commonPartOutputs : # Check if the common output (item) starts with prevValue # where prevValue is the enumerated character(s) so far if item . startswith ( prevValue ) : commonValue = item countCommonValue += 1 if len ( item ) > len ( prevValue ) : char = item [ len ( prevValue ) ] predictionSet . add ( char ) # Reset single value if there is more than one possible common # output if countCommonValue > 1 : commonValue = None commonCharset = [ ] otherCharset = [ ] # Split the original charset into common chars (commonCharset) # and other chars (otherCharset) for ordChar in originalCharset : if chr ( ordChar ) not in predictionSet : otherCharset . append ( ordChar ) else : commonCharset . append ( ordChar ) commonCharset . sort ( ) return commonValue , commonPattern , commonCharset , originalCharset else : return None , None , None , originalCharset