Exemple #1
0
 def __init__(self, phyvalues, dimension=None):
     if dimension is not None:
         super().__init__(phyvalues, dimension)
     else:
         x, y, z = phyvalues
         assert same(x.dimension, y.dimension) and same(x.dimension, z.dimension)
         super().__init__([x.value, y.value, z.value], x.dimension)
Exemple #2
0
def check_replacing(party, possible_dead_events):
    possible_dead = []
    possible_match = 0
    for pde in possible_dead_events:
        # we allow for a slight change in name when updating the place
        if party.time == pde[3] and utils.same(party.place, pde[2]) and utils.same(party.name, pde[1]):
            possible_match = pde[0]
        else:
            possible_dead.append(pde)
    return (possible_match, possible_dead)
Exemple #3
0
def set_location(cursor, event_id, event_place):
    cursor.execute("select id, comparison_name from locations")
    locations = cursor.fetchall()
    for location in locations:
        if utils.same(utils.remove_uneeded(event_place), location[1], 0.2):
            print ("adding new location to event %s" % event_id)
            cursor.execute("update events set id_location = %s where id = %s" % (location[0], event_id))
Exemple #4
0
def check_renaming(party, possible_dead_events):
    possible_dead = []
    possible_match = 0
    for pde in possible_dead_events:
        # date is 2 for www, 3 for pde
        # place is 1 for www, 2 for pde
        # name is 0 for www, 1 for pde
        if party.time == pde[3] and utils.same(party.name, pde[1]):
            possible_match = pde[0]
        else:
            possible_dead.append(pde)
    return (possible_match, possible_dead)
Exemple #5
0
def add_new_location(location_id, comparison_name):
    events = web.select(tables="events", what="id, place", where="id_location is null")
    for event in events:
        if utils.same(utils.remove_uneeded(event.place), comparison_name, 0.2):
            web.debug("adding new location to event %s" % event.id)
            web.query("update events set id_location = %s where id = %s" % (location_id, event.id))
Exemple #6
0
 def __rsub__(self, lhs):
     assert isinstance(lhs, PhyUnit) and same(self.dimension, lhs.dimension)
     subvalue = lhs.value - self.value
     dimension = self.dimension
     return type(self)(subvalue, dimension)
Exemple #7
0
 def __radd__(self, addend):
     assert isinstance(addend, PhyUnit) and same(self.dimension, addend.dimension)
     addvalue = self.value + addend.value
     dimension = self.dimension
     return type(self)(addvalue, dimension)
Exemple #8
0
    print "\n- new parties : "
    # new parties have to be checked for possible cross reference across different sources
    # levenstheim distance has to be computed in order to check for different spellings

    for e in new_events:

        print "- %s" % e.__str2__()
        cursor.execute("select id, name, place, time_start, taken_from from events where time_start = %s", (e.time))
        parties_of_the_day = cursor.fetchall()
        has_twin = False
        # we have to check that the party was not alreade entered by another source, and we have to allow for some variation in the naming
        for potd in parties_of_the_day:
            # is same place and date we allow for greater variation
            # ok si if 2 parties have the same name but a different adress on the same night one gets ignored, too bad.
            if (utils.same(potd[1], e.name, 0.2) and utils.same(potd[2], e.place, 0.6)) or (
                utils.same(potd[1], e.name, 0.6) and utils.same(potd[2], e.place, 0.2)
            ):

                # identical party
                print "## found identical event: \n\t%s %s %s %s, %s\n\t%s %s %s %s" % (
                    potd[1],
                    potd[2],
                    potd[3],
                    potd[4],
                    potd[0],
                    utils.encode_null(e.name),
                    utils.encode_null(e.place),
                    e.time,
                    e.source,
                )