本文整理汇总了Python中model.Model.read方法的典型用法代码示例。如果您正苦于以下问题:Python Model.read方法的具体用法?Python Model.read怎么用?Python Model.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Model
的用法示例。
在下文中一共展示了Model.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import read [as 别名]
#
#########################
sys.stderr.write('Loading ngrams\n')
with open(sys.argv[ngramfileix],'r',encoding='latin-1') as ngramFile:
unigrams = Model('U')
w_giv_min_u = Model('UBF')
w_giv_min = CondModel('BF')
w_giv_min_bak = Model('UBBF')
w_giv_plus_u = Model('UBB')
w_giv_plus = CondModel('BB')
w_giv_plus_bak = Model('UBBB')
for ix, line in enumerate(ngramFile.readlines()):
unigrams.read(line)
w_giv_min.read(line)
w_giv_plus.read(line)
w_giv_min_bak.read(line)
w_giv_plus_bak.read(line)
if ix % 1000000 == 0:
sys.stderr.write(' Loaded '+str(ix)+'\n')
#########################
#
# Compute ngrams for corpus
#
#########################
corpus = []
示例2: MemorizeGame
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import read [as 别名]
class MemorizeGame(GObject.GObject):
__gsignals__ = {
'reset_scoreboard': (GObject.SignalFlags.RUN_FIRST, None, []),
'reset_table': (GObject.SignalFlags.RUN_FIRST, None, []),
'load_mode': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'load_game': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'change_game': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'change_game_signal': (GObject.SignalFlags.RUN_FIRST, None,
5 * [GObject.TYPE_PYOBJECT]),
'set-border': (GObject.SignalFlags.RUN_FIRST, None,
3 * [GObject.TYPE_PYOBJECT]),
'flip-card': (GObject.SignalFlags.RUN_FIRST, None, [int, bool]),
'flip-card-signal': (GObject.SignalFlags.RUN_FIRST, None, [int]),
'cement-card': (GObject.SignalFlags.RUN_FIRST, None, [int]),
'flop-card': (GObject.SignalFlags.RUN_FIRST, None, [int]),
'highlight-card': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'add_buddy': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'rem_buddy': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'increase-score': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]),
'wait_mode_buddy': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'msg_buddy': (GObject.SignalFlags.RUN_FIRST, None,
2 * [GObject.TYPE_PYOBJECT]),
'change-turn': (GObject.SignalFlags.RUN_FIRST, None,
[GObject.TYPE_PYOBJECT]), }
def __init__(self):
GObject.GObject.__init__(self)
self.myself = None
self.players_score = {}
self.players = []
self.waiting_players = []
self.current_player = None
self.last_flipped = -1
self.last_highlight = 1
self._flop_card_timeout = -1
self.messenger = None
self.sentitive = True
self.model = Model()
self.flip_block = False
self._flop_cards = None
self.audio = Audio()
self._audio_play_finished_id = 0
def load_game(self, game_name, size, mode):
self.set_load_mode('Loading game')
if self.model.read(game_name) == 0:
logging.debug('load_game set is_demo mode %s', mode)
self.model.is_demo = (mode == 'demo')
self.model.def_grid(size)
self.model.data['running'] = 'False'
self.model.data['mode'] = mode
logging.debug(' Read setup file %r: %r ',
game_name, self.model.grid)
self.emit('load_game', self.model.data, self.model.grid)
else:
logging.error(' Reading setup file %s', game_name)
def load_remote(self, grid, data, mode, signal=False):
self.set_load_mode(_('Loading game...'))
self.model.grid = grid
self.model.data = data
self.model.data['mode'] = mode
self.emit('reset_scoreboard')
if not signal:
self.emit('change_game_signal', mode, self.get_grid(),
self.model.data, self.waiting_players,
self.model.data['game_file'])
self.emit('change_game', self.model.data, self.get_grid())
for buddy in self.players:
self.players_score[buddy] = 0
self.current_player = None
self.last_flipped = -1
self.last_highlight = 1
self.change_turn()
self.model.data['running'] = 'False'
for card in self.model.grid:
if card['state'] == '1':
self.emit('flip-card', self.model.grid.index(card), False)
self.last_flipped = self.model.grid.index(card)
elif card['state'] != '0':
stroke_color, fill_color = card['state'].split(',')
self.emit('flip-card', self.model.grid.index(card), False)
self.emit('set-border', self.model.grid.index(card),
stroke_color, fill_color)
logging.debug('load_remote set is_demo mode %s', mode)
if mode != 'reset':
self.model.is_demo = (mode == 'demo')
#.........这里部分代码省略.........
示例3: Model
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import read [as 别名]
#python scripts/filterLexicon.py wordcounts
# flags all words that are not in the wordcounts file
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg', 'scripts'))
from model import Model
lexicon = Model('L')
with open(sys.argv[1],'r') as lexFile:
for line in lexFile.readlines():
lexicon.read(line)
FIRST = True
header = []
for line in sys.stdin.readlines():
sline = line.strip().split()
if FIRST:
sys.stdout.write(line[:-1] + ' unknown\n')
FIRST = False
continue
if lexicon[sline[0]] > 4:
#known word
sys.stdout.write(line[:-1]+ ' False\n')
else:
#unknown word
sys.stdout.write(line[:-1]+ ' True\n')