Ejemplo n.º 1
0
    def _run_map(self):

        args = self.args

        threshold = args.threshold
        stddevs = args.stddevs

        # if doing anything online, revalidate cache
        self.cacher.revalidate(args.map_id, self.users_info)

        if (args.map_id and args.user_id):  # passed both -m and -u but not -l
            replays2 = OnlineReplay.from_user_info(self.cacher, args.map_id,
                                                   self.users_info)
            comparer = Comparer(threshold,
                                args.silent,
                                self.replays_check,
                                replays2=replays2,
                                stddevs=stddevs)
            comparer.compare(mode="double")
            return

        if (args.map_id):  # only passed -m
            # get all 50 top replays
            replays = OnlineReplay.from_user_info(self.cacher, args.map_id,
                                                  self.users_info)
            comparer = Comparer(threshold,
                                args.silent,
                                replays,
                                stddevs=stddevs)
            comparer.compare(mode="single")
            return
Ejemplo n.º 2
0
    def _run_map(self):

        args = self.args
        # if doing anything online, revalidate cache
        Cacher.revalidate(args.map_id, self.users_info)

        if (args.map_id and args.user_id):  # passed both -m and -u but not -l
            replays2 = [
                OnlineReplay.from_map(args.map_id, user_id, args.cache,
                                      replay_id)
                for user_id, replay_id in self.users_info.items()
            ]
            comparer = Comparer(args.threshold,
                                self.replays_check,
                                replays2=replays2)
            comparer.compare(mode="double")
            return

        if (args.map_id):  # only passed -m
            # get all 50 top replays
            replays = [
                OnlineReplay.from_map(args.map_id, user_id, args.cache,
                                      replay_id)
                for user_id, replay_id in self.users_info.items()
            ]
            comparer = Comparer(args.threshold, replays)
            comparer.compare(mode="single")
            return
Ejemplo n.º 3
0
    def _run_verify(self):
        args = self.args

        map_id = self.args.verify[0]
        user1_id = self.args.verify[1]
        user2_id = self.args.verify[2]

        user1_info = Loader.user_info(map_id, user1_id)
        user2_info = Loader.user_info(map_id, user2_id)
        replay1 = OnlineReplay.from_user_info(self.cacher, map_id, user1_info)
        replay2 = OnlineReplay.from_user_info(self.cacher, map_id, user2_info)

        comparer = Comparer(args.threshold,
                            args.silent,
                            replay1,
                            replays2=replay2,
                            stddevs=args.stddevs)
        comparer.compare(mode="double")
Ejemplo n.º 4
0
    def test(self):
        first = "This is an Apple.\nThat is a Banana."
        second = "No.\nThis is a Banana.\nTHAT is an Apple."

        class resolver():
            def resolve(self, diffs):
                return diffs

        diffs = Comparer(resolver()).compare_and_resolve(first, second)
        assert (len(diffs[-1]) == 1 and diffs[-1][0] == "n Apple.\nThat is a Banana") and \
               (len(diffs[1]) == 2 and "No.\n" in diffs[1] and " Banana.\nTHAT is an Apple" in diffs[1])
Ejemplo n.º 5
0
def main():
    """ This is the entry point"""
    valid_file = False

    filename1 = input("Please enter first html file name:")
    filename2 = input("Please enter the other html file name:")

    try:
        html1 = FileSource(filename1).get_content_and_close()
        html2 = FileSource(filename2).get_content_and_close()
    except IOError:
        print(
            "Unable to open the files. Please make sure they are available and try again."
        )
        return

    resolver = HumanResolver()
    Comparer(resolver).compare_and_resolve(HtmlParser().extractContent(html1),
                                           HtmlParser().extractContent(html2))
    print("Success. Please check the output.html to see the result.")
Ejemplo n.º 6
0
def main():
	file1Name = sys.argv[1]
	file2Name = sys.argv[2]
	comparisonToRun = sys.argv[3]
	
	data1 = []
	data2 = []
	
	with open(file1Name, 'rb') as csvfile:
		fileReader = csv.reader(csvfile)
		for row in fileReader:
			#print row
			data1.append(row)

	with open(file2Name, 'rb') as csvfile:
		fileReader = csv.reader(csvfile)
		for row in fileReader:
			data2.append(row)

	result = Comparer(data1, data2, comparisonToRun)

	if comparisonToRun == "totalDescription":
		result = Comparer(data1, data2, comparisonToRun)
		result.runTotalDescription()
	elif comparisonToRun == "BSL":
		result = Comparer(data1, data2, comparisonToRun)
		result.runBSL()
	elif comparisonToRun == "blockingTokens":
		result.runBlockingTokens()

	print result.evaluate(result, len(data1), len(data2))
Ejemplo n.º 7
0
username1 = sys.argv[1]
token1 = auth(username1)
songs1 = makePlaylist(token1, username1)
print("########### Songs in Playlist 1 ##############")
print(songs1)
logoutUser()

username2 = sys.argv[2]
token2 = auth(username2)
songs2 = makePlaylist(token2, username2)
print("########### Songs in Playlist 2 ##############")
print(songs2)
logoutUser()

comparer = Comparer(songs1, songs2)

print("########### Songs shared between both profiles ##############")
comparer.printCommonSongs()

print("########### Similarity Score for the two profiles ##############")
print(f"{comparer.similarity*100} %")
print("\n")

