当前位置: 首页>>代码示例>>Python>>正文


Python normalize.normalize函数代码示例

本文整理汇总了Python中normalize.normalize函数的典型用法代码示例。如果您正苦于以下问题:Python normalize函数的具体用法?Python normalize怎么用?Python normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了normalize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

def index(**kwargs):
    if request.args.get('submit') is not None:
        active = request.form.get('tabStatus')
        params = ['siteDest', 'siteSource']
        if active == 'page':
            params.append('title')
        return redirect(url_for('.index', **get_params(params)), code=c.REQUEST)

    normalize(['title'], kwargs)
    if not request.form.get('tabStatus', False):
        if kwargs.get('siteDest', False) and not kwargs.get('title', False):
            kwargs['tabStatus'] = 'content'
        else:
            kwargs['tabStatus'] = 'page'

    if not request.form.get('siteDest', False) and not request.form.get('siteSource', False):
        kwargs['siteDest'] = 'th'
        kwargs['siteSource'] = 'en'

    form = wikitranslator.form.getForm()(request.form, **kwargs)
    data = wikitranslator.model.Model(form=form)
    if form.validate(data):
        data.render()
    return render('index.html',
                  tool=__name__,
                  form=form,
                  data=data)
开发者ID:nullzero,项目名称:wpcgi,代码行数:27,代码来源:wikitranslator.py

示例2: main

def main():
    timer = timers.Timer()
    with timers.timing("Parsing", True):
        task = pddl_parser.open(
            domain_filename=options.domain, task_filename=options.task)

    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if options.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    sas_task = pddl_to_sas(task)
    dump_statistics(sas_task)

    with timers.timing("Writing output"):
        with open("output.sas", "w") as output_file:
            sas_task.output(output_file)
    print("Done! %s" % timer)
    global t1, t2
    t2 = time.time() - t2
    print('Time1:', t1)
    print('Time2:', t2)
开发者ID:danfis,项目名称:fast-downward-masters-thesis,代码行数:27,代码来源:translate.py

示例3: main

def main():
    options, args = parse_options()

    check_python_version(options.force_old_python)

    timer = timers.Timer()
    with timers.timing("Parsing", True):
        task = pddl.open()

    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if options.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    sas_task = pddl_to_sas(task)
    dump_statistics(sas_task)

    with timers.timing("Writing output"):
        with open("output.sas", "w") as output_file:
            sas_task.output(output_file)
    print("Done! %s" % timer)
开发者ID:jinnaiyuu,项目名称:fast-downward,代码行数:26,代码来源:translate.py

示例4: main

def main():
    timer = timers.Timer()
    
    
    with timers.timing("Parsing", True):
        task = pddl_parser.open(task_filename=options.task, domain_filename=options.domain)
    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if options.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    sas_task = pddl_to_sas(task)
    dump_statistics(sas_task)

    # Print pddl if a transormation option is selected.
    if options.exp or options.evmdd:
        pddl_parser.print_pddl(options.domain, sas_task, task, [])
        print("done!")
        exit(0)

    with timers.timing("Writing output"):
        with open("output.sas", "w") as output_file:
            sas_task.output(output_file)
    print("Done! %s" % timer) 
开发者ID:robertmattmueller,项目名称:sdac-compiler,代码行数:29,代码来源:translate.py

示例5: main

def main():
    print("-------------POND Translator-----------")
    args = parse_args()

    timer = timers.Timer()
    with timers.timing("Parsing", True):
        task = pddl.open(task_filename=args.task, domain_filename=args.domain)
      
        print();
        print("Problem Filename = " + args.task);
        print("Domain Filename = " + args.domain);
        print();
        
    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if args.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    sas_task = pddl_to_sas(task)
    dump_statistics(sas_task)

    if not sas_task is None:
        with timers.timing("Writing output"):
            with open("..\\webapps\\LunaPlanner\\translator_output\\output.sas", "w") as output_file:
                sas_task.output(output_file)
                
        print()
        print("SAS file saved at: " + output_file.name)
                
        print("Done! %s" % timer)
开发者ID:JackyCSer,项目名称:LunaPlanner,代码行数:35,代码来源:translate.py

示例6: build_titles

def build_titles(title):
    normalized_title = normalize(title).lower()
    titles = [ title, normalized_title ];
    if title.find(' & ') != -1:
        t = title.replace(" & ", " and ")
        titles.append(t)
        titles.append(normalize(t))
    t2 = []
    for t in titles:
        if t.lower().startswith('the '):
            t2.append(t[4:])
        elif t.lower().startswith('a '):
            t2.append(t[2:])
    titles += t2

    if re_amazon_title_paren.match(title):
        t2 = []
        for t in titles:
            m = re_amazon_title_paren.match(t)
            if m:
                t2.append(m.group(1))
                t2.append(normalize(m.group(1)))
        titles += t2

    return {
        'full_title':       title,
        'normalized_title': normalized_title,
        'titles':           titles,
        'short_title':      normalized_title[:25],
    }
开发者ID:RaceList,项目名称:openlibrary,代码行数:30,代码来源:merge_marc.py

示例7: marc_title

