aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-06-05 16:37:55 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-06-05 16:37:55 +0100
commit939e7aa65abe18f57a129fee590f46b7cd32f688 (patch)
treec0c56d0360f549807395bf087533e2269e16e81f /scripts
parent8c04e4d8003f33848ee84011f8427fe92d55001f (diff)
downloadACQuA-939e7aa65abe18f57a129fee590f46b7cd32f688.tar.gz
ACQuA-939e7aa65abe18f57a129fee590f46b7cd32f688.zip
Violations processor (Python script).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Violations_processor.py48
-rw-r--r--scripts/list_of_words.txt907
2 files changed, 955 insertions, 0 deletions
diff --git a/scripts/Violations_processor.py b/scripts/Violations_processor.py
new file mode 100644
index 0000000..62c1ade
--- /dev/null
+++ b/scripts/Violations_processor.py
@@ -0,0 +1,48 @@
1import json
2import argparse
3from os.path import dirname, join
4
5class Cleaner:
6 """Given a violation, it can make it very readable.
7
8 For example from:
9 atLeast(1 <RO_0002110> <FBbt_00003972>)(X) :- <auxiliary#NC36>(X)
10 to:
11 active(X) -> across(X,Y), act(Y)
12 """
13
14 def __init__(self):
15 with open(join(dirname(__file__),'list_of_words.txt'), 'r') as f:
16 self._words = [x.strip() for x in f]
17 self._used_words = 0
18 self._cache = {}
19
20 def clean(self, violation, prefix):
21 j = 0
22 atoms = []
23 for i in range(3):
24 i = violation.find('<', j) + 1
25 j = violation.find('>', i)
26 atom = violation[i:j]
27 if atom not in self._cache:
28 self._cache[atom] = str(prefix) + self._words[self._used_words]
29 self._used_words += 1
30 atoms.append(self._cache[atom])
31 return '%10s(X) -> %10s(X,Y), %10s(Y)' % (atoms[2], atoms[0], atoms[1])
32
33
34if __name__ == '__main__':
35 parser = argparse.ArgumentParser(description='Transform violations (as output by PAGOdA) into a very readable form.')
36 parser.add_argument('input', help='json file containing violations')
37 args = parser.parse_args()
38
39 cleaner = Cleaner()
40 with open(args.input, 'r') as f:
41 violations_list_list = json.load(f)['violationClauses']
42 clean_rules_list_list = []
43 i = 0
44 for violations_list in violations_list_list:
45 clean_rules_list_list.append(sorted(map(lambda x: cleaner.clean(x, i), violations_list)))
46 i += 1
47 print json.dumps(clean_rules_list_list, indent=2)
48
diff --git a/scripts/list_of_words.txt b/scripts/list_of_words.txt
new file mode 100644
index 0000000..5ac8658
--- /dev/null
+++ b/scripts/list_of_words.txt
@@ -0,0 +1,907 @@
1across
2act
3active
4activity
5add
6afraid
7age
8ago
9agree
10air
11alone
12along
13already
14always
15amount
16angry
17another
18answer
19anyone
20anything
21anytime
22appear
23apple
24area
25arm
26army
27around
28arrive
29art
30ask
31attack
32aunt
33autumn
34away
35baby
36back
37bad
38bag
39ball
40bank
41base
42basket
43bath
44bean
45bear
46beautiful
47bed
48bedroom
49beer
50behave
51begin
52behind
53bell
54besides
55best
56better
57big
58bird
59birth
60birthday
61bit
62bite
63black
64bleed
65block
66blood
67blow
68blue
69board
70boat
71body
72boil
73bone
74book
75border
76born
77borrow
78bottle
79bottom
80bowl
81box
82boy
83branch
84brave
85bread
86break
87breakfast
88breathe
89bridge
90bright
91bring
92brother
93brown
94brush
95build
96burn
97business
98bus
99busy
100buy
101cake
102call
103can
104candle
105cap
106car
107card
108care
109careful
110careless
111carry
112case
113cat
114catch
115central
116century
117certain
118chair
119chance
120change
121chase
122cheap
123cheese
124chicken
125child
126children
127chocolate
128choice
129choose
130circle
131city
132class
133clever
134clean
135clear
136climb
137clock
138cloth
139clothes
140cloud
141cloudy
142close
143coffee
144coat
145coin
146cold
147collect
148colour
149comb
150comfortable
151common
152compare
153come
154complete
155computer
156condition
157continue
158control
159cook
160cool
161copper
162corn
163corner
164correct
165cost
166contain
167count
168country
169course
170cover
171crash
172cross
173cry
174cup
175cupboard
176cut
177dance
178dangerous
179dark
180daughter
181day
182dead
183decide
184decrease
185deep
186deer
187depend
188desk
189destroy
190develop
191die
192different
193difficult
194dinner
195direction
196dirty
197discover
198dish
199dog
200door
201double
202draw
203dream
204dress
205drink
206drive
207drop
208dry
209duck
210dust
211duty
212ear
213early
214earn
215earth
216east
217easy
218eat
219education
220effect
221egg
222eight
223either
224electric
225elephant
226else
227empty
228end
229enemy
230enjoy
231enough
232enter
233equal
234entrance
235escape
236even
237evening
238event
239ever
240every
241everyone
242exact
243everybody
244examination
245example
246except
247excited
248exercise
249expect
250expensive
251explain
252extremely
253eye
254face
255fact
256fail
257fall
258false
259family
260famous
261far
262farm
263father
264fast
265fat
266fault
267fear
268feed
269feel
270female
271fever
272fight
273fill
274film
275find
276fine
277finger
278finish
279fire
280first
281fish
282fit
283five
284fix
285flag
286flat
287float
288floor
289flour
290flower
291fly
292fold
293food
294fool
295foot
296football
297force
298foreign
299forest
300forget
301forgive
302fork
303form
304fox
305four
306free
307freedom
308freeze
309fresh
310friend
311friendly
312front
313fruit
314full
315fun
316funny
317furniture
318future
319game
320garden
321gate
322general
323gentleman
324get
325gift
326give
327glad
328glass
329go
330goat
331god
332gold
333good
334goodbye
335grandfather
336grandmother
337grass
338grave
339great
340green
341grey
342ground
343group
344grow
345gun
346hair
347half
348hall
349hammer
350hand
351happen
352happy
353hard
354hat
355hate
356head
357healthy
358hear
359heavy
360heart
361heaven
362height
363hello
364help
365hen
366hide
367high
368hill
369hit
370hobby
371hold
372hole
373holiday
374home
375hope
376horse
377hospital
378hot
379hotel
380house
381hundred
382hungry
383hour
384hurry
385husband
386hurt
387I
388ice
389idea
390important
391increase
392inside
393introduce
394invent
395iron
396invite
397island
398jelly
399job
400join
401juice
402jump
403just
404keep
405key
406kill
407kind
408king
409kitchen
410knee
411knife
412knock
413know
414ladder
415lady
416lamp
417land
418large
419last
420late
421lately
422laugh
423lazy
424lead
425leaf
426learn
427leave
428leg
429left
430lend
431length
432less
433lesson
434let
435letter
436library
437lie
438life
439light
440like
441lion
442lip
443list
444listen
445little
446live
447lock
448lonely
449long
450look
451lose
452lot
453love
454low
455lower
456luck
457machine
458main
459make
460male
461man
462many
463map
464mark
465market
466marry
467matter
468may
469meal
470mean
471measure
472meat
473medicine
474meet
475member
476mention
477method
478middle
479milk
480million
481mind
482minute
483miss
484mistake
485mix
486model
487modern
488moment
489money
490monkey
491month
492moon
493morning
494mother
495mountain
496mouth
497move
498much
499music
500must
501name
502narrow
503nation
504nature
505near
506nearly
507neck
508need
509needle
510neighbour
511neither
512net
513never
514new
515news
516newspaper
517next
518nice
519night
520nine
521noble
522noise
523none
524north
525nose
526nothing
527notice
528now
529number
530obey
531object
532ocean
533offer
534office
535often
536oil
537old
538one
539open
540opposite
541orange
542order
543outside
544page
545pain
546paint
547pair
548pan
549paper
550parent
551park
552part
553partner
554party
555pass
556past
557path
558pay
559peace
560pen
561pencil
562people
563pepper
564per
565perfect
566period
567person
568petrol
569photograph
570piano
571pick
572picture
573piece
574pig
575pin
576pink
577place
578plane
579plant
580plastic
581plate
582play
583please
584pleased
585plenty
586pocket
587point
588poison
589police
590polite
591pool
592poor
593popular
594position
595possible
596potato
597pour
598power
599present
600press
601pretty
602prevent
603price
604prince
605prison
606private
607prize
608probably
609problem
610produce
611promise
612proper
613protect
614provide
615public
616pull
617punish
618pupil
619push
620put
621queen
622question
623quick
624quiet
625quite
626radio
627rain
628rainy
629raise
630reach
631read
632ready
633real
634really
635receive
636record
637red
638remember
639remind
640remove
641rent
642repair
643repeat
644reply
645report
646rest
647restaurant
648result
649return
650rice
651rich
652ride
653right
654ring
655rise
656road
657rob
658rock
659room
660round
661rubber
662rude
663rule
664ruler
665run
666rush
667sad
668safe
669sail
670salt
671sand
672save
673say
674school
675science
676scissors
677search
678seat
679second
680see
681seem
682sell
683send
684sentence
685serve
686seven
687several
688sex
689shade
690shadow
691shake
692shape
693share
694sharp
695sheep
696sheet
697shelf
698shine
699ship
700shirt
701shoe
702shoot
703shop
704short
705shoulder
706shout
707show
708sick
709side
710signal
711silence
712silly
713silver
714similar
715simple
716single
717since
718sing
719sink
720sister
721sit
722six
723size
724skill
725skin
726skirt
727sky
728sleep
729slip
730slow
731small
732smell
733smile
734smoke
735snow
736soap
737sock
738soft
739someone
740something
741sometimes
742son
743soon
744sorry
745sound
746soup
747south
748space
749speak
750special
751speed
752spell
753spend
754spoon
755sport
756spread
757spring
758square
759stamp
760stand
761star
762start
763station
764stay
765steal
766steam
767step
768still
769stomach
770stone
771stop
772store
773storm
774story
775strange
776street
777strong
778structure
779student
780study
781stupid
782subject
783substance
784successful
785sudden
786sugar
787suitable
788summer
789sun
790sunny
791support
792sure
793surprise
794sweet
795swim
796sword
797table
798take
799talk
800tall
801taste
802taxi
803tea
804teach
805team
806tear
807telephone
808television
809tell
810ten
811tennis
812terrible
813test
814therefore
815thick
816thin
817thing
818think
819third
820though
821threat
822three
823tidy
824tie
825title
826today
827toe
828together
829tomorrow
830tonight
831tool
832tooth
833top
834total
835touch
836town
837train
838tram
839travel
840tree
841trouble
842true
843trust
844twice
845try
846turn
847type
848ugly
849uncle
850understand
851unit
852use
853useful
854usual
855usually
856vegetable
857village
858voice
859visit
860wait
861wake
862walk
863want
864warm
865wash
866waste
867watch
868water
869way
870weak
871wear
872weather
873wedding
874week
875weight
876welcome
877well
878west
879wet
880wheel
881white
882wide
883wife
884wild
885will
886win
887wind
888window
889wine
890winter
891wire
892wise
893wish
894without
895woman
896wonder
897word
898work
899world
900worry
901yard
902yell
903yesterday
904yet
905young
906zero
907zoo