Compare commits

...

3 Commits

Author SHA1 Message Date
kallejre 1963c0ff00 Update wonderful _cleanup.py 3 years ago
kallejre a982728c48 style 3 years ago
kallejre 3e83eb0d5f done 3 years ago
  1. 87
      mystery/crimescene2
  2. 5024
      people.csv
  3. 4
      possible sus.txt
  4. 149
      wonderful _cleanup.py

87
mystery/crimescene2

@ -0,0 +1,87 @@
*******
Crime Scene Report #028615332953
********
CLUE: Found a wallet believed to belong to the killer: no ID, just loose change, and membership cards for AAA, Delta SkyMiles, the local library, and the Museum of Bash History. The cards are totally untraceable and have no name, for some reason.
*******
Crime Scene Report #575776622208
********
CLUE: Questioned the barista at the local coffee shop. He said a woman left right before they heard the shots. The name on her latte was Annabel, she had blond spiky hair and a New Zealand accent.
*******
Crime Scene Report #912464709392
********
CLUE: Footage from an ATM security camera is blurry but shows that the perpetrator is a tall male, at least 6'.
*******
Crime*******
Crime Scene Report #000515338921
********
would be
wasting
our
breath."
"I'll be
judge, I'll
be jury,"
Said
cunning
old Fury:
"I'll
try the
*******
Crime Scene Report #001087293595
********
whole
cause,
and
condemn
you
to
death."'
*******
Crime Scene Report #009057306824
********
Longitude either, but thought they were nice grand words to say.)
Presently she began again. 'I wonder if I shall fall right THROUGH the
earth! How funny it'll seem to come out among the people that walk with
their heads downward! The Antipathies, I think--' (she was rather glad
there WAS no one listening, this time, as it didn't sound at all the
right word) '--but I shall have to ask them what the name of the country
is, you know. Please, Ma'am, is this New Zealand or Australia?' (and
she tried to curtsey as she spoke--fancy CURTSEYING as you're falling
through the air! Do you think you could manage it?) 'And what an
ignorant little girl she'll think me for asking! No, it'll never do to
*******
Crime Scene Report #015542865662
********
[later editions continued as follows
When the sands are all dry, he is gay as a lark,
And will talk in contemptuous tones of the Shark,
But, when the tide rises and sharks are around,
His voice has a timid and tremulous sound.]
*******
Crime Scene Report #020826636519
********
It did so indeed, and much sooner than she had expected: before she had
drunk half the bottle, she found her head pressing against the ceiling,
and had to stoop to save her neck from being broken. She hastily put
down the bottle, saying to herself 'That's quite enough--I hope I shan't
grow any more--As it is, I can't get out at the door--I do wish I hadn't
*******
Crime Scene Report #024871257593
********
fellow?'
The Mock Turtle sighed deeply, and began, in a voice sometimes choked
with sobs, to sing this:--
'Beautiful Soup, so rich and green,
Waiting in a hot tureen!
Who for such dainties would not stoop?
Soup of the evening, beautiful Soup!
Soup of the evening, beautiful Soup!
Beau--ootiful Soo--oop!

5024
people.csv

File diff suppressed because it is too large diff.load

4
possible sus.txt

@ -0,0 +1,4 @@
Full name First Last G Height Age Weight Address Sus Make Color Plate Membership Interview
Brian Boyer Brian Boyer M 198,12 39 91,17 Harbor Point Boulevard, 183 Jaguar Blue L337OI9 AAA, Delta_SkyMiles, Museum_of_Bash_History, Terminal_City_Library fits the profile, except for the make of his car. should be considered a suspect if and only if there is evidence boyer owns a second car.
Dartey Henv Dartey Henv 185,42 92,53 Honda Blue L3375A9 AAA, Delta_SkyMiles, Museum_of_Bash_History, Terminal_City_Library
Hellen Maher Hellen Maher 187,96 58,97 Honda Blue L337WR9 AAA, Delta_SkyMiles, Museum_of_Bash_History, Terminal_City_Library

149
wonderful _cleanup.py