def marc_title(amazon_first_parts, marc_first_parts):
#            print 'title found: ', marc_first_parts[-1]
    if normalize(marc_first_parts[-1]) not in titles:
        return False
    if compare_parts(marc_first_parts[:-1], amazon_first_parts):
        if verbose:
            print("match with MARC end title")
        return True
    if normalize(amazon_first_parts[0]) in titles:
        if compare_parts(marc_first_parts[:-1], amazon_first_parts[1:]):
            if verbose:
                print("match, both with titles")
            return True
        if match_seq(marc_first_parts[:-1], amazon_first_parts[1:]):
            if verbose:
                print("partial match, both with titles")
            return True
    if match_seq(marc_first_parts[:-1], amazon_first_parts):
        if verbose:
            print("partial match with MARC end title")
        return True
    if match_seq(marc_first_parts, amazon_first_parts):
        if verbose:
            print("partial match with MARC end title")
    return False
开发者ID:hornc,项目名称:openlibrary-1,代码行数:25,代码来源:names.py

示例8: main

def main():
    args = parse_args()

    timer = timers.Timer()
    with timers.timing("Parsing", True):
        task = pddl.open(task_filename=args.task,
                         domain_filename=args.domain,
                         addl_filename=args.addl)

    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if args.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    output_file = args.output_file
    use_proto = args.use_proto
    print('Use Proto:', use_proto)

    sas_task = pddl_to_sas(task, args.agent_id, args.agent_url)
    dump_statistics(sas_task)

    with timers.timing("Writing output"):
        with open(output_file, "w") as output_file:
            if use_proto:
                sas_task.output_proto(output_file)
            else:
                sas_task.output(output_file)
    print("Done! %s" % timer)
开发者ID:danfis,项目名称:maplan,代码行数:33,代码来源:translate.py

示例9: main

def main():
    args = parse_args()

    timer = timers.Timer()
    with timers.timing("Parsing", True):
        task = pddl.open(task_filename=args.task, domain_filename=args.domain)

    with timers.timing("Normalizing task"):
        normalize.normalize(task)

    if args.generate_relaxed_task:
        # Remove delete effects.
        for action in task.actions:
            for index, effect in reversed(list(enumerate(action.effects))):
                if effect.literal.negated:
                    del action.effects[index]

    sas_task = pddl_to_sas(task)
    dump_statistics(sas_task)

    if not sas_task is None:
        with timers.timing("Writing output"):
            with open("output.sas", "w") as output_file:
                sas_task.output(output_file)
        print("Done! %s" % timer)
开发者ID:JackyCSer,项目名称:MyNDPlanner,代码行数:25,代码来源:translate.py

示例10: compare_author_fields

def compare_author_fields(e1_authors, e2_authors):
    for i in e1_authors:
        for j in e2_authors:
            if normalize(i['db_name']) == normalize(j['db_name']):
                return True
            if normalize(i['name']).strip('.') == normalize(j['name']).strip('.'):
                return True
    return False
开发者ID:hornc,项目名称:openlibrary-1,代码行数:8,代码来源:merge_marc.py

示例11: translate

def translate(task):
  normalize.normalize(task)
  prog = PrologProgram()
  translate_facts(prog, task)
  for conditions, effect in normalize.build_exploration_rules(task):
    prog.add_rule(Rule(conditions, effect))
  prog.normalize()
  prog.split_rules()
  return prog
开发者ID:TathagataChakraborti,项目名称:resource-conflicts,代码行数:9,代码来源:pddl_to_prolog.py

示例12: normalize

    def normalize(self):
        """
        Performs normalization. At this level, we do those normalizations that
        needs both the pre & post syscall objects
        """
        import normalize

        for id in self:
            pre,post = self.getSyscallByID(id)

            normalize.normalize(pre, post)
开发者ID:N3mes1s,项目名称:wusstrace,代码行数:11,代码来源:syscall.py

示例13: flip_marc_name

def flip_marc_name(marc):
    m = re_marc_name.match(marc)
    if not m:
        return remove_trailing_dot(marc)
    first_parts = split_parts(m.group(2))
    if normalize(first_parts[-1]) not in titles:
        # example: Eccles, David Eccles Viscount
        return remove_trailing_dot(m.group(2)) + ' ' + m.group(1)
    if len(first_parts) > 2 and normalize(first_parts[-2]) == normalize(m.group(1)):
        return u' '.join(first_parts[0:-1])
    return u' '.join(first_parts[:-1] + [m.group(1)])
开发者ID:hornc,项目名称:openlibrary-1,代码行数:11,代码来源:names.py

示例14: __init__

  def __init__(self, item_id, quantity, *options):
    """Store the descriptors of an order item in this object.

    Arguments:
    item_id -- the restaurants's numerial ID for the item
    quantity -- the quantity
    options -- any number of options to apply to the item

    """
    self.item_id = normalize(item_id, 'number')
    self.quantity = normalize(quantity, 'number')
    self.options = [normalize(option, 'number') for option in options]
开发者ID:ryankanno,项目名称:ecommercehackday,代码行数:12,代码来源:data.py

示例15: get_delivery_check

  def get_delivery_check(self, restaurant_id, date_time, address):
    """Get data about a given restaurant, including whether it will deliver to
    the specified address at the specified time

    Arguments:
    restaurant_id -- Ordr.in's restaurant identifier
    date_time -- Either 'ASAP' or a datetime object in the future
    address -- the address to deliver to. Should be an ordrin.data.Address object

    """
    dt = normalize(date_time, 'datetime')
    restaurant_id = normalize(restaurant_id, 'number')
    return self._call_api('GET', ('dc', restaurant_id, dt, address.zip, address.city, address.addr))
开发者ID:ryankanno,项目名称:ecommercehackday,代码行数:13,代码来源:restaurant.py


注:本文中的normalize.normalize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。