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

Python match.Match类代码示例

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

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



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

示例1: startGame

	def startGame(self):
		playerNumber = input("'one' player or 'two' players?\n")
		
		#pull this out
		if playerNumber == "two":
			player1 = Human()
			player2 = Human()
		elif playerNumber == "one":
			player1 = Human()
			player2 = AI()
		####

	
		match = Match()


		while match.matchNumber < 3:
			match.countMatches()
			match.startMatch(player1, player2)

			if player1.wins >= 2 or match.matchNumber == 3 and player1.wins > player2.wins:
				self.winner = "Player 1!"
				break
			elif player2.wins >= 2 or match.matchNumber == 3 and player2.wins > player1.wins:
				self.winner = "Player 2!"
				break
开发者ID:LouieLightning,项目名称:rockPaperScissors,代码行数:26,代码来源:game.py


示例2: test_match_full_sentences

def test_match_full_sentences():
    for (test_sentence, gold_result) in zip(test_sentences, gold_results_all_sentences):
        sys.stderr.write("gold: " + str(gold_result) + "\n")
        sys.stderr.write("test: " + str(test_sentence) + "\n")
        if sys.version_info[0] >= 3:
            eq_(gold_result, Match.match(test_text, test_sentence))
        else:
            eq_(gold_result, Match.match(test_text.decode("utf8"), test_sentence))
        sys.stderr.write("\n")
开发者ID:EducationalTestingService,项目名称:match,代码行数:9,代码来源:test_match.py


示例3: BlackJackTable

class BlackJackTable(cmd.Cmd):
    minbet = 3
    maxbet = 10
    intro = (
        "Welcome to the blackjack table. Type help or ? to list commands.\n The minimum bet is %s dollars, the maximum bet is %s dollars\n"
        % (minbet, maxbet)
    )
    prompt = "(input) "
    file = None

    # Instructions
    def do_start(self, arg):
        "Starts a game"
        self.match = Match(table=self)
        self.do_display(None)

    def feedback(self, question):
        return input(question)

    def do_hitme(self, arg):
        "Hit me"
        self.match.hit()
        self.do_display(None)

    def do_bet(self, arg):
        "Bet an amount of money"

    def do_buyIn(self, arg):
        "Buy a certain amount of chips"
        self.match.playerBuysIn(*parse(arg))

    def do_deck(self, arg):
        "Fix the number of decks be used: deck 6"
        self.math.newDecks(*parse(arg))

    def do_changeDefault(self, arg):
        "Change the default amount for a bet: changeDefault 3 10"
        if parse(arg)[0] >= parse(arg)[1]:
            print("Ensure that minimum is lower than the maximum")
        else:
            (BlackJackTable.minbet, BlackJackTable.maxbet) = parse(arg)

    def do_rules(self, arg):
        "Print the current rules"
        print("The minimum bet is " + str(BlackJackTable.minbet) + " and maximum is " + str(BlackJackTable.maxbet))

    def do_display(self, arg):
        "Display your hand"
        print(self.match)

    def do_quit(self, arg):
        "Quit the game"
        print("Thanks for visiting.")
        return True
开发者ID:JeromeLefebvre,项目名称:CardsForTheWorkingMathematician,代码行数:54,代码来源:table.py


示例4: test_winner

    def test_winner(self):
        game1 = Game(Team("Cate"), Team("Opponent1"), Team("Cate"))
        game2 = Game(Team("Cate"), Team("Opponent1"), Team("Cate"))
        games = []
        for x in range(0, 6):
            games.append(game1)
        set1 = Set(games)
        sets = []
        for x in range(0, 18):
            sets.append(set1)

        match1 = Match(sets, game1.teamA, game1.teamB)
        self.assertEqual(game1.teamA, match1.winner())
开发者ID:juliasgan,项目名称:tennis_tracker,代码行数:13,代码来源:test_match.py


示例5: get_true_true

