示例#1
0
def main():
    # def main(args):
    """main body"""

    json_data = []

    root_dir = os.path.dirname(os.path.realpath(__file__))

    for (source_dir, dir_list, file_list) in os.walk(root_dir):
        if dir_list == ['.git', 'output']:
            for file_name in file_list:
                if ".xlsx" in file_name:
                    parse.main(file_name, json_data)

    # write out json
    print_out = open('output/eiti.json', 'w')
    print_out.write(json.dumps(json_data, indent=4, separators=(',', ':')))
    print_out.close()

    # write out csv
    csv_out.main(json_data)

    # write out normalised data
    gfs_codes = reprocess.get_gfs()
    reprocess(gfs_codes)
示例#2
0
def main():
    # Parse the original dataset
    print("Parsing of original data...")
    parse.main(original_file, parsed_file, prefix)
    # Create features from the dataset
    print("Creating additional features...")
    add_features.main(parsed_file, rain_dataset, added_features_file)

    # Merge the three files : parsed_file, added_features_file and
    # distances_features_file into merged_file
    print("Merging all features...")
    parsed_df = pd.read_csv(parsed_file)
    added_features_df = pd.read_csv(added_features_file)
    distances_features_df = pd.read_csv(distances_features_file)
    # how="left" replace missing ORSM values by NaNs (dunno how to replace by zeros)
    merged_df = pd.merge(parsed_df,
                         pd.merge(added_features_df,
                                  distances_features_df,
                                  on='id',
                                  how='left'),
                         on='id')
    merged_df.to_csv(merged_file, index=False)

    # Do not clean the test set
    if prefix == "train":
        # Clean the final dataset
        print("Cleaning data...")
        clean.main(merged_file, merged_file)
示例#3
0
文件: __init__.py 项目: xshi/dhad
def main(opts, args):
    if args[0] == 'lumi':
	import lumi
	lumi.main(opts, args[1:])
    elif args[0] == 'compare':
	import compare
	compare.main(opts, args[1:])
    elif args[0] == 'combine':
	import combine
	combine.main(opts, args[1:])
    elif args[0] == 'divide':
	import divide
	divide.main(opts, args[1:])
    elif args[0] == 'para':
	import para
	para.main(opts, args[1:])
    elif args[0] == 'entries':
	import entries
	entries.main(opts, args[1:])
    elif args[0] == 'brf':
	import brf
	brf.main(opts, args[1:])
    elif args[0] == 'diff':
	import diff
	diff.main(opts, args[1:])
    elif args[0] == 'cuts':
	import cuts
	cuts.main(opts, args[1:])
    elif args[0] == 'parse':
	import parse
	parse.main(opts, args[1:])
    elif args[0] == 'backgrounds':
	import backgrounds
	backgrounds.main(opts, args[1:])
    elif args[0] == 'cbx':
	import cbx
	cbx.main(opts, args[1:])
    elif args[0] == 'sld':
	import sld
	sld.main(opts, args[1:])
    elif args[0] == 'web':
	import web
	web.main(opts, args[1:])
    elif args[0] == 'mctruth':
	import mctruth
	mctruth.main(opts, args[1:])
    elif args[0] == 'ths':
	import ths
	ths.main(opts, args[1:])
    elif args[0] == 'prd':
	import prd
	prd.main(opts, args[1:])
    else:
	raise NameError(args)
示例#4
0
def main(opts, args):
    if args[0] == 'lumi':
        import lumi
        lumi.main(opts, args[1:])
    elif args[0] == 'compare':
        import compare
        compare.main(opts, args[1:])
    elif args[0] == 'combine':
        import combine
        combine.main(opts, args[1:])
    elif args[0] == 'divide':
        import divide
        divide.main(opts, args[1:])
    elif args[0] == 'para':
        import para
        para.main(opts, args[1:])
    elif args[0] == 'entries':
        import entries
        entries.main(opts, args[1:])
    elif args[0] == 'brf':
        import brf
        brf.main(opts, args[1:])
    elif args[0] == 'diff':
        import diff
        diff.main(opts, args[1:])
    elif args[0] == 'cuts':
        import cuts
        cuts.main(opts, args[1:])
    elif args[0] == 'parse':
        import parse
        parse.main(opts, args[1:])
    elif args[0] == 'backgrounds':
        import backgrounds
        backgrounds.main(opts, args[1:])
    elif args[0] == 'cbx':
        import cbx
        cbx.main(opts, args[1:])
    elif args[0] == 'sld':
        import sld
        sld.main(opts, args[1:])
    elif args[0] == 'web':
        import web
        web.main(opts, args[1:])
    elif args[0] == 'mctruth':
        import mctruth
        mctruth.main(opts, args[1:])
    elif args[0] == 'ths':
        import ths
        ths.main(opts, args[1:])
    elif args[0] == 'prd':
        import prd
        prd.main(opts, args[1:])
    else:
        raise NameError(args)
示例#5
0
def main():
    parse.main()
    wait_enter()

    search.main()
    wait_enter()

    test.main()
    wait_enter()

    summary.main()
def main(argv):
    one = parse.main(argv[1])
    two = parse.main(argv[2])
    three = parse.main('silicon laboratories')
    print(one)

    res1 = PredictStock(argv[1], one)
    res2 = PredictStock(argv[2], two)
    res3 = PredictStock(argv[3], three)
    if (res1 > res2 and res1 > res3):
        print("Invest in NRCIB")
    elif (res2 > res1 and res2 > res3):
        print("Invest in NVCN")
    else:
        print("Invest in Silicon Labratories")
示例#7
0
def get_quakes():
    #URL="http://10.1.1.15/quake.html"
    #raw=requests.get(URL)
    #data=raw.content
    # return data
    res = parse.main()
    return res
示例#8
0
def run_year(year_dir, d):
    os.chdir("..")
    os.chdir(year_dir)
    d['year_folder'] = year_dir
    img_p = d['image_process']
    all_params = [d['no_ads'], d['margins'], d['columns'], d['entries']]

    #checks if you only wish to parse a single image.
    if img_p['single_image']:
        for p in all_params:
            p.update({'img_name': img_p['img_name']})

    if img_p['ads']: ads.rmAds(all_params[0])
    if img_p['margins']: margins.marginCrop(all_params[1])
    if img_p['columns']: columnCrop.doCrop(all_params[2])
    if img_p['entries']: entryChop.entryChop(all_params[3])
    os.chdir("..")
    if img_p['parse']: parse.main(d)
示例#9
0
def main(username, password, link):
    main_grade = {}

    soup = methods.main(username, password, link)
    classes = soup.findAll("div", {"class": "AssignmentClass"})
    #print(classes)

    main_grade = parse.main(classes)

    return main_grade
示例#10
0
def main(username, password, link):
    main_grade = {}

    test = "https://" + link + f"/HomeAccess/Account/LogOn?ReturnUrl=%2fHomeAccess%2fHomeAccess/Account/LogOn?ReturnUrl=%2fHomeAccess%2f"
    if uri_exists_get(test) == False:
        return "link_error"

    soup = methods.main(username, password, link)

    if re.findall("LogOnDetails.Password", str(soup)) != []:
        return "error"
    classes = soup.findAll("div", {"class": "AssignmentClass"})

    main_grade = parse.main(classes)

    return main_grade
示例#11
0
文件: __init__.py 项目: mgax/pywps-4
import unittest

import parse
import extent

parse.main()
extent.main()



示例#12
0
def test_main():
    parse.main({'file_in': 'input_file.txt', 'file_out': 'test_output.txt'})
    expected = open("expected_output.txt").read()
    given = open("test_output.txt").read()
    assert expected == given, "Expected and given outputs are not equal."
示例#13
0
import argparse

from timeit import default_timer as timer
time0 = timer()
#import json
#import textwrap

ap = argparse.ArgumentParser(
    formatter_class=argparse.RawTextHelpFormatter,
    epilog='_' * 60 +
    '\n Note option precedence (high to low):  individual options, opts dictionary, fopts  \n'
    + '-' * 60)

import parse
args = parse.main()
print(args)
sim_shape = args['sim_shape']
sim_width = args['sim_width']

GPU = args['GPU']
algo = args['algo']
shmem = args['shmem']
rot_center = args['rot_center']
simulate = args['simulate']
max_chunk = args['max_chunk_slice']
max_iter = args['maxiter']
tol = args['tol']
#print('tolerance',tol)
reg = args['reg']
tau = args['tau']
示例#14
0
        continue

#print(woman_product_type_set)
# Variable initializations
total_items_need, items_downloaded, num_multiple_category_items = 100, 0, 0
massive_json = {}
color, price, title, description, attributes, categories, composition, url_list, brand = [], [], [], [], [], [], [], [], []

for product_type_link in tqdm.tqdm(woman_product_type_set_copy):
    soup_product_type_page = bs.BeautifulSoup(
        requests.get(product_type_link, headers=headers).text, "lxml")

    for item in soup_product_type_page.find_all("a", {'class': "_3x-5VWa"}):
        product_link = item.get("href")
        try:
            final_object, id, first_download_of_item = parse.main(
                product_link, output_path, massive_json)
            if not first_download_of_item:
                num_multiple_category_items += 1
                print("Item_clash_for", item)
                continue

        except Exception as e:
            print("Parse failed for ", item, e)
            continue

        massive_json[id] = final_object

        color.append(final_object["annotation"]["color"])
        price.append(final_object["annotation"]["price"])
        title.append(final_object["annotation"]["title"])
        brand.append(final_object["annotation"]["brand"])
示例#15
0
def main():
    st.write(os.getcwd())
    st.write('# OER image to text')
    # st.info(__doc__)
    st.markdown(STYLE, unsafe_allow_html=True)

    last_name_input = st.text_input("Enter your last name")
    if not last_name_input:
        st.warning('Please type last name and hit enter')

    threshold_input = st.number_input("Enter threshold for binarizing images [0, 255]", min_value=0, max_value=255, value=150)


    page1 = st.file_uploader("Upload OER page 1", type=FILE_TYPES)
    page2 = st.file_uploader("Upload OER page 2", type=FILE_TYPES)
    show_page1 = st.empty()
    show_page2 = st.empty()


    if not page1:
        show_page1.info("Please OER page 1 of type: " + ", ".join(FILE_TYPES))
        return
    if not page2:
        show_page2.info("Please upload OER page 2 of type: " + ", ".join(FILE_TYPES))
        return
    # get data from images



    # once both files uploaded
    if page1 and page2:
        show_page1.image(page1.read())
        show_page2.image(page2.read())
        # get names and extensions
        input1_filename = page1.name
        input1_ext = input1_filename[input1_filename.rindex('.')+1:]
        input2_filename = page2.name
        input2_ext = input2_filename[input2_filename.rindex('.')+1:]

        last_name = last_name_input.lower()

        # images new file names
        filename_page_1 = last_name + '_page1.' + input1_ext
        filename_page_2 = last_name + '_page2.' + input2_ext

        # binarized images new file names
        filename_bin_page_1 = last_name + '_bin_' + str(threshold_input) + '_page1.' + input1_ext
        filename_bin_page_2 = last_name + '_bin_' + str(threshold_input) + '_page2.' + input2_ext
            # filename_bin_page_1=$name$bin$thresh$page1$extension
            # filename_bin_page_2=$name$bin$thresh$page2$extension

        # txt filename
        txt_filename = last_name + '_bin_' + str(threshold_input) + '.txt'
            #txt_filename=$name$bin$thresh$txt

        # json file name
        json_filename = last_name + '_bin_' + str(threshold_input) + '.json'

        # open and save images to file structure
        page1_img = Image.open(page1)
        page2_img = Image.open(page2)

        SAVE_PATH = './data/images/'

        page1_img.save(SAVE_PATH + filename_page_1)
        page2_img.save(SAVE_PATH + filename_page_2)



        # page1.close()
        # page2.close()
        # if show:
        #     page_1_image_show = Image.open(SAVE_PATH + filename_page_1)
        #     page_2_image_show = Image.open(SAVE_PATH + filename_page_1)
        #     show_page1.image(page_1_image_show)
        #     show_page2.image(page_2_image_show)
        #     # show_page1.image(page1.read())
        #     # show_page2.image(page2.read())

        ### binarize
        with st.spinner('Preprocessing OER image'):
            sys.argv = ["binarize_images.py", str(threshold_input), filename_page_1, filename_page_2]
            # os.system('python binarize_images 150' + page1_name + ' ' + page2_name)
            binarize_images.main()


        ### img to text
        with st.spinner('Reading text from image...'):
            sys.argv = ["img_to_text.py", filename_bin_page_1, filename_bin_page_2]
            img_to_text.main()

        ### parse
        with st.spinner('Converting text to machine-readable format...'):
            sys.argv = ["parse.py", txt_filename, filename_bin_page_2]
            parse.main()
        st.success('Conversion complete!')


        st.write('## Output')

        with open('./data/output/' + json_filename, 'r') as f:
            output = json.load(f)
        st.write(output)
示例#16
0
#!venv/bin/python3
import os
import lexer
import parse

# 命令行解析 获得源码文件
#
# def getarg():
#     parser = argparse.ArgumentParser()
#     parser.add_argument("file", help="choose a my_c source file")
#     args = parser.parse_args()
#     return args.file

if __name__ == "__main__":
    #path = getarg()
    try:
        fo = open('myc.c', "r")
    except IOError:
        print("ERROR: FILE NOT FOUND!")
        os._exit(0)
    lexer = lexer.main(fo)
    fo.close()
    parse.main(lexer)






def main():
    args = get_args()
    sys.argv[1:] = ['-v', args.vcf_file]
    sys.argv[3:] = ['-o', args.headless_vcf_filename
                    ] if args.headless_vcf_filename else []
    remove_vcf_header.main()

    vcf_file = args.headless_vcf_filename or (args.vcf_file + '.noh')
    del sys.argv[3:]
    sys.argv[2] = vcf_file
    sys.argv = sys.argv + ['-g', args.gene_expression_file]
    sys.argv[5:] = ['-e', args.overlap_extension
                    ] if args.overlap_extension else []
    vcf_overlap.main()

    gene_exp = args.gene_expression_file + args.overlap_extension if args.overlap_extension else args.gene_expression_file + '.out'
    vcf_file = vcf_file + args.overlap_extension if args.overlap_extension else vcf_file + '.out'
    del sys.argv[3:]
    sys.argv[2] = vcf_file
    sys.argv[3:] = ['-m', args.maf_cutoff] if args.maf_cutoff else []
    sys.argv[len(sys.argv):] = ['-o', args.filtered_filename
                                ] if args.filtered_filename else []
    filter_snps.main()

    del sys.argv[3:]
    vcf_file = args.filtered_filename or (vcf_file + '.maf_filtered')
    sys.argv[2] = vcf_file
    sys.argv[3:] = ['-o', args.parsed_filename] if args.parsed_filename else []
    parse.main()

    del sys.argv[3:]
    matrix_file = args.parsed_filename or (vcf_file + '.matrix')
    sys.argv[3:] = ['-o', args.position_filename
                    ] if args.position_filename else []
    sys.argv[len(sys.argv):] = ['-m', args.meqtl_position_filename
                                ] if args.meqtl_position_filename else []
    position.main()

    position_file = args.meqtl_position_filename or vcf_file + '.meqtl_positions'
    del sys.argv[3:]
    sys.argv[2] = matrix_file
    sys.argv[3:] = ['-n', args.number_pcs] if args.number_pcs else []
    sys.argv[len(sys.argv):] = ['-o', args.pc_filename
                                ] if args.pc_filename else []
    pc_covariates.main()

    sys.argv[1:] = ['-i', gene_exp]
    sys.argv[3:] = ['-o', args.normalized_filename
                    ] if args.normalized_filename else []
    run_iqn.main()

    del sys.argv[3:]
    gene_exp = args.normalized_filename or (gene_exp + '.qnorm')
    sys.argv[2] = gene_exp
    sys.argv = sys.argv + ['-n', args.numfactors]
    sys.argv[5:] = ['-o', args.peer_factor_filename
                    ] if args.peer_factor_filename else []
    run_peer.main()

    peer_file = args.peer_factor_filename or gene_exp + '.peer_factors_' + args.numfactors
    pc_file = args.pc_filename if args.pc_filename else matrix_file + '.pcs'
    sys.argv[1:] = ['-p', pc_file, '-f', peer_file]

    sys.argv[5:] = ['-o', args.combined_covariate_filename
                    ] if args.combined_covariate_filename else []
    covariate_file = args.combined_covariate_filename or 'data/combined_covariates'
    sys.argv[len(sys.argv):] = ['-a', args.additional_covariates
                                ] if args.additional_covariates else []
    combine_covariates.main()

    sys.argv[1:] = [
        '-m', matrix_file, '-p', position_file, '-e', gene_exp, '-g',
        args.gene_position_file, '-c', covariate_file
    ]

    sys.argv[len(sys.argv):] = ['--trans-output-file', args.trans_output_file
                                ] if args.trans_output_file else []
    sys.argv[len(sys.argv):] = ['--trans-p-value', args.trans_p_value
                                ] if args.trans_p_value else []
    sys.argv[len(sys.argv):] = ['--model', args.model] if args.model else []
    sys.argv[len(sys.argv):] = ['--cis-distance', args.cis_distance
                                ] if args.cis_distance else []
    sys.argv[len(sys.argv):] = ['--p-value', args.cis_p_value
                                ] if args.cis_p_value else []
    sys.argv[len(sys.argv):] = ['--no-header'
                                ] if args.no_header is False else []
    sys.argv[len(sys.argv):] = ['--no-rownames'
                                ] if args.no_rownames is False else []
    sys.argv[len(sys.argv):] = ['--missing', args.missing
                                ] if args.missing else []
    sys.argv[len(sys.argv):] = ['--sep', args.sep] if args.sep else []
    sys.argv[len(sys.argv):] = ['--maf', args.maf] if args.maf else []
    sys.argv[len(sys.argv):] = ['--qq-plot', args.qqplot
                                ] if args.qqplot else []
    sys.argv[len(sys.argv):] = ['--output-file', args.eqtl_output_file
                                ] if args.eqtl_output_file else []

    run_matrix_eqtl.main()

    sys.argv[1:] = [
        '-m', args.eqtl_output_file or 'MatrixEqtlOutput', '-g', matrix_file,
        '-e', gene_exp
    ]
    sys.argv[len(sys.argv):] = ['--pdf-file', args.boxplot_pdf_file
                                ] if args.boxplot_pdf_file else []
    sys.argv[len(sys.argv):] = ['--output-file', args.correlation_output_file
                                ] if args.correlation_output_file else []

    CorrBoxPlot.main()

    if args.manhattan_pdf_file:
        sys.argv[1:] = [
            '-e', args.eqtl_output_file or 'MatrixEqtlOutput', '-l',
            position_file, '-p', args.manhattan_pdf_file
        ]
        manhattan.main()
