def METHOD_NAME(filename):
    table = {}
    class Entry(object):
        def __init__(self):
            self.clear()
        def clear(self):
            self.ip = ''
            self.text = ''
        def complete(self):
            ips = self.build_ip()
            for ip in ips:
                if ip in table:
                    raise ValueError('duplicated IP: %s' % ip)
                table[ip] = self.text.rstrip() + "\n"
            self.clear()
        def add_ip(self, s):
            if '#' in s:
                s = s.partition('#')[0]
            self.ip += ' ' + s
        def add_text(self, s):
            self.text += s
        def build_ip(self):
            ips = self.ip.split()
            if not all((check_ipv4(ip) for ip in ips)):
                raise Exception('Bad IP.')
            return ips
    entry = Entry()
    with open(filename, 'rt', encoding='big5') as f:
        for line in f:
            t = line.strip()
            if t.startswith('#'):
                continue
            if t and t[0] in string.digits:
                # create new entry, or continue
                if entry.text:
                    entry.complete()
                entry.add_ip(t)
            elif entry.ip:
                # more text
                entry.add_text(line)
            elif not t:
                continue
            else:
                raise ValueError("Text before IP definition: %s" % t)
    if entry.ip:
        entry.complete()
    return table