def get_true_true(result, index, param, mass):
	true_true = []
	for i in range(len(result)):
		title = result[i][0]
		spec = index.spec_dict[title]
		ch = spec.ch

		candidate = []
		sum_int = []
		for j in range(len(result[i][1])):
			pep1 = index.unique_pep[0][result[i][1][j][0][0]]
			pep2 = index.unique_pep[0][result[i][1][j][0][1]]
			sl = [set(), set()]
			pos = result[i][1][j][1]

			for pro in pep1.pro_id:
				cols = pro.split('|R')
				if len(cols) > 1 and len(cols[1]) > 0:
					sl[0].add(cols[1][0])

			for pro in pep2.pro_id:
				cols = pro.split('|R')
				if len(cols) > 1 and len(cols[1]) > 0:
					sl[1].add(cols[1][0])

			feature = list(result[i][1][j][2][0])
			feature.extend(result[i][1][j][2][1])
			if feature[0] / float(feature[7]) >= 0.20 and feature[1] / float(feature[7]) >= 0.20 and feature[8] / float(feature[15]) >= 0.20 and feature[9] / float(feature[15]) >= 0.20 and feature[2] >= 0.1 and feature[10] >= 0.1 and (len(sl[0]) == 0 or len(sl[1]) == 0 or len(sl[0].intersection(sl[1]))) > 0:
				xl = XLink(pep1, pep2, pos, ch, mass, param)
				match = Match(spec, xl, mass, param)
				match.match(mass)

				candidate.append(match)
				sum_int.append(feature[2] + feature[10])

		if len(candidate) == 0:
			continue
		combo = zip(candidate, sum_int)
		candidate = list(zip(*sorted(combo, key = lambda x : x[1], reverse = True))[0])
		sum_int = list(zip(*sorted(combo, key = lambda x : x[1], reverse = True))[1])
		true_true.append(candidate[0])

	for i in range(len(true_true)):
		pep1 = true_true[i].xlink.pep[0]
		pep2 = true_true[i].xlink.pep[1]
		s = pep1.seq + '\t' + pep2.seq + '\t' + ','.join(pep1.pro_id) + '\t' + ','.join(pep2.pro_id)
		print s

	if len(true_true) < 150:
		print '\nWARNING: The number of True-True PSMs(' + str(len(true_true)) + ') is too small and maybe insufficient for training an reliable model!\n'
	return true_true
开发者ID:COL-IU,项目名称:XLSearch,代码行数:51,代码来源:utility.py


示例6: parse

 def parse(self, textfile = None):
     if textfile is not None:
         self.textfile = textfile
     if self.textfile is None:
         return False
     text = self.textfile.get_src_text()
     m = Match(r"(?s)\/\*[*]+(?=\s)"
               r"((?:.(?!\*\/))*.)\*\/"
               r"([^/\{\}\;\#]+)[\{\;]")
     self.children = []
     for found in m.finditer(text):
         child = FunctionHeader(self, found.group(1), found.group(2))
         self.children += [ child ]
     return len(self.children) > 0
开发者ID:Distrotech,项目名称:zziplib,代码行数:14,代码来源:functionheader.py


示例7: get_matches_per_spec

def get_matches_per_spec(mass, param, index, title):
	spec_dict = index.spec_dict
	unique_pep = index.unique_pep[0]
#	search_index = index.search_index
	x_residue = param['x_residue']

	index_list = index.get_candidates(title)
	spec = spec_dict[title]

	matches = []
	for i in range(len(index_list)):
		index1 = index_list[i][0]
		index2 = index_list[i][1]
		
		pep1 = unique_pep[index1]
		pep2 = unique_pep[index2]

		pep_sorted = sorted([pep1, pep2], key = lambda x : x.seq)
		pep1 = pep_sorted[0]
		pep2 = pep_sorted[1]

		ch = spec_dict[title].ch

		mz = spec_dict[title].mz
		it = spec_dict[title].it

		k_pos1 = []
		k_pos2 = []
		if param['ntermxlink'] == True:
			if pep1.is_nterm == True:
				k_pos1.append(0)
			if pep2.is_nterm == True:
				k_pos2.append(0)

		pep_seq1 = pep1.seq
		k_pos1.extend(list(zip(*filter(lambda x : x[1] == x_residue, enumerate(pep_seq1[:-1])))[0]))
		pep_seq2 = pep2.seq
		k_pos2.extend(list(zip(*filter(lambda x : x[1] == x_residue, enumerate(pep_seq2[:-1])))[0]))

		for p1 in k_pos1:
			for p2 in k_pos2:
				pos = [p1, p2]
				xl = XLink(pep1, pep2, pos, ch, mass, param)
			
				match = Match(spec, xl, mass, param)
				match.match(mass)
				matches.append(match.get_match_info(index))

	return matches
开发者ID:COL-IU,项目名称:XLSearch,代码行数:49,代码来源:utility.py


示例8: matchobj

