Merge pull request #2 from reimannsum/patch-3

Patch 3
This commit is contained in:
reimannsum 2015-10-30 12:35:47 -04:00
commit 2404095ef1
3 changed files with 123 additions and 2 deletions

View file

@ -553,7 +553,7 @@ class Card:
return outstr
def format(self, gatherer = False, for_forum = False, for_mse = False, vdump = False):
def format(self, gatherer = False, for_forum = False, for_mse = False, vdump = False, for_html = False):
outstr = ''
if gatherer:
cardname = titlecase(transforms.name_unpass_1_dashes(self.__dict__[field_name]))
@ -634,6 +634,60 @@ class Card:
outstr += '[/i]'
outstr += '\n'
elif for_html:
outstr += '<div class="card-text">'
cardname = self.__dict__[field_name]
#cardname = transforms.name_unpass_1_dashes(self.__dict__[field_name])
outstr += "<h5>" + cardname + "</h5>"
if self.__dict__[field_rarity]:
if self.__dict__[field_rarity] in utils.json_rarity_unmap:
rarity = utils.json_rarity_unmap[self.__dict__[field_rarity]]
else:
rarity = self.__dict__[field_rarity]
outstr += ' (<b>' + rarity.lower() + '</b>)'
outstr += '\n'
# I need the simple formatting with '{'
coststr = self.__dict__[field_cost].format()
if vdump or not coststr == '_NOCOST_':
outstr += coststr.replace("/","-").replace("{",'<img src="~/mtgencode/Icons/' ).replace("}",'-mana;.png" >')
outstr += '\n'
outstr += ' <b>'.join(self.__dict__[field_supertypes] + self.__dict__[field_types])
if self.__dict__[field_subtypes]:
outstr += ' ' + utils.dash_marker + ' ' + ' '.join(self.__dict__[field_subtypes])
outstr += '</b>\n'
if self.__dict__[field_text].text:
mtext = self.__dict__[field_text].text
mtext = transforms.text_unpass_1_choice(mtext, delimit = True)
#mtext = transforms.text_unpass_2_counters(mtext)
#mtext = transforms.text_unpass_3_uncast(mtext)
mtext = transforms.text_unpass_4_unary(mtext)
mtext = transforms.text_unpass_5_symbols(mtext, for_forum)
#mtext = transforms.text_unpass_6_cardname(mtext, cardname)
mtext = transforms.text_unpass_7_newlines(mtext)
#mtext = transforms.text_unpass_8_unicode(mtext)
newtext = Manatext('')
newtext.text = mtext
newtext.costs = self.__dict__[field_text].costs
outstr += newtext.format().replace("/","-").replace("{",'<img src="~/mtgencode/Icons/' ).replace("}",'-mana;.png" >') + '\n'
if self.__dict__[field_pt]:
outstr += '(' + utils.from_unary(self.__dict__[field_pt]) + ')'
outstr += '\n'
if self.__dict__[field_loyalty]:
outstr += '((' + utils.from_unary(self.__dict__[field_loyalty]) + '))'
outstr += '\n'
if vdump and self.__dict__[field_other]:
outstr += utils.dash_marker * 2
outstr += '\n'
for idx, value in self.__dict__[field_other]:
outstr += '<' + str(idx) + '> ' + str(value)
outstr += '\n'
else:
cardname = self.__dict__[field_name]
#cardname = transforms.name_unpass_1_dashes(self.__dict__[field_name])
@ -694,7 +748,10 @@ class Card:
outstr += '\n'
if self.bside:
outstr += utils.dash_marker * 8 + '\n'
if for_html:
outstr += "<hr>\n"
else:
outstr += utils.dash_marker * 8 + '\n'
outstr += self.bside.format(gatherer = gatherer, for_forum = for_forum)
return outstr

View file

@ -0,0 +1,47 @@
#!/bin/bash
#every 30 min
rnn_home=~/mtg-rnn
output_home=~/mtgencode/cards
# setting output parameters
length=10000
temperature=0.5
## */30 * * * * ~/mtgencode/scripts/crons/make_output.sh
if [[ $(pgrep -l 'luajit' | sed s/'[0-9]* '// ) =~ 'luajit' ]]; then
echo Training running, exiting cron
exit 0
fi
cd $rnn_home
for folder in $( ls cv); do
echo $folder
#I have my folders labeled by' {data_dir}-{rnn_size}_{dropout}"
# I can't decide of I want to remove {rnn_size} and {dropout} from output
#folder name
## dir_name=$(echo $folder | sed s/-[1-9][1-9][1-9]_0.[0-9]*//g)
dir_name=$folder
if [ ! -e $output_home/$dir_name ]; then
mkdir $output_home/$dir_name
fi
for file in $( ls cv/$folder); do
o_file=$(echo $file | sed s/lm_lstm_epoch/e/)
o_file=$(echo ${o_file} | sed s/_[0-9].[0-9]*//g)
o_file=$(echo ${o_file} | sed s/.t7//)
o_file=$(echo ${o_file}-${temperature})
#if file exists don't make a new one
if [ -e $output_home/$dir_name/$o_file/output.txt ];then
#echo "output for $file already exists"
continue
fi
#if the directory doesn't exist make it
if [ ! -e ./$output_home/$dir_name/$o_file ]; then
mkdir $output_home/$dir_name/$o_file
fi
th $rnn_home/sample_hs_v3.lua cv/$folder/$file -gpuid -1 -temperature $temperature -length $length | tee $output_home/$dir_name/$o_file/output.txt
done
done
# rsync to remote storage device
rsync -hruv -e 'ssh -p 2022' $output_home/mtgencode/cards/ host@ip:/mtgencode/cards

View file

@ -0,0 +1,17 @@
#!/bin/bash
# every 5 min
## */30 * * * * ~/mtgencode/scripts/crons/process_output.sh
cd ~/mtgencode/cards
for folder in $(ls); do
for sub in ${ ls ${folder} };do
if [ ! -e $folder/$sub/summary.txt ]; then
./scritps/summarize.py -a -v $folder/$sub/output.txt > summary.txt
fi
if [ ! -e $folder/$sub/cards.txt ]; then
.decode.py -v -f $folder/$sub/output.txt $folder/$sub/cards.txt
fi
done
done