本文整理汇总了Python中match.Match类的典型用法代码示例。如果您正苦于以下问题:Python Match类的具体用法?Python Match怎么用?Python Match使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Match类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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")
示例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
示例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())
示例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
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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
示例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