@ -0,0 +1,149 @@
import os
import re
crime_separator = '*******\nCrime'
not_sus_regex = r"[Nn][o\']t[ a-z]*sus"
not_sus = re.compile(not_sus_regex, re.IGNORECASE)
people = dict()
companies = set()
wonderful_blacklist = {'alice', 'hatter', 'rabbit', 'march mare'}
# in_to_cm('6\'0"') == 182.88
class Person:
def __init__(self, name):
n = name.strip().split()
if len(n) > 2:
print(name)
self.first = n[0]
self.last = n[1]
self.memberships = set()
self.gender = None
self.age = None
self.not_sus = None
self.addr = None
self.interview = None
self.height = None
self.weight = None
self.plate = None
self.make = None
self.color = None
def add_member(self, comp):
self.memberships.add(comp)
def __repr__(self):
out = list()
for i in sorted(filter(lambda x: x[0] != '_', dir(self))):
if not callable(eval('self.' + i)):
out.append(': '.join([i, str(eval('self.' + i))]))
return '\n'.join(out)
def in_to_cm(inch):
return round(int(inch.split('\'')[0]) * 30.48 + int(inch.split('\'')[1][:-1]) * 2.54, 2)
def lb_to_kg(lb):
return round(int(lb.split()[0]) * 0.4536, 2)
def check_wonders(x):
x = x.lower()
for alice in wonderful_blacklist:
if alice in x:
return False
return True
def format_output(field):
if not field:
return ''
elif type(field) in {list, tuple}:
return ', '.join(list(map(format_output, field)))
elif type(field) in {set}:
return ', '.join(list(map(format_output, sorted(field))))
elif type(field) is float:
return str(field).replace('.', ',')
else:
return str(field).replace('\n', ' ')
with open(r'mystery\crimescene') as f:
scene = filter(lambda x: check_wonders(x), f.read().split(crime_separator))
with open(r'mystery\crimescene2', 'w') as f:
t = list(sorted(scene, key=lambda x: (not 'clue' in x.lower(), x)))[:10]
t = crime_separator + crime_separator.join(t)
print(t.replace('\n\n\n', '\n'), file=f)
addresses = dict()
for streetname in os.listdir(r'mystery\streets'):
with open(r'mystery\streets' + '\\' + streetname) as f:
street = f.readlines()
ints = set()
for nr in range(len(street)):
if 'SEE INTER' in street[nr]:
ints.add((streetname, nr + 1, street[nr].strip().split('#')[1]))
for inter in ints:
intr = inter[2]
with open(r'mystery\interviews\interview-' + intr) as inf:
inview = inf.read().strip().lower().replace('\n', ' ')
ns = bool(not_sus.findall(inview))
# if ns: print(inview)
streetname = inter[0].replace('_', ' ')
addresses[(streetname, str(inter[1]))] = {'ns': ns, 'interv': inview}
for comp in os.listdir(r'mystery\memberships'):
with open(r'mystery\memberships' + '\\' + comp) as f:
for name in f:
name = name.strip()
if name not in people:
people[name] = Person(name)
people[name].add_member(comp)
with open(r'mystery\people') as f:
for line in f.readlines()[8:]:
name, g, age, addr = line.strip().split('\t')
name = name.strip()
if name not in people:
people[name] = Person(name)
people[name].age = age.strip()
people[name].gender = g.strip()
people[name].addr = tuple(addr.split(', line '))
if people[name].addr in addresses:
people[name].interview = addresses[people[name].addr]['interv']
people[name].not_sus = addresses[people[name].addr]['ns']
with open(r'mystery\vehicles') as f:
for car in f.read().split('\n\n')[1:]:
t = list(map(lambda x: x.replace('se Plate', 'te:').split(': ')[1].strip(), car.strip().split('\n')))
plate, make, color, name, hei, wei = t
if name not in people:
people[name] = Person(name)
people[name].height = in_to_cm(hei)
people[name].weight = lb_to_kg(wei)
people[name].plate = plate
people[name].make = make
people[name].color = color
f = open('people.csv', 'w')
print('Full name;First;Last;G;Height;Age;Weight;Address;Sus;Make;Color;Plate;Membership;Interview', file=f)
for name in sorted(people):
output_row = [name]
pp = people[name]
output_row.append(pp.first)
output_row.append(pp.last)
output_row.append(pp.gender)
output_row.append(pp.height)
output_row.append(pp.age)
output_row.append(pp.weight)
output_row.append(pp.addr)
output_row.append(pp.not_sus)
output_row.append(pp.make)
output_row.append(pp.color)
output_row.append(pp.plate)
output_row.append(pp.memberships)
output_row.append(pp.interview)
print(*list(map(format_output, output_row)), sep=';', file=f)
f.close()
Loading…
Cancel
Save