Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file renamed src/dataflow/numpy/.DS_Store → .DS_Store
Binary file not shown.
Empty file modified .idea/dictionaries/lynn.xml
100644 → 100755
Empty file.
Empty file modified .idea/m2e2-multimedia-event-extraction.iml
100644 → 100755
Empty file.
Empty file modified .idea/misc.xml
100644 → 100755
Empty file.
Empty file modified .idea/modules.xml
100644 → 100755
Empty file.
Empty file modified .idea/vcs.xml
100644 → 100755
Empty file.
Empty file modified .idea/workspace.xml
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ pip install -r requirements.txt
We download situation recognition data from [imSitu](http://imsitu.org/). Please find the preprocessed data in [PreprcessedSR](https://drive.google.com/drive/folders/1h0qwYWeGEoCx8m-zwH-XcoPSyffmrC-c?usp=sharing).

### ACE (Text Event Extraction Data)
We preprcoessed ACE following [JMEE](https://github.com/lx865712528/EMNLP2018-JMEE/tree/master). The preprocessing script is in `dataflow/preprocess_ace_JMEE.py`, and the sample data format is in [sample.json](https://github.com/lx865712528/EMNLP2018-JMEE/blob/master/ace-05-splits/sample.json). Due to license reason, the ACE 2005 dataset is only accessible to those with LDC2006T06 license, please drop me an email showing your possession of the license for the processed data.
We preprcoessed ACE following [JMEE](https://github.com/lx865712528/EMNLP2018-JMEE/tree/master). The sample data format is in [sample.json](https://github.com/lx865712528/EMNLP2018-JMEE/blob/master/ace-05-splits/sample.json). Due to license reason, the ACE 2005 dataset is only accessible to those with LDC2006T06 license, please drop me an email `manling2@illinois.edu` showing your possession of the license for the processed data.

### Voice of America Image-Caption Pairs
We crawled VOA image-captions to train the common space, the [image-caption pairs](https://uofi.box.com/s/xtn9p6m8z5qtjbbi5tqrl45tn6apew4x) and images can be downloaded using the URLs (We share image URLs instead of downloaded images due to license issue). We preprocess the data including object detection, and parse text sentences. The preprocessed data is in [PreprocessedVOA](https://drive.google.com/drive/folders/1I9vMGIhWZpKqxQYip91eLoDRnrkqRxnt?usp=sharing).
We crawled VOA image-captions to train the common space, the [image-caption pairs](https://uofi.box.com/s/xtn9p6m8z5qtjbbi5tqrl45tn6apew4x) and images can be downloaded using the URLs (We share image URLs instead of downloaded images due to license issue) using script in [dataset_image_download.py](https://github.com/limanling/m2e2/blob/master/src/dataflow/numpy/dataset_image_download.py). We preprocess the data including object detection, and parse text sentences. The preprocessed data is in [PreprocessedVOA](https://drive.google.com/drive/folders/1I9vMGIhWZpKqxQYip91eLoDRnrkqRxnt?usp=sharing).

### M2E2 (Multimedia Event Extraction Benchmark)

Expand Down
Empty file modified data/ace/ace_sr_mapping.txt
100644 → 100755
Empty file.
Empty file modified data/object/class-descriptions-boxable.csv
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ujson==1.35
seqeval==0.0.12
six==1.12.0
jieba==0.39
nltk==3.4.5
nltk==3.6.5
scipy==1.3.0
torchvision==0.3.0
Pillow==8.1.1
Expand Down
Empty file modified scripts/.gitkeep
100644 → 100755
Empty file.
Empty file modified scripts/eval/.gitkeep
100644 → 100755
Empty file.
Empty file modified scripts/train/.gitkeep
100644 → 100755
Empty file.
Binary file added src/.DS_Store
Binary file not shown.
Empty file modified src/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/__init__.py
100644 → 100755
Empty file.
Binary file added src/dataflow/.DS_Store
Binary file not shown.
Empty file modified src/dataflow/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/dataflow/__init__.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/numpy/__init__.py
100644 → 100755
Empty file.
103 changes: 103 additions & 0 deletions src/dataflow/numpy/anno_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
from collections import defaultdict

def event_type_norm(type_str):
return type_str.replace('.', '||').replace(':', '||').replace('-', '|').upper()


def role_name_norm(type_str):
return type_str.upper()

entity_type_mapping_brat = {
'PER': 'PER',
'ORG': 'ORG',
'GPE': 'GPE',
'LOC': 'LOC',
'FAC': 'FAC',
'VEH': 'VEH',
'WEA': 'WEA',
# 'TIM': 'TIME',
# 'NUM': 'VALUE',
# 'TIT',
'MON': 'VALUE',
# 'URL',
# 'RES',
# 'BALLOT'
}

event_type_mapping_brat2ace = {
'Die': 'Life:Die',
# 'Injure': 'Life:Injure',
'TransferMoney': 'Transaction:Transfer-Money',
'Attack': 'Conflict:Attack',
'Demonstrate': 'Conflict:Demonstrate',
'Correspondence': 'Contact:Phone-Write',
'Meet': 'Contact:Meet',
'ArrestJail': 'Justice:Arrest-Jail',
# 'ReleaseParole': 'Justice:Release-Parole',
'TransportPerson': 'Movement:Transport',
'TransportArtifact': 'Movement:Transport',
}

event_type_mapping_ace2brat = {event_type_norm(v): k for k, v in event_type_mapping_brat2ace.items()}
# print(event_type_mapping_ace2brat)

event_type_mapping_aida2brat = {
'Life.Die': 'Die',
'Life.Injure': 'Injure',
'Transaction.TransferMoney': 'TransferMoney',
'Conflict.Attack': 'Attack',
'Conflict.Demonstrate': 'Demonstrate',
'Contact.Correspondence': 'Correspondence',
'Contact.Meet': 'Meet',
'Justice.ArrestJail': 'ArrestJail',
'Justice.ReleaseParole': 'ReleaseParole',
'Movement.TransportPerson': 'TransportPerson',
'Movement.TransportArtifact': 'TransportArtifact',
}

event_role_mapping_brat2ace = { # delete time-related ones when testing
'Die': {'Victim': 'Victim', 'Agent': 'Agent', 'Instrument': 'Instrument', 'Place': 'Place'}, #, 'Time': 'Time'},
# 'Injure': {'Victim': 'Victim', 'Agent': 'Agent', 'Instrument': 'Instrument', 'Place': 'Place'}, #, 'Time': 'Time'},
'TransferMoney': {'Giver': 'Giver', 'Recipient': 'Recipient', 'Beneficiary': 'Beneficiary', 'Money': 'Money', 'Place': 'Place'}, #, 'Time': 'Time'},
'Attack': {'Attacker': 'Attacker', 'Instrument': 'Instrument', 'Place': 'Place', 'Target': 'Target'}, #, 'Time': 'Time'},
'Demonstrate': {'Demonstrator': 'Entity', 'Place': 'Place'}, #, 'Time': 'Time'},
'Correspondence': {'Participant': 'Entity', 'Place': 'Place'}, #, 'Time': 'Time'},
'Meet': {'Participant': 'Entity', 'Place': 'Place'}, #, 'Time': 'Time'},
'ArrestJail': {'Agent': 'Agent', 'Person': 'Person', 'Place': 'Place'}, #, 'Time': 'Time'},
# 'ReleaseParole': {'Agent': 'Entity', 'Person': 'Person', 'Place': 'Place'}, #, 'Time': 'Time'},
'TransportPerson': {'Agent': 'Agent', 'Person': 'Artifact', 'Instrument': 'Vehicle', 'Destination': 'Destination', 'Origin': 'Origin'}, #, 'Time': 'Time'},
'TransportArtifact': {'Agent': 'Agent', 'Artifact': 'Artifact', 'Instrument': 'Vehicle', 'Destination': 'Destination', 'Origin': 'Origin'}, #, 'Time': 'Time'},
}

# event_role_mapping_ace2brat = {role_name_norm(v): k for t in event_role_mapping_brat2ace.items() for k, v in event_role_mapping_brat2ace[t]}
event_role_mapping_ace2brat = defaultdict(lambda : defaultdict())
for t in event_role_mapping_brat2ace:
for k, v in event_role_mapping_brat2ace[t].items():
event_type_ace = event_type_norm(event_type_mapping_brat2ace[t])
event_role_mapping_ace2brat[event_type_ace][role_name_norm(v)] = k
# print(event_role_mapping_ace2brat)

event_type_mapping_image2ace = {
'Movement.TransportPerson': 'Movement:Transport',
'Movement.TransportArtifact': 'Movement:Transport',
'Life.Die': 'Life:Die',
'Conflict.Attack': 'Conflict:Attack',
'Conflict.Demonstrate': 'Conflict:Demonstrate',
'Contact.Phone-Write': 'Contact:Phone-Write',
'Contact.Meet': 'Contact:Meet',
'Transaction.TransferMoney': 'Transaction:Transfer-Money',
'Justice.ArrestJail': 'Justice:Arrest-Jail',
}

event_role_mapping_image2ace = {
'Life.Die': {'victim': 'Victim', 'agent': 'Agent', 'instrument': 'Instrument', 'place': 'Place'}, #, 'Time': 'Time'},
'Transaction.TransferMoney': {'instrument': 'Instrument', 'giver': 'Giver', 'recipient': 'Recipient', 'beneficiary': 'Beneficiary', 'money': 'Money', 'place': 'Place'}, #, 'Time': 'Time'},
'Conflict.Attack': {'attacker': 'Attacker', 'instrument': 'Instrument', 'place': 'Place', 'target': 'Target', 'victim': 'Target'}, #, 'Time': 'Time'},
'Conflict.Demonstrate': {'police':'Police', 'instrument': 'Instrument', 'demonstrator': 'Entity', 'place': 'Place', 'participant': 'Entity'}, #, 'Time': 'Time'},
'Contact.Phone-Write': {'instrument':'Instrument', 'participant': 'Entity', 'place': 'Place'}, #, 'Time': 'Time'},
'Contact.Meet': {'participant': 'Entity', 'place': 'Place'}, #, 'Time': 'Time'},
'Justice.ArrestJail': {'instrument': 'Instrument', 'agent': 'Agent', 'person': 'Person', 'place': 'Place'}, #, 'Time': 'Time'},
'Movement.TransportPerson': {'agent': 'Agent', 'person': 'Artifact', 'instrument': 'Instrument', 'destination': 'Destination', 'origin': 'Origin'}, #, 'Time': 'Time'},
'Movement.TransportArtifact': {'person': 'Artifact', 'agent': 'Agent', 'artifact': 'Artifact', 'instrument': 'Instrument', 'destination': 'Destination', 'origin': 'Origin'}, #, 'Time': 'Time'},
}
# 'TransportArtifact' has 'person' in image annotation
Empty file modified src/dataflow/numpy/data_loader_ace_role.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/numpy/data_loader_grounding.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/numpy/data_loader_situation.py
100644 → 100755
Empty file.
7 changes: 4 additions & 3 deletions src/dataflow/numpy/dataset_image_download.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def download_image_list(meta_json, dir_save):
for doc_id in metadata:
for img_id in metadata[doc_id]:
url_image = metadata[doc_id][img_id]['url']
image_path_save = os.path.join(dir_save, '%s_%s.jpg' % (doc_id, img_id))
if not url_image.endswith('.jpg'):
print(image_path_save, url_image)
suffix_image = metadata[doc_id][img_id]['url'].split('.')[-1]
image_path_save = os.path.join(dir_save, '%s_%s.%s' % (doc_id, img_id, suffix_image))
# if not url_image.endswith('.jpg'):
# print(image_path_save, url_image)
download_image(url_image, image_path_save)


Expand Down
Empty file modified src/dataflow/numpy/prepare_vocab.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/torch/Corpus.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/torch/Data.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/torch/Sentence.py
100644 → 100755
Empty file.
Empty file modified src/dataflow/torch/__init__.py
100644 → 100755
Empty file.
Empty file modified src/engine/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/engine/EErunner.py
100644 → 100755
Empty file.
Empty file modified src/engine/EEtraining.py
100644 → 100755
Empty file.
Empty file modified src/engine/Groundingrunner.py
100644 → 100755
Empty file.
Empty file modified src/engine/Groundingtraining.py
100644 → 100755
Empty file.
Empty file modified src/engine/JOINTRunner.py
100644 → 100755
Empty file.
Empty file modified src/engine/JOINTTraining_sample.py
100644 → 100755
Empty file.
Empty file modified src/engine/SRrunner.py
100644 → 100755
Empty file.
Empty file modified src/engine/SRtraining.py
100644 → 100755
Empty file.
Empty file modified src/engine/TestRunnerEE.py
100644 → 100755
Empty file.
Empty file modified src/engine/TestRunnerEE_m2e2.py
100644 → 100755
Empty file.
Empty file modified src/engine/TestRunnerJOINT.py
100644 → 100755
Empty file.
Empty file modified src/engine/TestRunnerSR.py
100644 → 100755
Empty file.
Empty file modified src/engine/TestRunnerSR_m2e2.py
100644 → 100755
Empty file.
Empty file modified src/engine/__init__.py
100644 → 100755
Empty file.
Empty file modified src/eval/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/eval/EEtesting.py
100644 → 100755
Empty file.
Empty file modified src/eval/EEvisualizing.py
100644 → 100755
Empty file.
Empty file modified src/eval/Groundingtesting.py
100644 → 100755
Empty file.
Empty file modified src/eval/JOINTtesting.py
100644 → 100755
Empty file.
Empty file modified src/eval/SRtesting.py
100644 → 100755
Empty file.
Empty file modified src/eval/__init__.py
100644 → 100755
Empty file.
Empty file modified src/models/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/models/__init__.py
100644 → 100755
Empty file.
Empty file modified src/models/ace_classifier.py
100644 → 100755
Empty file.
Empty file modified src/models/ee.py
100644 → 100755
Empty file.
Empty file modified src/models/grounding.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/models/modules/DynamicLSTM.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/EmbeddingLayer.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/EmbeddingLayerImage.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/FMapLayerImage.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/GCN.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/HighWay.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/SelfAttention.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/__init__.py
100644 → 100755
Empty file.
Empty file modified src/models/modules/model.py
100644 → 100755
Empty file.
Empty file modified src/models/sr.py
100644 → 100755
Empty file.
Empty file modified src/models/sr_object.py
100644 → 100755
Empty file.
Empty file modified src/util/.gitkeep
100644 → 100755
Empty file.
Empty file modified src/util/__init__.py
100644 → 100755
Empty file.
Empty file modified src/util/constant.py
100644 → 100755
Empty file.
Empty file modified src/util/consts.py
100644 → 100755
Empty file.
Empty file modified src/util/helper.py
100644 → 100755
Empty file.
Empty file modified src/util/util_img.py
100644 → 100755
Empty file.
Empty file modified src/util/util_model.py
100644 → 100755
Empty file.
Empty file modified src/util/vocab.py
100644 → 100755
Empty file.
Empty file modified training-testing.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.