• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python term.Term类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Term类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Zedventure

class Zedventure(object):
    __slots__ = ("time", "area", "hero", "actors", "term", "rng", "game_over")

    def __init__(self, args):
        # init the game
        self.time = 0
        self.area = None
        self.term = None
        self.hero = None
        self.game_over = None
        self.actors = []
        self.rng = random.Random()

    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)

    def new_level(self, increment):
        self.actors = self.area.generate(increment)
        self.actors.insert(0, self.hero)
        self.area.occ[self.hero.y, self.hero.x] = self.hero

    def prev_level(self):
        if self.area.depth < 1:
            self.game_over = "escaped"
        else:
            self.new_level(-1)

    def next_level(self):
        self.new_level(1)

    def queue_actor(self, actor):
        done = False
        for i, a in enumerate(self.actors):
            if a > actor:
                self.actors.remove(actor)
                self.actors.insert(i, actor)
                done = True
                break
        if not done:
            self.actors.remove(actor)
            self.actors.append(actor)

    def coinflip(self):
        return bool(self.rng.randint(0, 1))

    def chance_in(self, odds):
        return self.rng.randint(1, odds) == 1

    def percent_chance(self, pct):
        return self.rng.randint(1, 100) <= pct
开发者ID:zenhob,项目名称:zedventure,代码行数:80,代码来源:game.py


示例7: find_hearst_concepts

    def find_hearst_concepts(self, triples):
        s_concepts = []
        m_concepts = []
        for (t1, rel, t2) in triples:
            term1 = Term(preprocessor.pos_tag(t1, True))
            term2 = Term(preprocessor.pos_tag(t2, True))

            synsets1 = wn.synsets(term1.get_head()[0], self.pos_tag(term1.get_head()[1]))
            synsets2 = wn.synsets(term2.get_head()[0], self.pos_tag(term2.get_head()[1]))

            if not synsets1:
                raise Exception("'{}' not found in WordNet".format(term1.get_head()[0]))
            if not synsets2:
                raise Exception("'{}' not found in WordNet".format(term2.get_head()[0]))

            (best1, best2) = self.comp(synsets1, synsets2)

            con1 = self.get_concept(
                concept.Concept(synset=best1, term=term1.get_head()[0])
            )
            con2 = self.get_concept(
                concept.Concept(synset=best2, term=term2.get_head()[0])
            )

            conChild1 = None
            conChild2 = None
            if len(term1.get_terms()) > 1:
                conChild1 = self.get_concept(
                    concept.Concept(name=term1.get_terms(), term=term1.get_head()[0])
                )
                con1.add_hyponym(conChild1)
                conChild1.add_hypernym(con1)
                #m_concepts.append(conChild1)
            if len(term2.get_terms()) > 1:
                conChild2 = self.get_concept(
                    concept.Concept(name=term2.get_terms(), term=term2.get_head()[0])
                )
                con2.add_hyponym(conChild2)
                conChild2.add_hypernym(con2)
                #m_concepts.append(conChild2)

            if conChild1:
                if conChild2:
                    conChild1.add_relation(conChild2, rel)
                else:
                    conChild1.add_relation(con2, rel)
                m_concepts.append(conChild1)
            else:
                if conChild2:
                    con1.add_relation(conChild2, rel)
                    m_concepts.append(conChild2)
                else:
                    con1.add_relation(con2, rel)

            s_concepts.append(con1)
            s_concepts.append(con2)

        self.single_concepts = self.single_concepts.union(set(s_concepts))
        self.multi_concepts = self.multi_concepts.union(set(m_concepts))
开发者ID:cartisan,项目名称:knoex,代码行数:59,代码来源:concept_former.py


示例8: Zedventure

class Zedventure (object):
    __slots__ = ('time','area','hero','actors','term','rng')
    def __init__(self,args):
        # init the game
        self.time = 0
        self.area = None
        self.term = None
        self.hero = None
        self.actors = []
        self.rng = random.Random()

    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)

    def new_level(self,increment):
        self.actors = self.area.generate(increment)
        self.actors.insert(0,self.hero)
        self.area.occ[self.hero.y,self.hero.x] = self.hero

    def prev_level(self):
        self.new_level(-1)

    def next_level(self):
        self.new_level(1)

    def queue_actor(self,actor):
        done = False
        for i,a in enumerate(self.actors):
            if a > actor:
                self.actors.remove(actor)
                self.actors.insert(i, actor)
                done = True
                break
        if not done:
            self.actors.remove(actor)
            self.actors.append(actor)

    def coinflip(self):
        return bool(self.rng.randint(0,1))

    def chance_in(self,odds):
        return self.rng.randint(1,odds) == 1

    def percent_chance(self,pct):
        return self.rng.randint(1,100) <= pct
开发者ID:codelurker,项目名称:zedventure,代码行数:77,代码来源:game.py


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: update_view

def update_view(asker, view, input):
    relayer = asker.pass_through(should_return.head)
    #FIXME using the name view_in is a hack to keep view from being locally scoped...
    @relayer(should_print.head)
    def print_string(s):
        view_in = asker.refresh(view)
        asker.update(add_line(input), view_in)
        #FIXME more things going wrong with representation levels...
        s = convert.unquote(asker, s)
        line = asker.ask_firmly(render(s))
        asker.update(add_line(line), view_in)
        return properties.trivial()
    @relayer(should_dispatch.head)
    def dispatch(x):
        view_in = asker.refresh(view)
        asker.update(add_line(input), view_in)
        head = fields.get(asker, representations.head(), x)
        bindings = fields.get(asker, representations.bindings(), x)
        view_in = asker.refresh(view_in)
        asker.update(add_line(head), view_in)
        for p in dictionaries.item_iterator(asker, bindings):
            var, val = pairs.to_pair(asker, p)
            view_in = asker.refresh(view_in)
            asker.update(bind_variable(var, val), view_in)
        return properties.trivial()
    @relayer(should_assign.head)
    def assign(s, x):
        view_in = asker.refresh(view)
        asker.update(add_line(input), view_in)
        view_in = asker.refresh(view_in)
        asker.update(bind_variable(s, x), view_in)
        return properties.trivial()

    interpret_response = asker.ask(interpret_input(view, input), handler=relayer)
    if interpret_response.has_answer():
        bindings = dictionaries.to_dict(asker, fields.get(asker, bindings_field(), view))
        bindings_str = {strings.to_str(asker, k):v for k, v in bindings.items()}
        for char in "xyzw" + string.letters:
            if char not in bindings_str:
                break
        asker.update(bind_variable(T.from_str(char), interpret_response.answer), view)
        new_line = strings.concat(
            T.from_str("{} = ".format(char)),
            input
        )
        asker.update(add_line(new_line), view)
    return asker.reply()
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:47,代码来源:views.py


示例20: complex_dict

def complex_dict(base=None, **kwargs):
    if base is None:
        base = {}
    to_make = dict(base, **kwargs)
    result = quote(T.empty_dict())
    for name, value in to_make.items():
        result = dict_cons(quote_str(name), value, result)
    return result
开发者ID:paulfchristiano,项目名称:interpreter,代码行数:8,代码来源:computations.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python board.Board类代码示例发布时间:2022-05-27
下一篇:
Python loggers.getLogger函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap