def main(): # Commonly used data # Use Parse module to import dataset prepare fetaures and # vocabulary and test data parse = p.ParseData() sw = parse.stopWords("Stopwords.txt") td = parse.test("TestData", sw) vocabulary, classcount, documents, classes = parse.training( "LargeIMDB", sw) ln = len(classes["neg"]) lp = len(classes["pos"]) # Make length same on both sets of data if ln > lp: classes["neg"] = classes["neg"][0:lp] if lp > ln: classes["pos"] = classes["pos"][0:ln] # Use Calc class to retrive term frequency of each class calc = c.Calculate(vocabulary) nf = calc.termFrequency(vocabulary, classes["neg"]) pf = calc.termFrequency(vocabulary, classes["pos"]) # Get term probability multinomial model formula np = calc.termProbability(vocabulary, nf) pp = calc.termProbability(vocabulary, pf) # Get probablity for each class ncp = calc.classProbability(documents, classcount["neg"]) pcp = calc.classProbability(documents, classcount["pos"]) negativeResults = [] postiveResults = [] correctn = 0 correctp = 0 # Test all knows negative test documents for tst in td["neg"]: negativeResults.append( calc.classification(ncp, pcp, np, pp, td["neg"][tst])) # Test all knows negative test documents for tst in td["pos"]: postiveResults.append( calc.classification(ncp, pcp, np, pp, td["pos"][tst])) for i in negativeResults: if i == False: correctn += 1 for i in postiveResults: if i == True: correctp += 1 negp = (correctn / len(td["neg"])) * 100 posp = (correctp / len(td["pos"])) * 100 acuracy = (negp + posp) / 2 print("documents", documents) print("tests", len(td["neg"]) + len(td["pos"])) print("nagative ", correctn, "/", len(td["neg"])) print("postive ", correctp, "/", len(td["pos"])) print(acuracy, "% accurate") return
#!/usr/bin/env python3 import sys import calculate from math import * operation = input("Operation: ") calc = calculate.Calculate(); result = calc.execute(operation) print(result)
import calculate import inputfiles import os import outputfiles def list_files(directory, extension): return (f for f in os.listdir(directory) if f.endswith('.' + extension)) calculate_method = calculate.Calculate('template.inp', 'C:\\Users\\Public\\gamess-64\\', 'rungms.bat', '2018-R1-pgi-mkl 4 0') main_dir = 'C:\\Users\\Public\\gamess-64\\CF3SO3_CH3CN_n\\' files = files = list_files(main_dir, "txt") for file in files: name = os.path.splitext(file)[0] sub_dir = os.path.join(main_dir, name) try: calculate_method.run(os.path.join(main_dir, file), sub_dir, name, inputfiles.Method.DFT, '-1') except: pass try: calculate_method.run(os.path.join(main_dir, file), sub_dir, name, inputfiles.Method.MP2, '-1') except: pass
import settings import calculate import results import CommandErrorHandler import info import read import DataWriter import DataSender guild_id = 740596566632562760 bot = commands.Bot(command_prefix='+') @bot.event async def on_ready(): await bot.change_presence(activity=discord.Game('Made by Shep and Peter!')) print(f'Logged in as: {bot.user.name}') print(f'With ID: {bot.user.id}') bot.add_cog(settings.Settings(bot)) bot.add_cog(calculate.Calculate(bot)) bot.add_cog(results.Results(bot)) #bot.add_cog(CommandErrorHandler.CommandErrorHandler(bot)) bot.add_cog(info.Info(bot)) bot.add_cog(read.Read(bot)) bot.add_cog(DataSender.DataSender(bot, guild_id)) bot.add_cog(DataWriter.DataWriter(bot)) with open('work_bot_token.txt', 'r') as f: bot.run(f.read().strip())
def mp2(exp): return cl.Calculate(logging, exp, corr)
import calculate height = 0.0 print"Welcome to your BMI calclulator!!" print"Would you like to enter your weight in (K)ilogram or (p)ound" weight_type = raw_input("> ") weight = float(raw_input("Your weight: ")) print"Would you like to enter your height in (m)eter or (f)eet and inches or (I)nches" height_type = raw_input("> ").upper() if height_type == 'M': height = float(raw_input("Your height in m: ")) calc = calculate.Calculate(height,weight,weight_type) elif height_type == 'F': feet_height = int(raw_input("Your height in (feet only): ")) inch_height = int(raw_input("Your height in (inches): ")) else: inch_height = int(raw_input("Your height in (inches): ")) #height = float(raw_input("Your height in m: "))