def matchobj(daf_num, amud, text):
    new_shas =[]
    index = (daf_num-2)*2
    if amud=="b":
        index= index + 1
    list =text.split(" ")
    string= " ".join(list[0:7])
    string = re.sub(ur'(?:@|[0-9]|<|>|b|\[|\*|\])',"",string)
    match_obj = Match(min_ratio=50, guess =True)
    for line in shas[index]:
        new_line = re.sub(ur'<[^<]+?>',"",line)
        new_shas.append(new_line)
    #print string, daf_num, amud
    results = match_obj.match_list([string], new_shas)
    return(results)
开发者ID:BenjaminKozuch,项目名称:Sefaria-Data,代码行数:15,代码来源:rosh_menachot.py


示例9: parse

 def parse(self, functionheader = None):
     if functionheader is not None:
         self.functionheader = functionheader
     if self.functionheader is None:
         return False
     found = Match()
     prototype = self.get_prototype()
     if prototype & found(r"(?s)^(.*[^.])"
                          r"\b(\w[\w.]*\w)\b"
                          r"(\s*\(.*)$"):
         self.prespec = found.group(1).lstrip()
         self.namespec = found.group(2)
         self.callspec = found.group(3).lstrip()
         self.name = self.namespec.strip()
         return True
     return False
开发者ID:Distrotech,项目名称:zziplib,代码行数:16,代码来源:functionprototype.py


示例10: catch_content

    def catch_content(self):
        question_id = Match.question(self.url).group('question_id')
        question_obj = self.client.question(int(question_id))
        # TODO: hyperlink, pictures, Youku links
        bulk_data = list()
        bulk_data.append({
            '_index': 'zhihu',
            '_type': 'question',
            '_id': question_obj.id,
            '_op_type': 'update',
            '_source': {'doc': question_obj.pure_data, 'doc_as_upsert': True}
        })

        for item in question_obj.answers:
            if item.pure_data['cache'] is not None:
                doc_data = item.pure_data['cache']
            else:
                doc_data = item.pure_data['data']
            doc_data.update({'content': item.content})
            _source_data = {'doc': doc_data, 'doc_as_upsert': True}
            bulk_data.append({
                '_index': 'zhihu',
                '_type': 'answer',
                '_id': item.id,
                '_op_type': 'update',
                '_source': _source_data
            })
        helpers.bulk(self.es, bulk_data)
开发者ID:knarfeh,项目名称:EE-Book,代码行数:28,代码来源:question.py


示例11: setUp

 def setUp(self):
     json = {  
                "_links":{  
                   "self":{  
                      "href":"http://api.football-data.org/v1/fixtures/153572"
                   },
                   "competition":{  
                      "href":"http://api.football-data.org/v1/competitions/433"
                   },
                   "homeTeam":{  
                      "href":"http://api.football-data.org/v1/teams/679"
                   },
                   "awayTeam":{  
                      "href":"http://api.football-data.org/v1/teams/676"
                   }
                },
                "date":"2016-08-26T18:00:00Z",
                "status":"TIMED",
                "matchday":4,
                "homeTeamName":"Vitesse Arnhem",
                "awayTeamName":"FC Utrecht",
                "result":{  
                   "goalsHomeTeam":0,
                   "goalsAwayTeam":0
                },
                "odds":{}
             }
     self.match = Match(json)
开发者ID:dimoynwa,项目名称:DLivescore,代码行数:28,代码来源:test_match.py


示例12: match_and_link

def match_and_link(text, masechet):
	match = Match(in_order=True, min_ratio=80, guess=False, range=True, can_expand=False)
	for daf_count, daf in enumerate(text):
		dhs = []
		comments = []
		for each_line in daf:
			if each_line.find("כו'") >= 0:
				dh, comment = each_line.split("כו'", 1)
			elif each_line.find(".") >= 0:
				dh, comment = each_line.split(".", 1)
			else:
				dh, comment = splitText(each_line, 10)
			dhs.append(dh)
			comments.append(comment)
		pdb.set_trace()
		talmud_text = get_text_plus(masechet+"."+AddressTalmud.toStr("en", daf_count+3))['he']
		result = match.match_list(dhs, talmud_text)
开发者ID:agvania,项目名称:Sefaria-Data,代码行数:17,代码来源:parse.py


示例13: post