示例#18
0
	
	if img_p['ads']:
		print('Removing ads...')
		t1 = time.time()
		ads.rmAds(all_params[0]) 
		t2 = time.time()
		print('Done in: ' + str(round(t2-t1, 2)) + ' s')
	if img_p['margins']:
		print('Cropping margins...')
		t1 = time.time()
		margins.marginCrop(all_params[1])
		t2 = time.time()
		print('Done in: ' + str(round(t2-t1, 2)) + ' s')
	if img_p['columns']:
		print('Cropping columns...')
		t1 = time.time()
		columnCrop.doCrop(all_params[2]) 
		t2 = time.time()
		print('Done in: ' + str(round(t2-t1, 2)) + ' s')
	if img_p['entries']:
		print('Chopping entries...')
		t1 = time.time()
		entryChop.entryChop(all_params[3])
		t2 = time.time()
		print('Done in: ' + str(round(t2-t1, 2)) + ' s')
	if img_p['parse']:
		os.chdir("..")
		parse.main(d)

mt2 = time.time()
print('Full runtime: ' + str(round(mt2-mt1, 2)) + ' s')
示例#19
0
import parse  # import main as parse_main
from predict import get_baseline_predictions
from common import *

__author__ = "Alin Barsan, Curtis Josey"

if __name__ == "__main__":
	parse.main("data", "train.txt")
	predictions = get_baseline_predictions(parse.readTestDataBaseline("data", "test.txt"))
	write_predictions_to_file(predictions)
示例#20
0
            q.append([sequenceRobots[i], sequenceStates[i], aux])
    return done


""" Main function of the program:
    - Take the information of the pddl.
    - Solve the planning problem.
    - Send the path into the graphics.
    - Print the cpu time needed to find the optimal path.
    """
if __name__ == '__main__':

    #Actual time
    a = time.datetime.now()
    #Information from the PDDL file using parse.py. Robots information, the initial state and the target state.
    robots, state, target = p.main()
    how_many_robots = len(robots)
    for i in range(0, how_many_robots):
        robots[i][1] += 1
        robots[i][0][0] -= 1
    rows = len(state)
    columns = len(state[0])
    solution = False
    #Solve and find the proper path
    solution = solve_NRobots(how_many_robots, robots, state, target)
    #Time needed
    print("Time: ")
    print(time.datetime.now() - a)
    if (solution == True):
        #We found a path. Needed to draw it.
        print("Solved")
示例#21
0
        for line5 in fin5:
            deprels = line5.strip().split()
            deprels_list.append(deprels)
        for line6 in fin6:
            postags = line6.strip().split()
            postags_list.append(postags)

    save_data_dir = direc
    if not os.path.exists(save_data_dir):
        os.mkdir(save_data_dir)
    pred_file_name = save_data_dir + data + '.conll' + Type
    conll_format(aspects_list, opinions_list, tokens_list, parents_list,
                 deprels_list, postags_list, pred_file_name)


if __name__ == '__main__':
    datasets = ['rest', 'laptop', 'restaurant']  #'laptop', 'restaurant'

    for dataset in datasets:
        direc = '../data/' + dataset + '/'
        data = dataset

        if not os.path.exists(direc + data + '.toks' + '_train'):
            pre_script_semeval.main(dataset)
            stanford_pos.main(dataset, Type='_train')
            stanford_pos.main(dataset, Type='_test')
            parse.main(dataset, Type='_train')
            parse.main(dataset, Type='_test')
        train_test_save(direc, data, Type='_train')
        train_test_save(direc, data, Type='_test')
