當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。