def educateQuotes(text, language='en'):
 smart = smartchars(language)
 punct_class = '[!"#\\$\\%\'()*+,-.\\/:;<=>?\\@\\[\\\\\\]\\^_`{|}~]'
 text = re.sub(("^'(?=%s\\\\B)" % (punct_class,)), smart.csquote, text)
 text = re.sub(('^"(?=%s\\\\B)' % (punct_class,)), smart.cpquote, text)
 text = re.sub('"\'(?=\\w)', (smart.opquote + smart.osquote), text)
 text = re.sub('\'"(?=\\w)', (smart.osquote + smart.opquote), text)
 text = re.sub("\\b'(?=\\d{2}s)", smart.csquote, text)
 close_class = '[^\\ \\t\\r\\n\\[\\{\\(\\-]'
 dec_dashes = '&#8211;|&#8212;'
 opening_single_quotes_regex = re.compile(("\n                    (\n                            \\s          |   # a whitespace char, or\n                            &nbsp;      |   # a non-breaking space entity, or\n                            --          |   # dashes, or\n                            &[mn]dash;  |   # named dash entities\n                            %s          |   # or decimal entities\n                            &\\#x201[34];    # or hex\n                    )\n                    '                 # the quote\n                    (?=\\w)            # followed by a word character\n                    " % (dec_dashes,)), re.VERBOSE)
 text = opening_single_quotes_regex.sub(('\\1' + smart.osquote), text)
 closing_single_quotes_regex = re.compile(("\n                    (%s)\n                    '\n                    (?!\\s | s\\b | \\d)\n                    " % (close_class,)), re.VERBOSE)
 text = closing_single_quotes_regex.sub(('\\1' + smart.csquote), text)
 closing_single_quotes_regex = re.compile(("\n                    (%s)\n                    '\n                    (\\s | s\\b)\n                    " % (close_class,)), re.VERBOSE)
 text = closing_single_quotes_regex.sub(('\\1%s\\2' % smart.csquote), text)
 text = re.sub("'", smart.osquote, text)
 opening_double_quotes_regex = re.compile(('\n                    (\n                            \\s          |   # a whitespace char, or\n                            &nbsp;      |   # a non-breaking space entity, or\n                            --          |   # dashes, or\n                            &[mn]dash;  |   # named dash entities\n                            %s          |   # or decimal entities\n                            &\\#x201[34];    # or hex\n                    )\n                    "                 # the quote\n                    (?=\\w)            # followed by a word character\n                    ' % (dec_dashes,)), re.VERBOSE)
 text = opening_double_quotes_regex.sub(('\\1' + smart.opquote), text)
 closing_double_quotes_regex = re.compile(('\n                    #(%s)?   # character that indicates the quote should be closing\n                    "\n                    (?=\\s)\n                    ' % (close_class,)), re.VERBOSE)
 text = closing_double_quotes_regex.sub(smart.cpquote, text)
 closing_double_quotes_regex = re.compile(('\n                    (%s)   # character that indicates the quote should be closing\n                    "\n                    ' % (close_class,)), re.VERBOSE)
 text = closing_double_quotes_regex.sub(('\\1' + smart.cpquote), text)
 text = re.sub('"', smart.opquote, text)
 return text

def educateQuotes ( text , language = 'en' ) : smart = smartchars ( language ) punct_class = '[!"#\\$\\%\'()*+,-.\\/:;<=>?\\@\\[\\\\\\]\\^_`{|}~]' text = re . sub ( ( "^'(?=%s\\\\B)" % ( punct_class , ) ) , smart . csquote , text ) text = re . sub ( ( '^"(?=%s\\\\B)' % ( punct_class , ) ) , smart . cpquote , text ) text = re . sub ( '"\'(?=\\w)' , ( smart . opquote + smart . osquote ) , text ) text = re . sub ( '\'"(?=\\w)' , ( smart . osquote + smart . opquote ) , text ) text = re . sub ( "\\b'(?=\\d{2}s)" , smart . csquote , text ) close_class = '[^\\ \\t\\r\\n\\[\\{\\(\\-]' dec_dashes = '&#8211;|&#8212;' opening_single_quotes_regex = re . compile ( ( "\n                    (\n                            \\s          |   # a whitespace char, or\n                            &nbsp;      |   # a non-breaking space entity, or\n                            --          |   # dashes, or\n                            &[mn]dash;  |   # named dash entities\n                            %s          |   # or decimal entities\n                            &\\#x201[34];    # or hex\n                    )\n                    '                 # the quote\n                    (?=\\w)            # followed by a word character\n                    " % ( dec_dashes , ) ) , re . VERBOSE ) text = opening_single_quotes_regex . sub ( ( '\\1' + smart . osquote ) , text ) closing_single_quotes_regex = re . compile ( ( "\n                    (%s)\n                    '\n                    (?!\\s | s\\b | \\d)\n                    " % ( close_class , ) ) , re . VERBOSE ) text = closing_single_quotes_regex . sub ( ( '\\1' + smart . csquote ) , text ) closing_single_quotes_regex = re . compile ( ( "\n                    (%s)\n                    '\n                    (\\s | s\\b)\n                    " % ( close_class , ) ) , re . VERBOSE ) text = closing_single_quotes_regex . sub ( ( '\\1%s\\2' % smart . csquote ) , text ) text = re . sub ( "'" , smart . osquote , text ) opening_double_quotes_regex = re . compile ( ( '\n                    (\n                            \\s          |   # a whitespace char, or\n                            &nbsp;      |   # a non-breaking space entity, or\n                            --          |   # dashes, or\n                            &[mn]dash;  |   # named dash entities\n                            %s          |   # or decimal entities\n                            &\\#x201[34];    # or hex\n                    )\n                    "                 # the quote\n                    (?=\\w)            # followed by a word character\n                    ' % ( dec_dashes , ) ) , re . VERBOSE ) text = opening_double_quotes_regex . sub ( ( '\\1' + smart . opquote ) , text ) closing_double_quotes_regex = re . compile ( ( '\n                    #(%s)?   # character that indicates the quote should be closing\n                    "\n                    (?=\\s)\n                    ' % ( close_class , ) ) , re . VERBOSE ) text = closing_double_quotes_regex . sub ( smart . cpquote , text ) closing_double_quotes_regex = re . compile ( ( '\n                    (%s)   # character that indicates the quote should be closing\n                    "\n                    ' % ( close_class , ) ) , re . VERBOSE ) text = closing_double_quotes_regex . sub ( ( '\\1' + smart . cpquote ) , text ) text = re . sub ( '"' , smart . opquote , text ) return text
parameter: string .