def post(text, dh_dict, tractate):
     text_array = convertDictToArray(text)
     send_text = {
         "text": text_array,
         "versionTitle": "Ramban on Talmud",
         "versionSource": "http://www.sefaria.org",
         "language": "he"
     }
     post_text("Chiddushei Ramban on "+tractate, send_text)
     links_to_post = []
     daf_array = get_text_plus(tractate)['he']
     match = Match(in_order=True, min_ratio=80, guess=False, range=True, can_expand=False)
     for daf in sorted(dh_dict.keys()):
         dh_list = dh_dict[daf]
         results = match.match_list(dh_list, daf_array[daf-1], tractate+" "+AddressTalmud.toStr("en", daf))
         for key, value in results.iteritems():
             value = value.replace("0:", "")
             talmud_end = tractate + "." + AddressTalmud.toStr("en", daf) + "." + value
             ramban_end = "Chiddushei_Ramban_on_" + tractate + "." + AddressTalmud.toStr("en", daf) + "." + str(key)
             links_to_post.append({'refs': [talmud_end, ramban_end], 'type': 'commentary', 'auto': 'True', 'generated_by': "ramban"+tractate})
     post_link(links_to_post)
开发者ID:joshuagoldmeier,项目名称:Sefaria-Data,代码行数:21,代码来源:ramban.py


示例14: __init__

 def __init__(self, director, background_match):
     '''
     Constructor
     '''
     Scene.__init__(self, director, background_match)        
     self.match = Match()
     self.scene_winner =  Sce_Winner(director, 'winner', MATCH_SCENE)
     self.c_fails = 0
     
     self.match.generate_table()
     for buttom in self.common_buttoms.itervalues():
         buttom.is_visible = True
开发者ID:NightZpy,项目名称:QuimicaDidactica,代码行数:12,代码来源:sce_match.py


示例15: match_zero_or_more

 def match_zero_or_more(self, text, index=0):
     """
     Accumulates zero or more matches into a single Match object.
     This will always return a Match, (0 or 1) = true
     """
     accumulated_match = Match(index, '')
     while True:
         start_index = index + len(accumulated_match.text)
         match = self.match_all_sub_queries(text, start_index)
         if match and match.index == start_index:
             accumulated_match = Match.join_matches([accumulated_match, match])
         else: break
     return accumulated_match
开发者ID:lwakefield,项目名称:triplebyte_regex,代码行数:13,代码来源:query.py


示例16: fix_image

    def fix_image(self, content, recipe):
        content = Match.fix_html(content=content, recipe_kind=recipe)
        for img in re.findall(r'<img[^>]*', content):
            if recipe not in [Type.sinablog_author, Type.cnblogs_author]:
                # fix img
                if img[-1] == '/':
                    img = img[:-1]
            img += '>'
            src = re.search(r'(?<=src=").*?(?=")', img)
            if not src:
                new_image = img + '</img>'
                content = content.replace(img, new_image)
                continue
            else:
                src = src.group(0)
                if src.replace(' ', '') == '':
                    new_image = img + '</img>'
                    content = content.replace(img, new_image)
                    continue
            src_download = HtmlCreator.fix_image_src(src)
            if src_download:
                if recipe in Type.zhihu and not src_download.startswith('http'):
                    # fix zhuanlan image href
                    src_download = src_download.split('.')[0]
                    filename = self.image_container.add('https://pic2.zhimg.com/'+src_download+'_b.jpg')
                elif recipe in Type.generic:
                    filename = ''    # TODO
                else:
                    filename = self.image_container.add(src_download)
            else:
                filename = ''
            new_image = img.replace('"{}"'.format(src), '"../images/{}"'.format(filename))

            if recipe in Type.jianshu:
                new_image = new_image.replace('data-original-src', 'temppicsr')
                new_image = new_image.replace('src', 'falsesrc')
                new_image = new_image.replace('temppicsr', 'src')    # 应该有更好的方式, 暂时先这样写
                new_image += '</img>'
            elif recipe in Type.sinablog:
                # 硬编码, 可以优化?写到fix_html函数中
                new_image = new_image.replace('http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif',\
                                          '../images/{}'.format(filename))
            elif recipe in Type.zhihu:
                new_image = new_image.replace('//zhstatic.zhihu.com/assets/zhihu/ztext/whitedot.jpg',
                                              '../images/{}'.format(filename))
                new_image += '</img>'
            elif recipe in Type.cnblogs:
                pass
            content = content.replace(img, '<div class="duokan-image-single">{}</div>'.format(new_image))

        return content
开发者ID:bindx,项目名称:EE-Book,代码行数:51,代码来源:html_creator.py


示例17: main

