def choose_string(g1, g2):
 (v1, c1) = g1
 (v2, c2) = g2
 if (not v1):
  return g2
 elif (not v2):
  return g1
 (v1, v2) = (v1.strip(), v2.strip())
 (v1l, v2l) = (v1.lower(), v2.lower())
 combined_prob = (1 - ((1 - c1) * (1 - c2)))
 if (v1l == v2l):
  return (v1, combined_prob)
 elif (v1l == (u'the ' + v2l)):
  return (v1, combined_prob)
 elif (v2l == (u'the ' + v1l)):
  return (v2, combined_prob)
 elif (v2l in v1l):
  return (v2, combined_prob)
 elif (v1l in v2l):
  return (v1, combined_prob)
 elif (c1 > c2):
  return (v1, (c1 - c2))
 else:
  return (v2, (c2 - c1))

def choose_string ( g1 , g2 ) : ( v1 , c1 ) = g1 ( v2 , c2 ) = g2 if ( not v1 ) : return g2 elif ( not v2 ) : return g1 ( v1 , v2 ) = ( v1 . strip ( ) , v2 . strip ( ) ) ( v1l , v2l ) = ( v1 . lower ( ) , v2 . lower ( ) ) combined_prob = ( 1 - ( ( 1 - c1 ) * ( 1 - c2 ) ) ) if ( v1l == v2l ) : return ( v1 , combined_prob ) elif ( v1l == ( u'the ' + v2l ) ) : return ( v1 , combined_prob ) elif ( v2l == ( u'the ' + v1l ) ) : return ( v2 , combined_prob ) elif ( v2l in v1l ) : return ( v2 , combined_prob ) elif ( v1l in v2l ) : return ( v1 , combined_prob ) elif ( c1 > c2 ) : return ( v1 , ( c1 - c2 ) ) else : return ( v2 , ( c2 - c1 ) )
function used by merge_similar_guesses to choose between 2 possible properties when they are strings .