示例#22
0
def playGame(userSelection):

	#Initial variables
	userInput = "default"	#Default message for user input
	userRoom = 0   #Sentinel variable for room

	#Create new or load saved game
	if userSelection == 0:	#New game
		load_gamestate("0")
		#print "NEW GAME FILE CREATED"
		
		#PENDING - Load game state with default starting variables {Data dev}
		#Initialize gamestate class - NOTE: MODIFIED TO START IN ROOM 6
		# currentState = gamestate.GameStateClass(6,   #currentRoom
		  # 0, #room1
		  # 0, #room2
		  # 0, #room3
		  # 0, #room4
		  # 0, #room5
		  # 0, #room6
		  # 0, #room7
		  # 0, #room8
		  # 0, #room9
		  # 0, #room10
		  # 99, #item1 - Board
		  # 99, #item2 - Key
		  # 99, #item3 - Handle
		  # 99, #item4 - Skeleton Key
		  # 6, #item5 - Small Key
		  # 7, #item6 - Gun
		  # 0, #rm1f1
		  # 0, #rm1f2
		  # 0, #rm1f3
		  # 0, #rm1f4
		  # 1, #rm1o1 - Board discovery
		  # 1, #rm1o2 - Keys discovery
		  # 0, #rm2f1
		  # 0, #rm2f2
		  # 0, #rm2f3
		  # 1, #rm2o1 - Handle discovery 
		  # 0, #rm3f1
		  # 0, #rm3f2
		  # 0, #rm3f3
		  # 0, #rm3f4
		  # 0, #rm3f5
		  # 0, #rm3f6
		  # 0, #rm4f1
		  # 0, #rm4f2
		  # 0, #rm4f3
		  # 0, #rm4f4
		  # 0, #rm4f5
		  # 0, #rm4f6
		  # 1, #rm4o1 - Skeleton key discovery
		  # 0, #rm5f1
		  # 0, #rm5f2
		  # 0, #rm5f3
		  # 0, #rm6f1
		  # 0, #rm6f2
		  # 0, #rm6f3
		  # 0, #rm6f4
		  # 0, #rm6f5
		  # 0, #rm6o1 - Small key discovery 
		  # 0, #rm7f1
		  # 0, #rm7f2
		  # 0, #rm7f3
		  # 0, #rm7f4
		  # 0, #rm7f5
		  # 0, #rm7o1 - Gun discovery
		  # 0, #rm8f1
		  # 0, #rm8f2
		  # 0, #rm8f3
		  # 0, #rm8f4
		  # 0, #rm8f5
		  # 0, #rm8f6
		  # 0, #rm9f1
		  # 0, #rm9f2
		  # 0, #rm9f3
		  # 0, #rm9f4
		  # 0, #rm10f1
		  # 0) #rm10f2

	else:
		print "LOAD GAME FILE"
		#PENDING - Load game state with saved variables {Data dev}

	#Load room files {Data dev}
	data.load_rooms() 
	
	#Rename loaded rooms to be compatible with engine
	brig = rooms[1] 
	storage = rooms[2]
	hallway = rooms[3]
	observation = rooms[4]
	examination = rooms[5]

	#MIDDLE LEVEL ROOMS
	rum = rooms[6]
	armory = rooms[7]
	garrison = rooms[8]
	galley = rooms[9]
	ladder = rooms[10]

	#Load object files {Data dev}
	data.load_objects()

	#Rename objects for engine compatibility
	board = objects["board"]
	keys = objects["keys"]
	handle = objects["handle"]
	skeletonKey = objects["skeleton key"]

	#MIDDLE LEVEL OBJECTS
	smallKey = objects["small key"]
	gun = objects["gun"]

	#Send room/item info to get format for parsing
	featureList, featureDict, itemDict, roomList = utils.formatRoomData(rooms, objects, currentState)

	#While loop repeatedly prompts user for input until user requests to load, save, or quit game
	while userInput not in ['loadgame', 'savegame', 'quit', 'exit']:

		#[BEGIN ENGINE]
		if userRoom != currentState.currRoom:  #Displays room description when player moves rooms

			#Display short / long desc
			if currentState.currRoom == 1:   #Brig
				if currentState.rm01vis == 0:
					display(brig.longDesc)
					currentState.rm01vis = 1 #Update to visited
				else:
					display(brig.shortDesc)

			elif currentState.currRoom == 2:    #Storage
				if currentState.rm02vis == 0:
					display(storage.longDesc)
					currentState.rm02vis = 1 #Update to visited
				else:
					display(storage.shortDesc)

			elif currentState.currRoom == 3:  #Lower Hallway
				if currentState.rm03vis == 0:
					display(hallway.longDesc)
					currentState.rm03vis = 1 #Update to visited
				else:
					display(hallway.shortDesc)

			elif currentState.currRoom == 4:    #Observation
				if currentState.rm04vis == 0: 
					display(observation.longDesc)
					currentState.rm04vis = 1 #Update to visited
				else:
					display(observation.shortDesc)

			elif currentState.currRoom == 5:    #Examination
				if currentState.rm05vis == 0: 
				   display(examination.longDesc)
				   currentState.rm05vis = 1 #Update to visited
				else:
				   display(examination.shortDesc)

			elif currentState.currRoom == 6:    #Rum
				if currentState.rm06vis == 0: 
				   display(rum.longDesc)
				   currentState.rm06vis = 1 #Update to visited
				else:
				   display(rum.shortDesc)

			elif currentState.currRoom == 7:    #Armory
				if currentState.rm07vis == 0: 
				   display(armory.longDesc)
				   currentState.rm07vis = 1 #Update to visited
				else:
				   display(armory.shortDesc)

			elif currentState.currRoom == 8:    #Garrison
				if currentState.rm08vis == 0: 
				   display(garrison.longDesc)
				   currentState.rm08vis = 1 #Update to visited
				else:
				   display(garrison.shortDesc)

			elif currentState.currRoom == 9:    #Galley
				if currentState.rm09vis == 0: 
				   display(galley.longDesc)
				   currentState.rm09vis = 1 #Update to visited
				else:
				   display(galley.shortDesc)

			elif currentState.currRoom == 10:    #Ladder
				if currentState.rm10vis == 0: 
				   display(ladder.longDesc)
				   currentState.rm10vis = 1 #Update to visited
				else:
				   display(ladder.shortDesc)

			userRoom = currentState.currRoom #Update room the user is currently in

		#Parsing helper function
		featureList, featureDict, itemList, roomList = utils.formatRoomData(rooms, objects, currentState)	
			
		#Pend input:
		userInput = raw_input (": ")

		#Parse user input and return code for engine action {Parsing Dev}
		userInput = parse.main(userInput, featureList, featureDict, itemDict, roomList)
	  
		#ENGINE INTERACTIONS BASED ON PARSED USER INPUT
		if userInput == "1":#Look at feature 1 - STRAW / ENTRYWAY MARKINGS / LOCKER / EXAM ENTRYWAY / DOOR / BOTTLE / GUN CABINET / BUNKS / CANVAS FLAP / LADDER
			#Brig
			if currentState.currRoom == 1:
				if currentState.rm01f1 == 0: #Before interaction
					display(brig.feat1desc)
				else: #After interaction
					display(brig.feat1interactComplete)
			#Storage
			elif currentState.currRoom == 2:
				if currentState.rm02f1 == 0: #Before interaction
					display(storage.feat1desc)
				else: #After interaction
					display(storage.feat1interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f1 == 0: #Before interaction
					display(hallway.feat1desc)
				else: #After interaction
					display(hallway.feat1interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f1 == 0: #Before interaction
					display(observation.feat1desc)
				else: #After interaction
					display(observation.feat1interactComplete)
			#Examination
			elif currentState.currRoom == 5:
				if currentState.rm05f1 == 0: #Before interaction
					display(examination.feat1desc)
				else: #After interaction
					display(examination.feat1interactComplete)
			#Rum
			elif currentState.currRoom == 6:
				if currentState.rm06f1 == 0: #Before interaction
					display(rum.feat1desc)
				else: #After interaction
					display(rum.feat1interactComplete)
			#Armory
			elif currentState.currRoom == 7:
				if currentState.rm07f1 == 0: #Before interaction
					display(armory.feat1desc)
				else: #After interaction
					display(armory.feat1interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f1 == 0: #Before interaction
					display(garrison.feat1desc)
				else: #After interaction
					display(garrison.feat1interactComplete)
			#Galley
			elif currentState.currRoom == 9:
				if currentState.rm09f1 == 0: #Before interaction
					display(galley.feat1desc)
				else: #After interaction
					display(galley.feat1interactComplete)
			#Ladder
			elif currentState.currRoom == 10:
				if currentState.rm10f1 == 0: #Before interaction
					display(ladder.feat1desc)
				else: #After interaction
					display(ladder.feat1interactComplete)

		elif userInput == "2": #Interact with feature 1 
			#Brig
			if currentState.currRoom == 1:
				display(brig.feat1interactSuccess)
				currentState.rm01f1 = 1 #Update to interaction complete
			#Storage
			elif currentState.currRoom == 2:
				if currentState.obj1Loc == 99: #If have board
					display(storage.feat1interactSuccess)
					currentState.rm02f1 = 1 #Update to interaction complete
					currentState.rm02o1 = 1 #Handle discovered
				else:
					display(storage.feat1interactFail)
			#Hallway
			elif currentState.currRoom == 3:
				display(hallway.feat1interactSuccess)
				currentState.rm03f1 = 1 #Update to interaction complete
			#Observation
			elif currentState.currRoom == 4:
				display(observation.feat1interactSuccess)
				currentState.rm04f1 = 1 #Update to interaction complete
			#Examination
			elif currentState.currRoom == 5:
				display(examination.feat1interactSuccess)
				currentState.rm05f1 = 1 #Update to interaction complete
			#Rum 
			elif currentState.currRoom == 6:
				display(rum.feat1interactSuccess)
				currentState.rm06f1 = 1 #Update to interaction complete
			#Armory 
			elif currentState.currRoom == 7:
				display(armory.feat1interactSuccess)
				currentState.rm07f1 = 1 #Update to interaction complete
			#Garrison
			elif currentState.currRoom == 8:
				display(garrison.feat1interactSuccess)
				currentState.rm08f1 = 1 #Update to interaction complete
			#Galley
			elif currentState.currRoom == 9:
				display(galley.feat1interactSuccess)
				currentState.rm09f1 = 1 #Update to interaction complete
			#Ladder
			elif currentState.currRoom == 10:
				display(ladder.feat1interactSuccess)
				currentState.rm10f1 = 1 #Update to interaction complete

		elif userInput == "3": #Look at feature 2 - BENCH / BARRED DOOR / PAPER / TABLE / BARRED WINDOW / LAMP / WOODEN DOOR / TABLE / TRASH CAN / WOODEN DOOR
			#Brig
			if currentState.currRoom == 1:
				if currentState.rm01f2 == 0: #Before interaction
					display(brig.feat2desc)
				else: #After interaction
					display(brig.feat2interactComplete)
			#Storage
			elif currentState.currRoom == 2:
				if currentState.rm02f2 == 0: #Before interaction
					display(storage.feat2desc)
				else: #After interaction
					display(storage.feat2interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f2 == 0: #Before interaction
					display(hallway.feat2desc)
				else: #After interaction
					display(hallway.feat2interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f2 == 0: #Before interaction
					display(observation.feat2desc)
				else: #After interaction
					display(observation.feat2interactComplete)
			#Examination
			elif currentState.currRoom == 5:
				if currentState.rm05f2 == 0: #Before interaction
					 display(examination.feat2desc)
				else: #After interaction
					 display(examination.feat2interactComplete)
			#Rum
			elif currentState.currRoom == 6:
				if currentState.rm06f2 == 0: #Before interaction
					display(rum.feat2desc)
				else: #After interaction
					display(rum.feat2interactComplete)
			#Armory
			elif currentState.currRoom == 7:
				if currentState.rm07f2 == 0: #Before interaction
					display(armory.feat2desc)
				else: #After interaction
					display(armory.feat2interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f2 == 0: #Before interaction
					display(garrison.feat2desc)
				else: #After interaction
					display(garrison.feat2interactComplete)
			#Galley
			elif currentState.currRoom == 9:
				if currentState.rm09f2 == 0: #Before interaction
					display(galley.feat2desc)
				else: #After interaction
					display(galley.feat2interactComplete)
			#Ladder
			elif currentState.currRoom == 10:
				if currentState.rm10f2 == 0: #Before interaction
					display(ladder.feat2desc)
				else: #After interaction
					display(ladder.feat2interactComplete)

		elif userInput == "4": #Interact with feature 2
			#Brig
			if currentState.currRoom == 1:
				display(brig.feat2interactSuccess)
				currentState.rm01f2 = 1 #Update to interaction complete
				currentState.rm01o1 = 1 #Board discovered
			#Storage
			elif currentState.currRoom == 2:
				display(storage.feat2interactSuccess)
				currentState.rm02f2 = 1 #Update to interaction complete
			#Hallway
			elif currentState.currRoom == 3:
				display(hallway.feat2interactSuccess)
				currentState.rm03f2 = 1 #Update to interaction complete
			#Observation
			elif currentState.currRoom == 4:
				display(observation.feat2interactSuccess)
				currentState.rm04f2 = 1 #Update to interaction complete
			#Examination
			elif currentState.currRoom == 5:
				display(examination.feat2interactSuccess)
				currentState.rm05f2 = 1 #Update to interaction complete
			#Rum
			elif currentState.currRoom == 6:
				display(rum.feat2interactSuccess)
				currentState.rm06f2 = 1 #Update to interaction complete
			#Armory
			elif currentState.currRoom == 7:
				display(armory.feat2interactSuccess)
				currentState.rm07f2 = 1 #Update to interaction complete
			#Garrison
			elif currentState.currRoom == 8:
				display(garrison.feat2interactSuccess)
				currentState.rm08f2 = 1 #Update to interaction complete
			#Galley
			elif currentState.currRoom == 9:
				display(galley.feat2interactSuccess)
				currentState.rm09f2 = 1 #Update to interaction complete
			#Ladder
			elif currentState.currRoom == 10:
				display(ladder.feat2interactSuccess)
				currentState.rm10f2 = 1 #Update to interaction complete

		elif userInput == "5": #Look at object "board"
			if currentState.obj1Loc ==99: #In iventory
				display(board.desc)
			else: #Not in inventory
				display(board.notInInv)

		elif userInput == "6": #Look at feature 3 - WINDOW / METAL DOOR / DOOR / MIRROR / WINDOW / TRAP DOOR / LOCKER / PHOTOGRAPH / STOVE
			#Brig
			if currentState.currRoom == 1:
				if currentState.rm01f3 == 0: #Before interaction
					display(brig.feat3desc)
				else: #After interaction
					display(brig.feat3interactComplete)
			#Storage
			if currentState.currRoom == 2:
				if currentState.rm02f3 == 0: #Before interaction
					display(storage.feat3desc)
				else: #After interaction
					display(storage.feat3interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f3 == 0: #Before interaction
					display(hallway.feat3desc)
				else: #After interaction
					display(hallway.feat3interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f3 == 0: #Before interaction
					display(observation.feat3desc)
				else: #After interaction
					display(observation.feat3interactComplete)
			#Examination
			elif currentState.currRoom == 5:
				if currentState.rm05f3 == 0: #Before interaction
					display(examination.feat3desc)
				else: #After interaction
					display(examination.feat3interactComplete)
			#Rum
			elif currentState.currRoom == 6:
				if currentState.rm06f3 == 0: #Before interaction
					display(rum.feat3desc)
				else: #After interaction
					display(rum.feat3interactComplete)
			#Armory
			elif currentState.currRoom == 7:
				if currentState.rm07f3 == 0: #Before interaction
					display(armory.feat3desc)
				else: #After interaction
					display(armory.feat3interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f3 == 0: #Before interaction
					display(garrison.feat3desc)
				else: #After interaction
					display(garrison.feat3interactComplete)
			#Galley
			elif currentState.currRoom == 9:
				if currentState.rm09f3 == 0: #Before interaction
					display(galley.feat3desc)
				else: #After interaction
					display(galley.feat3interactComplete)

		elif userInput == "7": #Interact with feature 3
			#Brig
			if currentState.currRoom == 1:
				if currentState.obj1Loc == 99:

					display(brig.feat3interactSuccess)
					currentState.rm01f3 = 1 #Update to interaction complete
					currentState.rm01o2 = 1 #Keys discovered
				else:
					display(brig.feat3interactFail)
			#Storage
			elif currentState.currRoom == 2:
				display(storage.feat3interactSuccess)
				currentState.rm02f3 = 1 #Update to interaction complete
			#Hallway
			if currentState.currRoom == 3: #NOTE TO CHECK: HANDLE PERMANENTLY USED?
				if currentState.obj3Loc == 99:   #Handle in inv
					display(hallway.feat3interactSuccess)
					currentState.rm03f3 = 1 #Update to interaction complete
					currentState.obj3Loc = 100 #Update handle to permanently used
				elif currentState.obj3Loc == 100:
					display(hallway.feat3interactComplete)
				else:
					display(hallway.feat3interactFail)
			#Observation
			elif currentState.currRoom == 4:
				display(observation.feat3interactSuccess)
				currentState.rm04f3 = 1 #Update to interaction complete
			#Examination
			elif currentState.currRoom == 5:
				display(examination.feat3interactSuccess)
				currentState.rm05f3 = 1 #Update to interaction complete
			#Rum
			elif currentState.currRoom == 6:
				display(rum.feat3interactSuccess)
				currentState.rm06f3 = 1 #Update to interaction complete
			#Armory
			elif currentState.currRoom == 7:
				display(armory.feat3interactSuccess)
				currentState.rm07f3 = 1 #Update to interaction complete
			#Garrison
			elif currentState.currRoom == 8:
				display(garrison.feat3interactSuccess)
				currentState.rm08f3 = 1 #Update to interaction complete
			#Garrison
			elif currentState.currRoom == 9:
				display(galley.feat3interactSuccess)
				currentState.rm09f3 = 1 #Update to interaction complete

		elif userInput == "8": #Look at object "keys"
			if currentState.obj2Loc ==99: #In inventory
				display(keys.desc)
			else: #Not in inventory
				display(keys.notInInv)

		elif userInput == "9": #Look at feature 4 - DOOR / WOODEN DOOR / CHEST / BARRELS / GUN CASE / WOODEN DOOR / SINK
			#Brig
			if currentState.currRoom == 1:
				if currentState.rm01f4 == 0: #Before interaction
					display(brig.feat4desc)
				else: #After interaction
					display(brig.feat4interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f4 == 0: #Before interaction
					display(hallway.feat4desc)
				else: #After interaction
					display(hallway.feat4interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f4 == 0: #Before interaction
					display(observation.feat4desc)
				else: #After interaction
					display(observation.feat4interactComplete)
			#Rum
			elif currentState.currRoom == 6:
				if currentState.rm06f4 == 0: #Before interaction
					display(rum.feat4desc)
				else: #After interaction
					display(rum.feat4interactComplete)
			#Armory
			elif currentState.currRoom == 7:
				if currentState.rm07f4 == 0: #Before interaction
					display(armory.feat4desc)
				else: #After interaction
					display(armory.feat4interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f4 == 0: #Before interaction
					display(garrison.feat4desc)
				else: #After interaction
					display(garrison.feat4interactComplete)
			#Galley
			elif currentState.currRoom == 9:
				if currentState.rm09f4 == 0: #Before interaction
					display(galley.feat4desc)
				else: #After interaction
					display(galley.feat4interactComplete)

		elif userInput == "10": #Interact with feature 4
			#Brig
			if currentState.currRoom == 1:
				if currentState.obj2Loc == 99: #Keys
					display(brig.feat4interactSuccess)
					currentState.rm01f4 = 1 #Update to interaction complete
				else:
					display(brig.feat4interactFail)
			#Hallway
			elif currentState.currRoom == 3:
				display(hallway.feat4interactSuccess)
				currentState.rm03f4 = 1 #Update to interaction complete
			#Observation
			if currentState.currRoom == 4:
				if currentState.obj2Loc == 99: #Keys
					display(observation.feat4interactSuccess)
					currentState.rm04f4 = 1 #Update to interaction complete
					currentState.rm04o1 = 1 #Skeleton key discovered
				else:
					display(observation.feat4interactFail)
			#Rum
			elif currentState.currRoom == 6:
				display(rum.feat4interactSuccess)
				currentState.rm06f4 = 1 #Update to interaction complete
				currentState.rm06o1 = 1 #Small Key discovered 
			#Armory
			if currentState.currRoom == 7:
				if currentState.obj5Loc == 99: #Small key
					display(armory.feat4interactSuccess)
					currentState.rm07f4 = 1 #Update to interaction complete
					currentState.rm07o1 = 1 #Gun discovered
				else:
					display(armory.feat4interactFail)
			#Garrison
			elif currentState.currRoom == 8:
				display(garrison.feat4interactSuccess)
				currentState.rm08f4 = 1 #Update to interaction complete
			#Galley
			elif currentState.currRoom == 9:
				display(galley.feat4interactSuccess)
				currentState.rm09f4 = 1 #Update to interaction complete

		elif userInput == "11": #General look around room
			if currentState.currRoom == 1:
				display(brig.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 1:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 1:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 1:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 1:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm05o1 == 1 and currentState.obj5Loc == 1:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 1:
					display(gun.inRoom)

			elif currentState.currRoom == 2:
				display(storage.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 2:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 2:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 2:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 2:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm05o1 == 1 and currentState.obj5Loc == 2:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 2:
					display(gun.inRoom)

			elif currentState.currRoom == 3:
				display(hallway.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 3:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 3:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 3:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 3:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm05o1 == 1 and currentState.obj5Loc == 3:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 3:
					display(gun.inRoom)

			elif currentState.currRoom == 4:
				display(observation.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 4:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 4:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 4:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 4:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm05o1 == 1 and currentState.obj5Loc == 4:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 4:
					display(gun.inRoom)

			elif currentState.currRoom == 5:
				display(examination.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 5:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 5:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 5:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 5:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm05o1 == 1 and currentState.obj5Loc == 5:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 5:
					display(gun.inRoom)

			elif currentState.currRoom == 6:    #Rum
				display(rum.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 6:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 6:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 6:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 6:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm06o1 == 1 and currentState.obj5Loc == 6:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 6:
					display(gun.inRoom)

			elif currentState.currRoom == 7:    #Armory
				display(armory.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 7:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 7:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 7:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 7:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm06o1 == 1 and currentState.obj5Loc == 7:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 7:
					display(gun.inRoom)

			elif currentState.currRoom == 8:    #Garrison
				display(garrison.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 8:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 8:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 8:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 8:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm06o1 == 1 and currentState.obj5Loc == 8:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 8:
					display(gun.inRoom)

			elif currentState.currRoom == 9:    #Galley
				display(galley.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 9:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 9:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 9:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 9:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm06o1 == 1 and currentState.obj5Loc == 9:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 9:
					display(gun.inRoom)

			elif currentState.currRoom == 10:    #Ladder
				display(galley.longDesc)
				#Checks objects and if they are DISCOVERED and LOCATED IN ROOM then displays notice they are there
				#Object 1 - board
				if currentState.rm01o1 == 1 and currentState.obj1Loc == 10:
					display(board.inRoom)
				#Object 2 - keys
				if currentState.rm01o2 == 1 and currentState.obj2Loc == 10:
					display(keys.inRoom)
				#Object 3 - handle
				if currentState.rm02o1 == 1 and currentState.obj3Loc == 10:
					display(handle.inRoom)
				#Object 4 - skeleton key
				if currentState.rm04o1 == 1 and currentState.obj4Loc == 10:
					display(skeletonKey.inRoom)
				#Object 5 - small key
				if currentState.rm06o1 == 1 and currentState.obj5Loc == 10:
					display(smallKey.inRoom)
				#Object 6 - Gun
				if currentState.rm07o1 == 1 and currentState.obj6Loc == 10:
					display(gun.inRoom)

		elif userInput == "12": #Take board
			#If object discovered and if player is in the same room as the object
			if currentState.rm01o1 == 1 and currentState.obj1Loc == currentState.currRoom:
				currentState.obj1Loc = 99 #Add board to player inventory
				display(board.take)
			else:
				display(board.notAvail)

		elif userInput == "13": #Take keys
			#If object discovered and if player is in the same room as the object
			if currentState.rm01o2 == 1 and currentState.obj2Loc == currentState.currRoom:
				currentState.obj2Loc = 99 #Add keys to player inventory
				display(keys.take)
			else:
				display(keys.notAvail)

		elif userInput == "14": #Drop board
			if currentState.obj1Loc == 99: #In inventory to drop
				currentState.obj1Loc = currentState.currRoom
				display(board.drop)
			else:
				display(board.notInInv)

		elif userInput == "15": #Drop keys
			if currentState.obj2Loc == 99: #In inventory to drop
				currentState.obj2Loc = currentState.currRoom
				display(keys.drop)
			else:
				display(keys.notInInv)

		elif userInput == "16": #Help
			utils.printHelp(featureDict, itemDict)

		elif userInput == "17": #Inventory
			print ""
			display("Inventory:")
			if currentState.obj1Loc == 99:   #Board
				display(board.name)
			if currentState.obj2Loc == 99:   #Keys
				display(keys.name)
			if currentState.obj3Loc == 99:   #Handle
				display(handle.name)
			if currentState.obj4Loc == 99:   #Skeleton Key
				display(skeletonKey.name)
			if currentState.obj5Loc == 99:   #Small Key
				display(smallKey.name)
			if currentState.obj6Loc == 99:   #Gun
				display(gun.name)
			print ""

		elif userInput == "18": #Look at feature 5 - Brig:null - LADDER / BOTTLES / WOODEN DOOR / METAL DOOR / CANVAS FLAP
			#Brig
			if currentState.currRoom == 1:
				display("Brig feature 5 null")
				#if currentState.rm01f4 == 0: #Before interaction
				#   display(brig.feat4desc)
				#else: #After interaction
				#   display(brig.feat4interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f5 == 0: #Before interaction
					display(hallway.feat5desc)
				else: #After interaction
					display(hallway.feat5interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f5 == 0: #Before interaction
					display(observation.feat5desc)
				else: #After interaction
					display(observation.feat5interactComplete)
			#Rum
			elif currentState.currRoom == 6:
				if currentState.rm06f5 == 0: #Before interaction
					display(rum.feat5desc)
				else: #After interaction
					display(rum.feat5interactComplete)
			#Armory
			elif currentState.currRoom == 7:
				if currentState.rm07f5 == 0: #Before interaction
					display(armory.feat5desc)
				else: #After interaction
					display(armory.feat5interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f5 == 0: #Before interaction
					display(garrison.feat5desc)
				else: #After interaction
					display(garrison.feat5interactComplete)

		elif userInput == "19": #Interact with feature 5  - LADDER / BOTTLES / WOODEN DOOR
			#Brig
			if currentState.currRoom == 1:
				print "Brig feature 5 null"
				#if currentState.obj2Loc == 99: #Keys
				#   display(brig.feat4interactSuccess)
				#   currentState.rm01f4 = 1 #Update to interaction complete
				#else:
				#   display(brig.feat4interactFail)
			#Hallway
			elif currentState.currRoom == 3:
				display(hallway.feat5interactSuccess)
				currentState.rm03f5 = 1 #Update to interaction complete
			#Observation
			elif currentState.currRoom == 4:
				display(observation.feat5interactSuccess)
				currentState.rm04f5 = 1 #Update to interaction complete
			#Rum
			elif currentState.currRoom == 6:
				display(rum.feat5interactSuccess)
				currentState.rm06f5 = 1 #Update to interaction complete
			#Armory
			elif currentState.currRoom == 7:
				display(armory.feat5interactSuccess)
				currentState.rm07f5 = 1 #Update to interaction complete
			#Garrison
			elif currentState.currRoom == 8:
				display(garrison.feat5interactSuccess)
				currentState.rm08f5 = 1 #Update to interaction complete

		elif userInput == "20": #Look at feature 6 - Brig:null  - TRAP DOOR / PAPERS / METAL DOOR
			#Brig
			if currentState.currRoom == 1:
				print "Brig feature 6 null"
				#if currentState.rm01f4 == 0: #Before interaction
				#   display(brig.feat4desc)
				#else: #After interaction
				#   display(brig.feat4interactComplete)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.rm03f6 == 0: #Before interaction
					display(hallway.feat6desc)
				else: #After interaction
					display(hallway.feat6interactComplete)
			#Observation
			elif currentState.currRoom == 4:
				if currentState.rm04f6 == 0: #Before interaction
					display(observation.feat6desc)
				else: #After interaction
					display(observation.feat6interactComplete)
			#Garrison
			elif currentState.currRoom == 8:
				if currentState.rm08f6 == 0: #Before interaction
					display(armory.feat6desc)
				else: #After interaction
					display(armory.feat6interactComplete)

		elif userInput == "21": #Interact with feature 6
			#Brig
			if currentState.currRoom == 1:
				print "Brig feature 6 null"
				#if currentState.obj2Loc == 99: #Keys
				#   display(brig.feat4interactSuccess)
				#   currentState.rm01f4 = 1 #Update to interaction complete
				#else:
				#   display(brig.feat4interactFail)
			#Hallway
			elif currentState.currRoom == 3:
				if currentState.obj4Loc == 99:   #Skeleton Key in inv
					display(hallway.feat6interactSuccess)
					currentState.rm03f6 = 1 #Update to interaction complete
				else:
					display(hallway.feat6interactFail)
			#Observation
			elif currentState.currRoom == 4:
				display(observation.feat6interactSuccess)
				currentState.rm04f6 = 1 #Update to interaction complete
			#Armory
			elif currentState.currRoom == 8:
				display(armory.feat6interactSuccess)
				currentState.rm08f6 = 1 #Update to interaction complete

		elif userInput == "22": #GO NORTH
			if currentState.currRoom == 1: #Brig
				if currentState.rm01f4 == 1: #If door unlocked, proceed North into Lower Hallway
					currentState.currRoom = 3 #Updates current user location to ID 3 (Lower Hallway)
				else:
					display(brig.feat4interactFail)  #Else, failure statement

			elif currentState.currRoom == 2: #Storage
				display("You cannot go that way.")

			elif currentState.currRoom == 3: #Lower Hallway
				currentState.currRoom = hallway.north #Updates current user location to ID 5 (Examination Room)

			elif currentState.currRoom == 4: #Observation
				display("You cannot go that way.")

			elif currentState.currRoom == 5: #Examination
				display("You cannot go that way.")
			elif currentState.currRoom == 6: #Rum
				currentState.currRoom = rum.north #Updates current user location to ID 7 (Armory Room)

			elif currentState.currRoom == 7: #Armory
				currentState.currRoom = armory.north #Updates current user location to ID 8 (Garrison)

			elif currentState.currRoom == 8: #Garrison
				currentState.currRoom = garrison.north #Updates current user location to ID 9 (Galley)

			elif currentState.currRoom == 9: #Galley
				print "You cannot go that way."

			elif currentState.currRoom == 10: #Ladder
				print "You cannot go that way."

		elif userInput == "23": #GO SOUTH
			if currentState.currRoom == 1: #Brig
				print "You cannot go that way."

			elif currentState.currRoom == 2: #Storage
				print "You cannot go that way."

			elif currentState.currRoom == 3: #Lower Hallway
				currentState.currRoom = hallway.south #Updates current user location to ID 1 (Brig)
				#currentState.currRoom = 1 #Updates current user location to ID 1 (Brig)

			elif currentState.currRoom == 4: #Observation
				print "You cannot go that way."

			elif currentState.currRoom == 5: #Examination
				currentState.currRoom = examination.south #Updates current user location to ID 3 (Hallway)

			elif currentState.currRoom == 6: #Rum
				print "You cannot go that way."

			elif currentState.currRoom == 7: #Armory
				currentState.currRoom = armory.south #Updates current user location to ID 6 (Rum)

			elif currentState.currRoom == 8: #Garrison
				currentState.currRoom = garrison.south #Updates current user location to ID 7 (Armory)

			elif currentState.currRoom == 9: #Galley
				currentState.currRoom = galley.south #Updates current user location to ID 8 (Garrison)

			elif currentState.currRoom == 10: #Ladder
				print "You cannot go that way."

		elif userInput == "24": #GO WEST
			if currentState.currRoom == 1: #Brig
				print "You cannot go that way."

			elif currentState.currRoom == 2: #Storage
				print "You cannot go that way."

			elif currentState.currRoom == 3: #Lower Hallway
				currentState.currRoom = hallway.west #Updates current user location to ID 2 (Storage Room)

			elif currentState.currRoom == 4: #Observation
				currentState.currRoom = observation.west #Updates current user location to ID 3 (Hallway)

			elif currentState.currRoom == 5: #Examination
				print "You cannot go that way."

			elif currentState.currRoom == 6: #Rum
				print "You cannot go that way."

			elif currentState.currRoom == 7: #Armory
				print "You cannot go that way."

			elif currentState.currRoom == 8: #Garrison
				print "You cannot go that way."

			elif currentState.currRoom == 9: #Galley
				print "You cannot go that way."

			elif currentState.currRoom == 10: #Ladder
				currentState.currRoom = ladder.west #Updates current user location to ID 8 (Garrison)

		elif userInput == "25": #GO EAST
			if currentState.currRoom == 1: #Brig
				print "You cannot go that way."

			elif currentState.currRoom == 2: #Storage
				currentState.currRoom = storage.east #Updates current user location to ID 3 (Hallway)

			elif currentState.currRoom == 3: #Lower Hallway
				if currentState.rm03f3 == 1: #If door unlocked, proceed North into Lower Hallway
					currentState.currRoom = hallway.east #Updates current user location to ID 4 (Observation)
				else:
					display(hallway.feat3interactFail)  #Else, failure statement

			elif currentState.currRoom == 4: #Observation
				display("You cannot go that way.")

			elif currentState.currRoom == 5: #Examination
				display("You cannot go that way.")

			elif currentState.currRoom == 6: #Rum
				display("You cannot go that way.")

			elif currentState.currRoom == 7: #Armory
				display("You cannot go that way.")

			elif currentState.currRoom == 8: #Garrison
				currentState.currRoom = garrison.east #Updates current user location to ID 10 (Ladder)

			elif currentState.currRoom == 9: #Galley
				display("You cannot go that way.")

			elif currentState.currRoom == 10: #Ladder
				display("You cannot go that way.")

		elif userInput == "26": #GO UP
			if currentState.currRoom == 1: #Brig
				display("You cannot go that way.")

			elif currentState.currRoom == 2: #Storage
				display("You cannot go that way.")

			elif currentState.currRoom == 3: #Lower Hallway
				currentState.currRoom = hallway.up #Updates current user location to ID 6 (Rum)

			elif currentState.currRoom == 4: #Observation
				display("You cannot go that way.")

			elif currentState.currRoom == 5: #Examination
				display("You cannot go that way.")

			elif currentState.currRoom == 6: #Rum
				display("You cannot go that way.")

			elif currentState.currRoom == 7: #Armory
				display("You cannot go that way.")

			elif currentState.currRoom == 8: #Garrison
				display("You cannot go that way.")

			elif currentState.currRoom == 9: #Galley
				display("You cannot go that way.")

			elif currentState.currRoom == 10: #Ladder
				display("UPPER LEVEL")
				currentState.currRoom = ladder.up #Updates current user location to ID 11 (**PENDING**)

		elif userInput == "27": #GO DOWN
			if currentState.currRoom == 1: #Brig
				display("You cannot go that way.")

			elif currentState.currRoom == 2: #Storage
				display("You cannot go that way.")

			elif currentState.currRoom == 3: #Lower Hallway
				display("You cannot go that way.")

			elif currentState.currRoom == 4: #Observation
				display("You cannot go that way.")

			elif currentState.currRoom == 5: #Examination
				display("You cannot go that way.")

			elif currentState.currRoom == 6: #Rum
				currentState.currRoom = rum.down #Updates current user location to ID 6 (Rum)

			elif currentState.currRoom == 7: #Armory
				display("You cannot go that way.")

			elif currentState.currRoom == 8: #Garrison
				display("You cannot go that way.")

			elif currentState.currRoom == 9: #Galley
				display("You cannot go that way.")

			elif currentState.currRoom == 10: #Ladder
				display("You cannot go that way.")

		elif userInput == "28": #Take handle
			#If object discovered and if player is in the same room as the object
			if currentState.rm02o1 == 1 and currentState.obj3Loc == currentState.currRoom:
				currentState.obj3Loc = 99 #Add handle to player inventory
				display(handle.take)
			else:
				display(handle.notAvail)

		elif userInput == "29": #Drop handle
			if currentState.obj3Loc == 99: #In inventory to drop
				currentState.obj3Loc = currentState.currRoom
				display(handle.drop)
			else:
				display(handle.notInInv)

		elif userInput == "30": #Take skeleton key
			#If object discovered and if player is in the same room as the object
			if currentState.rm04o1 == 1 and currentState.obj4Loc == currentState.currRoom:
				currentState.obj4Loc = 99 #Add skeleton key to player inventory
				display(skeletonKey.take)
			else:
				display(skeletonKey.notAvail)

		elif userInput == "31": #Drop skeleton key
			if currentState.obj4Loc == 99: #In inventory to drop
				currentState.obj4Loc = currentState.currRoom
				display(skeletonKey.drop)
			else:
				display(skeletonKey.notInInv)

		elif userInput == "32": #Look at object "handle"
			if currentState.obj3Loc ==99: #In inventory
				display(handle.desc)
			else: #Not in inventory
				display(handle.notInInv)

		elif userInput == "33": #Look at object "skeleton key"
			if currentState.obj4Loc ==99: #In inventory
				display(skeletonKey.desc)
			else: #Not in inventory
				display(skeletonKey.notInInv)

		elif userInput == "34": #Look at object "small key"
			if currentState.obj5Loc ==99: #In inventory
				display(smallKey.desc)
			else: #Not in inventory
				display(smallKey.notInInv)

		elif userInput == "35": #Take small key
			#If object discovered and if player is in the same room as the object
			if currentState.rm06o1 == 1 and currentState.obj5Loc == currentState.currRoom:
				currentState.obj5Loc = 99 #Add board to player inventory
				display(smallKey.take)
			else:
				display(smallKey.notAvail)

		elif userInput == "36": #Drop small key
			if currentState.obj5Loc == 99: #In inventory to drop
				currentState.obj5Loc = currentState.currRoom
				display(smallKey.drop)
			else:
				display(smallKey.notInInv)

		elif userInput == "37": #Look at object "gun"
			if currentState.obj6Loc == 99: #In inventory
				display(gun.desc)
			else: #Not in inventory
				display(gun.notInInv)

		elif userInput == "38": #Take gun
			#If object discovered and if player is in the same room as the object
			if currentState.rm07o1 == 1 and currentState.obj6Loc == currentState.currRoom:
				currentState.obj6Loc = 99 #Add board to player inventory
				display(gun.take)
			else:
				display(gun.notAvail)

		elif userInput == "39": #Drop gun
			if currentState.obj6Loc == 99: #In inventory to drop
				currentState.obj6Loc = currentState.currRoom
				display(gun.drop)
			else:
				display(gun.notInInv)

		else:
			display("Invalid input")
		#[END ENGINE]

	if userInput == "loadgame":
		print "Load game"
		#PENDING - Load game function {Data Dev}

	elif userInput == "savegame":
		print "Save game"
		#PENDING - Save game function {Data Dev}

	elif userInput == "quit" or "exit":
		exitGame()

#[END PLAY GAME]


#[References]
#ASCII Title Art Generator - http://patorjk.com/software/taag/#p=display&f=Doom&t=Dead%0AIn%0AThe%20%0AWater
示例#23
0
import crawl
import parse

from common import arg_parser

if __name__ == '__main__':
  args = arg_parser()

  if args.crawl:
    crawl.main()
  parse.main()
示例#24
0
from dotenv import load_dotenv
import json
from datetime import datetime


def write_json(dictionary, date, filename = 'data'):
    # Dump dict to json then write to json file
    with open(f'data/{filename}-{date}.json', 'w') as outfile:
        json.dump(dictionary, outfile, indent = 4)


if __name__ == '__main__':
    start_time = time() # Starts timer
    current_datetime = datetime.now().strftime("%m-%d-%y(%H-%M-%S)") 
    # Check if there arguments entered in terminal
    if len(sys.argv) >= 2:
        filename = 'response'
        load_dotenv()
        data = request.main(sys.argv[1])
        write_json(data, current_datetime, filename)
    else:
        # If there is only 1 argument parse operators from multiple files
        data = parse.main()
        write_json(data, current_datetime)
    execution_time = (time() - start_time) # Calculate script execution time
    print(f'Run time: {execution_time}s')
    
    
    

示例#25
0
 def test_basic_cli(self):
     output = parse.main(["--help"])
示例#26
0
def main():
    parser = argparse.ArgumentParser()

    # required arguments
    parser.add_argument('sourcefile',
                        type=str,
                        help='source of information for paragraph')
    parser.add_argument('stylefile', type=str, help='essay in style of author')
    parser.add_argument(
        'keyword_weight',
        type=float,
        help=
        "multiplicative weight of key words. e.g. a weight of 2 doubles probabilities of keywords"
    )
    parser.add_argument('num_keywords',
                        type=int,
                        help="number of keywords to grab")
    parser.add_argument(
        'bigram_weight',
        type=float,
        help=
        "weight of bigram probability to be used in generating emissions, e.g. 0 means only uses HMM, 1 means only uses Bigram"
    )

    args = parser.parse_args()

    if args.bigram_weight > 1 or args.bigram_weight < 0:
        raise Exception("bigram_weight must be in range [0,1]")

    cd = os.getcwd()

    transitions = get_transitions(cd + "/sourcedocs/" + args.stylefile)
    print "transitions complete"

    emissions = get_emissions(cd + "/sourcedocs/" + args.sourcefile,
                              args.keyword_weight, args.num_keywords)
    print "emissions complete"

    relcounts = get_relcounts(cd + "/sourcedocs/" + args.sourcefile)
    print "relcounts complete"

    # make output directory if none yet exists
    if not os.path.isdir("output"):
        os.mkdir("output")

    outputfile = (args.sourcefile.split('.')[0] + "_" +
                  args.stylefile.split('.')[0] + "-" +
                  str(args.keyword_weight) + "_" + str(args.bigram_weight) +
                  ".txt")

    # generate sentences, and write to 2 files: outputfile and file to generate paragraph
    o = codecs.open(cd + "/output/" + outputfile, 'a', 'utf8')
    input_f = codecs.open('input.txt', 'w+', 'utf8')
    o.write('\n\n****** NEW TRIAL ******\n')
    for _ in range(20):
        new_line = ' '.join(
            generate(transitions, emissions, relcounts, args.bigram_weight))
        o.write(new_line + '\n')
        input_f.write(new_line + '\n')

    # parse sentences
    parsed_sents = parse.main(5)

    # write parsed sentences to file in /paragraphs dir
    if not os.path.isdir(cd + '/paragraphs'):
        os.mkdir("paragraphs")
    essay_fname = 'paragraphs/essay_' + args.sourcefile.split(
        '.')[0] + "_" + args.stylefile.split('.')[0] + "-" + str(
            args.keyword_weight) + "_" + str(args.bigram_weight) + ".txt"
    output_essay = open(essay_fname, 'w+')
    essay = ' '.join(parsed_sents)
    output_essay.write(essay)

    print "\nDONE, written to:", essay_fname