def __parse_roman(value):
 if (not __romanNumeralPattern.search(value)):
  raise ValueError(('Invalid Roman numeral: %s' % value))
 result = 0
 index = 0
 for (num, integer) in __romanNumeralMap:
  while (value[index:(index + len(num))] == num):
   result += integer
   index += len(num)
 return result

def __parse_roman ( value ) : if ( not __romanNumeralPattern . search ( value ) ) : raise ValueError ( ( 'Invalid Roman numeral: %s' % value ) ) result = 0 index = 0 for ( num , integer ) in __romanNumeralMap : while ( value [ index : ( index + len ( num ) ) ] == num ) : result += integer index += len ( num ) return result
convert roman numeral to integer .