def goGoodSamaritan(prevValue, originalCharset):
 if (kb.commonOutputs is None):
  initCommonOutputs()
 predictionSet = set()
 commonValue = None
 commonPattern = None
 countCommonValue = 0
 if (kb.partRun in kb.commonOutputs):
  commonPartOutputs = kb.commonOutputs[kb.partRun]
  commonPattern = commonFinderOnly(prevValue, commonPartOutputs)
  if (commonPattern and (commonPattern == prevValue)):
   commonPattern = None
  for item in commonPartOutputs:
   if item.startswith(prevValue):
    commonValue = item
    countCommonValue += 1
    if (len(item) > len(prevValue)):
     char = item[len(prevValue)]
     predictionSet.add(char)
  if (countCommonValue > 1):
   commonValue = None
  commonCharset = []
  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 ( kb . partRun in kb . commonOutputs ) : commonPartOutputs = kb . commonOutputs [ kb . partRun ] commonPattern = commonFinderOnly ( prevValue , commonPartOutputs ) if ( commonPattern and ( commonPattern == prevValue ) ) : commonPattern = None for item in commonPartOutputs : if item . startswith ( prevValue ) : commonValue = item countCommonValue += 1 if ( len ( item ) > len ( prevValue ) ) : char = item [ len ( prevValue ) ] predictionSet . add ( char ) if ( countCommonValue > 1 ) : commonValue = None commonCharset = [ ] 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 )
function for retrieving parameters needed for common prediction feature .