def main():
    '''
    Main function permits to launch a match of Quarto
    It permits also to modify game configuration (mainly players attributes)
    '''

    hostname = None
    if len(argv) == 2:
        hostname = argv[1]

    configuration = {
        'name_player1': 'Mr. R',
        'name_player2': 'Mr. N',
        'intelligence_player1': Minimax(3),
        'intelligence_player2': Minimax(4),
        'hostname': hostname
    }

    choice = None

    while choice != "q":
        ui.showMenu()
        try:
            choice = ui.askChoice(("p", "t", "c", "q")).lower()
        except EOFError:
            choice = "q"

        if choice == "p":
            match = Match(configuration)
            match.run()
        elif choice == "t":
            try:
                tournament = Tournament(configuration)
                tournament.run()
            except Exception, e:
                print e
        elif choice == "c":
            configuration = change_configuration()
开发者ID:marienfressinaud,项目名称:AI_quarto,代码行数:38,代码来源:quarto.py


示例18: match_all_sub_queries

    def match_all_sub_queries(self, text, index=0):
        """
            Recursively matches all subqueries in this Query.
            This function searches left to right for matches to subqueries.
            For each subquery, if a match is found, then:
                if it is adjacent to the last match or it is the first match
                    for this query, we add it to the matches array
                otherwise, we empty the matches array and start searching from
                    the first subquery again
            If at any point no match for a subquery is found, we return None
            Once we have found matches for all subqueries, we join all matches
                into a single Match object, which is then returned.
        """
        while index < len(text):
            matches = []
            for i, query in enumerate(self.queries):
                match = None
                if type(query) is str:
                    found_index = text.find(query, index)
                    match = Match(found_index, query)
                else:
                    match = query.match(text, index)

                if match is None or match.index == -1: return None

                if matches == [] or index == match.index:
                    index = match.index + len(match.text)
                    matches.append(match)
                elif index != 0 and index != match.index:
                    curr_match = Match.join_matches(matches)
                    if len(curr_match.text) == 0:
                        index += 1
                    break
                else:
                    return None
            else:
                return Match.join_matches(matches)
        return None
开发者ID:lwakefield,项目名称:triplebyte_regex,代码行数:38,代码来源:query.py


示例19: post

def post(text, dh_dict):
     actual_text = {}
     for perek in text:
         actual_text[perek] = convertDictToArray(text[perek])
     text_to_post = convertDictToArray(actual_text)
     send_text = {"text":text_to_post,
                         "versionTitle":"OYW",
                        "versionSource": "http://mobile.tora.ws/",
                        "language":"he"
                         }
     post_text("Gur Aryeh on "+book, send_text)

     links = []
     for perek in dh_dict:
        for passuk in dh_dict[perek]:


            dh_list = dh_dict[perek][passuk]
            rashi_text = get_text_plus("Rashi on "+book+"."+str(perek)+"."+str(passuk))['he']
            match_out_of_order = Match(in_order=False, min_ratio=85, guess=True, range=True, can_expand=False)
            results = match_out_of_order.match_list(dh_orig_list=dh_list, page=rashi_text, ref_title="Gur Aryeh")
            for dh_pos in results:
                result = results[dh_pos].replace("0:","")
                if result.find('-')>=0:
                    x,y = result.split('-')
                    if int(x)>int(y):
                        pdb.set_trace()
                links.append({
                    "refs": [
                        "Rashi on "+book+"."+str(perek)+"."+str(passuk)+"."+result,
                        "Gur Aryeh on "+book+"."+str(perek)+"."+str(passuk)+"."+str(dh_pos)
                    ],
                    "type": "commentary",
                    "auto": True,
                    "generated_by": "Gur Aryeh on "+book+" linker"})
     	post_link(links)
     	links = []
开发者ID:JonMosenkis,项目名称:Sefaria-Data,代码行数:37,代码来源:gur_aryeh.py


示例20: catch_content

    def catch_content(self):
        column_id = Match.column(self.url).group("column_id")
        print("column_id: {}".format(column_id))
        headers = {
          'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Mobile Safari/537.36'
        }

        r = requests.get(
            url="https://zhuanlan.zhihu.com/api/columns/{}".format(column_id),
            headers=headers
        )
        columns_info = json.loads(r.text)
        print("Got column info: {}".format(columns_info["intro"] if columns_info["intro"] != '' else 'None'))

        offset = 0
        for offset in range(0, int(columns_info["postsCount"]), 50):
            self.send_bulk(headers, column_id, offset, 50, columns_info)
        self.send_bulk(headers, column_id, offset, columns_info["postsCount"]-offset, columns_info)
开发者ID:knarfeh,项目名称:EE-Book,代码行数:18,代码来源:column.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python matching.max_cardinality_matching函数代码示例发布时间:2022-05-27
下一篇:
Python match.match函数代码示例发布时间: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