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


Python term.Term类代码示例

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


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

示例1: build_term

def build_term(dict):
    """
    Builds a Term object from the term metadata dictionary provided.
    """
    # Add our metadata to our term piece-by-piece
    term = Term()

    try:
        term.id = dict['id'][0]
        term.name = dict['name'][0]
    except KeyError as k:
        raise TermMissingRequiredFieldException("Missing required field %s" % k)

    termDef = dict.get('def', [""])
    term.definition = termDef[0]
    obsoleteBool = dict.get('is_obsolete', [False])
    term.obsolete = obsoleteBool[0]

    term.synonyms.extend( format_synonym_list(dict.get('synonym', [])) )
    term.relationships.extend( dict.get('relationship', []) )
    term.xrefs.extend( dict.get('xref', []) ) 
    term.alternateIds.extend( dict.get('alt_id', []) )
    term.subsets.extend( dict.get('subset', []) )

    return term
开发者ID:bdunnette,项目名称:lmpscripts,代码行数:25,代码来源:oboparser.py

示例2: post

 def post(self):
     user = self.current_user
     
     semester = str(self.request.get('listSelectSemester'))
     year = int(self.request.get('listSelectYear'))
 
     term = Term.query(ancestor = user.key).filter(ndb.AND(Term.semester == semester, Term.year == year)).get()
         
     if not term:
         term = Term(parent = user.key, semester = semester, year = year)
         term.put()
         
     self.session['term'] = term.key.urlsafe()
 
     self.redirect('/list')
开发者ID:koszuta,项目名称:CS361,代码行数:15,代码来源:lister.py

示例3: __call__

 def __call__(self, screen):
     """Z(screen) -> None"""
     # init the interface
     self.area = area.Area(self)
     self.term = Term(self, screen)
     (y, x) = self.term.viewsize()  # wtf? why can't curses
     self.area.resize(y, x - 1)  # draw on the screen edge?
     self.hero = Hero(self.area, 1, 1, None)
     self.actors = [self.hero]
     self.actors.extend(self.area.generate(0))
     self.area.enter(self.hero.y, self.hero.x, self.hero)
     self.term.redraw()
     # start the game
     running = True
     while running:
         actor = self.actors[0]
         while running and actor.wait_until <= self.time:
             actor.act()
             if self.game_over == "quit":
                 self.term.msg("Goodbye, thanks for playing!")
                 self.term.waitforkey()
                 running = False
             elif self.game_over == "escaped":
                 self.term.msg("You escaped with %d gold!" % self.hero.gold)
                 self.term.waitforkey()
                 running = False
             elif self.game_over == "killed":
                 self.term.msg("You died.")
                 self.term.waitforkey()
                 running = False
         self.time += 1
         self.queue_actor(actor)
开发者ID:zenhob,项目名称:zedventure,代码行数:32,代码来源:game.py

示例4: __call__

 def __call__(self,screen):
     """Z(screen) -> None"""
     # init the interface
     self.area = area.Area(self)
     self.term = Term(self,screen)
     (y, x) = self.term.viewsize()  # wtf? why can't curses
     self.area.resize(y, x-1)       # draw on the screen edge?
     self.hero = Hero(self.area,1,1,None)
     self.actors = [self.hero]
     self.actors.extend(self.area.generate(0))
     self.area.enter(self.hero.y, self.hero.x, self.hero)
     self.term.redraw()
     # start the game
     running = True
     while running:
         actor = self.actors[0]
         try:
             while actor.wait_until <= self.time:
                 actor.act()
         except QuitGame:
             self.term.msg('Goodbye, thanks for playing!')
             self.term.waitforkey()
             running = False
         except Escaped:
             self.term.msg('You escaped with %d gold!' % self.hero.gold)
             self.term.waitforkey()
             running = False
         except WasKilled:
             self.term.msg('You died.')
             self.term.waitforkey()
             running = False
         finally:
             self.time += 1
         self.queue_actor(actor)
开发者ID:codelurker,项目名称:zedventure,代码行数:34,代码来源:game.py

示例5: __repr__

    def __repr__(self):
        if self.statements == []:
            return "{}"
        if len(self.statements) == 1:
            st = self.statements[0]
            return "{"+`st[SUBJ]`+" "+`st[PRED]`+" "+`st[OBJ]`+"}"

        s = Term.__repr__(self)
        return "{%i}" % len(self.statements)
开发者ID:mit-dig,项目名称:air-reasoner,代码行数:9,代码来源:formula.py

示例6: shell

def shell(asker):
    current_view = view(T.from_list_of_str(["(Home)"]), T.from_dict({}))
    asker.tag(T("the current view"), current_view)
    while True:
        input = asker.ask_firmly(elicit(current_view))
        asker.ask(update_view(current_view, input))
        current_view = asker.refresh(current_view)
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:views.py

示例7: exposed_modifier

def exposed_modifier(asker, rep):
    head = asker.ask(fields.get_field(representations.head(), rep)).answer
    if head is None:
        return asker.reply(answer=T.no())
    else:
        result = strings.to_str(asker, head) not in hidden_modifier_heads
        return asker.reply(answer=T.from_bool(result))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:convert.py

示例8: render_term

def render_term(asker, term):
    return asker.reply(answer=strings.concat(
        strings.concat(
            T.from_str("T("), 
            field.get(asker, representations.head(), term)),
        T.from_str(")")
    ))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:views.py

示例9: render_list

def render_list(asker, x):
    result = T.from_str("[")
    first = True
    for item in lists.iterator(asker, x):
        item_printed = asker.ask_firmly(render(item))
        if not first:
            item_printed = strings.concat(T.from_str(", "), item_printed)
        first = False
        result = strings.concat(result, item_printed)
    result = strings.concat(result, T.from_str("]"))
    return asker.reply(answer=result)
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:11,代码来源:views.py

示例10: make_raw_expr

def make_raw_expr(xs):
    text = ""
    args = {}
    for x in xs:
        if type(x) is str:
            text += x
        else:
            arg_name = ("xyzw"+alphas)[len(args)]
            text += "[{}]".format(arg_name)
            args[arg_name] = x
    return T(make_raw_expr.head, text=T.from_str(text), bindings=T.from_dict_of_str(args))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:11,代码来源:parsing.py

示例11: render_pair

def render_pair(asker, x):
    return asker.reply(answer=strings.concat(
        strings.concat(
            T.from_str("("),
            asker.ask_firmly(render(fields.get(pairs.first(), x))),
        ),
        strings.concat(
            T.from_str(", "),
            strings.concat(
                asker.ask_firmly(render(fields.get(pairs.first(), x))),
                T.from_str(")")
            )
        )
    ))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:14,代码来源:views.py

示例12: node_from_term

def node_from_term(asker, quoted_term):
    head = asker.ask(fields.get_field(representations.head(), quoted_term)).firm_answer
    bindings = asker.ask(fields.get_field(representations.bindings(), quoted_term)).firm_answer
    return asker.reply(answer=properties.simple_add_modifier(
        node(head, T.empty_list()),
        children_on_expanded(bindings)
    ))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:outlines.py

示例13: add_children_on_expanded

def add_children_on_expanded(asker, old, new, bindings):
    children = []
    for p in lists.iterator(asker, lists.from_dict(bindings)):
        k = asker.ask(fields.get_field(first(), p)).firm_answer
        v = asker.ask(fields.get_field(second(), p)).firm_answer
        prefix = strings.string_concat(k, T.from_str(": "))
        new_node = node_from_term(asker, v)
        new_node = updates.update(
            updates.apply_to(headline(), strings.prepend_str(prefix)),
            new_node
        )
        children.append(new_node)
    return asker.reply(answer=updates.update(
        fields.set_field(all_children(), T.from_list(children)), 
        new
    ))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:16,代码来源:outlines.py

示例14: orthogonal

def orthogonal(asker, field1, field2):
    if booleans.ask_firmly(asker, builtins.equal(field1, field2)):
        return asker.reply(answer=T.no())
    result = orthogonality_tester.dispatch(asker, field1, field2)
    if result is not None: return result
    result = orthogonality_tester.dispatch(asker, field2, field1)
    if result is not None: return result
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:fields.py

示例15: zip

def zip(asker, req, a, b):
    if (properties.check_firmly(asker, is_empty(), a) or 
            properties.check_firmly(asker, is_empty(), b)):
        return asker.reply(answer=empty())
    zipped_first = T.pair(fields.get(asker, first(), a), fields.get(asker, first(), b))
    zipped_tail = zip(fields.get(asker, tail(), a), fields.get(asker, tail(), b))
    return asker.ask_tail(convert.convert(cons(zipped_first, zipped_tail), req))
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:7,代码来源:lists.py


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