if (comparer.similarity == 1):
    print(f"The two profiles are identical!")

elif (comparer.isSimilar(0.000001)):
    print(
        f"The two profiles are very similar, {username1}, you might like these songs from {username2}'s library:"
    )
Ejemplo n.º 8
0
from flask_cors import CORS
from werkzeug.utils import secure_filename
from parserFnc import Parser
from comparer import Comparer
from analyzer import ResumeAnalyzer
from pdfminer import high_level
from dotenv import load_dotenv
import json
import psycopg2
import os
import sys
import signal

load_dotenv()
p = Parser()
c = Comparer(p, 1000)
a = ResumeAnalyzer(p)
app = Flask(__name__)
CORS(app)
UPLOAD_FOLDER = os.path.join('.', 'static', 'pdfs')
ALLOWED_EXTENSIONS = {'pdf'}
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER


def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS


@app.route('/api/upload', methods=['POST'])
def upload():
Ejemplo n.º 9
0
    def _run_local(self):

        args = self.args
        # get all local user replays (used in every --local case)
        replays1 = [
            LocalReplay.from_path(osr_path) for osr_path in PATH_REPLAYS_USER
        ]
        if (args.map_id and args.user_id):
            # compare every local replay with just the given user + map replay
            comparer = Comparer(args.threshold,
                                replays1,
                                replays2=self.replays_check)
            comparer.compare(mode="double")
            return
        if (args.map_id):
            # compare every local replay with every leaderboard entry
            replays2 = [
                OnlineReplay.from_map(args.map_id, user_id, args.cache,
                                      replay_id)
                for user_id, replay_id in self.users_info
            ]
            comparer = Comparer(args.threshold, replays1, replays2=replays2)
            comparer.compare(mode="double")
            return

        if (args.single):
            # checks every replay listed in PATH_REPLAYS_USER against every other replay there
            comparer = Comparer(args.threshold, replays1)
            comparer.compare(mode="single")
            return
        else:
            # checks every replay listed in PATH_REPLAYS_USER against every replay listed in PATH_REPLAYS_CHECK
            replays2 = [
                LocalReplay.from_path(osr_path)
                for osr_path in PATH_REPLAYS_CHECK
            ]
            comparer = Comparer(args.threshold, replays1, replays2=replays2)
            comparer.compare(mode="double")
            return
Ejemplo n.º 10
0
    def _run_local(self):

        args = self.args
        # get all local replays (used in every --local case)
        replays1 = [
            LocalReplay.from_path(osr_path) for osr_path in self.PATH_REPLAYS
        ]

        threshold = args.threshold
        stddevs = args.stddevs

        if (args.map_id and args.user_id):
            # compare every local replay with just the given user + map replay
            comparer = Comparer(threshold,
                                args.silent,
                                replays1,
                                replays2=self.replays_check,
                                stddevs=stddevs)
            comparer.compare(mode="double")
            return
        if (args.map_id):
            # compare every local replay with every leaderboard entry
            replays2 = OnlineReplay.from_user_info(self.cacher, args.map_id,
                                                   self.users_info)
            comparer = Comparer(threshold,
                                args.silent,
                                replays1,
                                replays2=replays2,
                                stddevs=stddevs)
            comparer.compare(mode="double")
            return
        else:
            comparer = Comparer(threshold,
                                args.silent,
                                replays1,
                                stddevs=stddevs)
            comparer.compare(mode="single")
Ejemplo n.º 11
0
def compare_models():
    c = Comparer(no_of_testcases=100, nb=nb, bw=bw)
    c.ready()
    c.compare()
Ejemplo n.º 12
0
                    unusedVariables = slvr.findUnusedVariables()
                    if len(unusedVariables):
                        logger.warning(
                            "There are some unused input varables: %s\n" %
                            (str(unusedVariables)))
                    if args.graph:
                        grph.export()
            except Exception:
                print(traceback.format_exc())

    if args.nozzleplot:
        nozzleplotter = NozzlePlotter(rocketModels)
        nozzleplotter.make()

    if args.compare:
        comparer = Comparer(rocketModels)
        comparer.make()

    if args.postproc:
        postProcesser = PostProcesser(rocketModels)
        postProcesser.make()

    if args.latex:
        latexer = Latexer(rocketModels)
        latexer.make()

    if args.outputcea:
        outputcea = OutputCea(rocketModels)
        outputcea.make()

    #pp.pprint(rocketModels)
Ejemplo n.º 13
0
            yield skip

        # Shift by the precalculated offset given by the character in the text
        # at the far right of the pattern, so that it lines up with an equal
        # character in the pattern, if posssible. Otherwise the pattern is
        # moved to after this position.
        skip += table[text[skip + len(pattern) - 1]]


if __name__ == "__main__":
    try:
        pattern = argv[1]
        text = argv[2]
    except IndexError:
        print("usage: python3 bmh.py PATTERN TEXT")
        exit()

    print(f'Searching for "{pattern}" in "{text}".')
    print()

    compare = Comparer()

    table = precalc(pattern)
    print(f'Precomputed shift table: {dict(table)}')
    print()

    for match in run_bmh(table, text, pattern, compare):
        print(f"Match found at position {match}")

    print(f"{compare.count} comparisons")
Ejemplo n.º 14
0
 def compareAnnotations(self):
     comparer = Comparer(self.Form)
     comparer.compareAnnotations()