Coder Social home page Coder Social logo

salie's Introduction

SalIE - Salient Open Information Extraction

This repository hosts SalIE, the first framework addressing the extraction of salient open facts from arbitrary text.

Building

Requirements. For running SalIE out-of-the-box, your machine needs only to have Java and sbt preinstalled.

Setting-up. Download this repository recursively, apply the patch with:

git clone --recursive https://github.com/mponza/SalIE
cd SalIE
bash src/main/bash/patch.sh

Then download the precrafted embeddings from here in path/to/downloaded/zip and unzip the archive into data/embeddings with:

mkdir -p data/embeddings
unzip path/to/downloaded/zip -d data

Now you are ready to run SalIE.

Running. Given a data collection stored in path/to/input/data folder, where each element of the folder is a text file (i.e., .txt), you can extract its salient open facts with SalIE by typing:

src/main/bash/salient-extraction.sh path/to/input/data path/to/output/data minieMode

where minieMode can be agg, safe, dict or comp (for, respectively, aggressive, safe, dictionary and complete MinIE's mode) and path/to/output/data is the folder on which the salient open facts will be stored in the following JSON format:

{
    "docID":         string      document ID
    "text":          string      content of the document
    "openfacts":     list        list of salient open facts, sorted by descending salience score
                [
                    {
                        "text":         string      text of the open fact
                        "salience":     float       salience score   
                    }
                ]          
}

Using SalIE within your Code. An Example is provied in src/main/scala/de/mpg/mpi/runners/RunExample.scala. The code has been developed on the top of DkPro/UIMA frameworks, for more information, please check the documentation in their official websites.

Embeddings Wikipedia Open Facts via GloVe and Data Compression

We describe here the procedure used for generating the embedding vectors from the set of open facts extracted from the whole Wikipedia. If you have generated your own embeddings, you can easily adapt this procedure to plug them into SalIE.

Setting-up. After you have clone this repository with --recursive option you have to install and create a virtualenv environment in the venv directory:

virtualenv venv

and install the Python requirements:

source venv/bin/activate
pip install -r src/main/python/requirements.txt

Embeddings Generation & Compression. Given a file of open facts in JSON format (e.g., path/to/agg-wikipedia.json, section Dataset of Wikipedia Open Facts for the description of the format), the output embeddings file (e.g., path/to/agg-wikipedia.glove) can be generated from scratch with:

bash src/main/bash/facts2glove.sh path/to/agg-wikipedia.json path/to/agg-wikipedia.glove

In this example, the output filename will be path/to/agg-wikipedia.glove.bin. For setting up different GloVe parameters check src/main/bash/facts2glove.sh.

Evaluation

If you want to evaluate the performance of SalIE on a data collection, just set-up and run the following steps.

Setting-up. After the creation and activation of your virtualenv environment, you need to install the Python requirements:

pip install -r src/main/python/requirements.txt

Then, you have to configure pyrouge by creating the file ~/.pyrouge/settings.ini with the content:

[pyrouge settings]
home_dir = path/to/src/main/python/summarization/tools/ROUGE-1.5.5/

Evaluation. For evaluating a set of extracted salient facts with respect to documents' abstracts you need to run:

python src/main/python/summarization evaluate path/to/open/facts/dir path/to/abstracts path/to/scores.json

where path/to/open/facts/dir is the path to a directory of a set of documents, each one with the following JSON format:

{
   "docID":        string      id of the document
   "text":         string      content of the document
   "abstract":     string      abstract of the document

   "openfacts":    list        list of open facts

               [
                   {
                       "text":        string      text of the open fact
                       "salience":    float       salience score
                   }
               ]
}

and the path/to/abstracts is the path to a directory of a set of documents, each one containing the document's abstract. On the NYT dataset results are slightly different from the ones in the paper because minor changes for this release.

Known Error (and How to Fix). Running ROUGE can raise the "Cannot open exception db file for reading" exception. For fix it, just type:

bash src/main/fixROUGE.sh

and then re-run the evaluation script.

NYT Dataset. This dataset can be bought from LDC, while the document IDs used in our testbed can be downloaded here.

Dataset of Wikipedia Open Facts

You can download the datasets containing the set of open facts extracted from Wikipedia (dump of August 2017) with different MinIE's modes: aggressive, safe, dictionary and complete. Each file size is about 9GB (compressed) and each line is a Wikipedia page with the following JSON format:

{
    "wikiID":       string      id of the Wikipedia page
    "text":         string      raw text of the Wikipedia page
    
    "sentences":    list        list of sentences containing the extracted open facts
    
            [
                {
                    "text":     string      sentence text
                    "begin":    int         begin character offset of the sentence in the Wikipedia text
                    "end":      int         end character offset of the sentence in the Wikipedia text
                    
                    "openFacts":    list    list of open facts extracted from the sentence (warning: F of facts is uppercase here!)
                                [
                                    {
                                        "subject":
                                            {
                                                "text":     string      text of the subject
                                                "head":     string      head of the subject
                                                "begin":    int         begin character offset of the subject
                                                "end":      int         end character offset of the subject
                                            }
                                            
                                        "relation":     same object structure of subject
                                        "object":       same object structure of subject
                                    }
                                ]
                }
            ]
}

Citation and Further Reading

If you find any resource (code or data) of this repository useful, please cite our paper:

Marco Ponza, Luciano Del Corro, Gerhard Waikum
Facts That Matter
In Proceedings of the 2018 Conference of Empirical Methods in Natural Language Processing (EMNLP 2018)

In the following we list other relevant papers describing the tools we used in this work.

  • MinIE, the open information extraction tool default used by SalIE:

    Kiril Gashteovski, Rainer Gemulla and Luciano Del Corro
    MinIE: Minimizing Facts in Open Information Extraction
    In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing (EMNLP 2017)

  • Algorithms used for compressing word embeddings:

    Roi Blanco, Giuseppe Ottaviano and Edgar Meij
    Fast and Space-Efficient Entity Linking for Queries
    In Proceedings of the Eighth ACM International Conference on Web Search and Data Mining (WSDM 2015)

License

The code in this repository has been released under GNU General Public License v.3.0

salie's People

Contributors

cortinico avatar mponza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

salie's Issues

salient-extraction.sh Error

Wanted to ask about this issue as it is just producing errors and not working. It seems like some dependency issue but it is really hard to decode what is wrong with it. Would really appreciate your help. Open JDK 8 and scala 2.12.6 with sbt have been preinstalled. Output is below when I run the salient-extraction.sh file.

Running SalIE with input ../content/data2 and output ../output_data with mode miniemode...
[info] Loading project definition from /content/SalIE/project
[info] Set current project to SalIE (in build file:/content/SalIE/)
[success] Total time: 0 s, completed Aug 17, 2021 11:33:47 AM
[info] Updating {file:/content/SalIE/}salie...
....
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] 	* it.unimi.dsi:fastutil:(7.0.13, 8.1.0) -> 8.1.1
[warn] Run 'evicted' to see detailed eviction warnings
[info] Compiling 43 Scala sources and 74 Java sources to /content/SalIE/target/scala-2.12/classes...
[warn] there were 5 deprecation warnings; re-run with -deprecation for details
[warn] one warning found
[info] /content/SalIE/src/main/java/it/cnr/isti/hpc/Word2VecCompress.java: /content/SalIE/src/main/java/it/cnr/isti/hpc/Word2VecCompress.java uses or overrides a deprecated API.
[info] /content/SalIE/src/main/java/it/cnr/isti/hpc/Word2VecCompress.java: Recompile with -Xlint:deprecation for details.
[info] /content/SalIE/src/main/java/de/uni_mannheim/utils/minie/Utils.java: /content/SalIE/src/main/java/de/uni_mannheim/utils/minie/Utils.java uses unchecked or unsafe operations.
[info] /content/SalIE/src/main/java/de/uni_mannheim/utils/minie/Utils.java: Recompile with -Xlint:unchecked for details.
[success] Total time: 26 s, completed Aug 17, 2021 11:34:14 AM
[info] Loading project definition from /content/SalIE/project
[info] Set current project to SalIE (in build file:/content/SalIE/)
[info] Running de.mpg.mpi.runners.RunIOPipeline --inputdir ../content/data2 --inputformat txt --outputdir ../output_data --outputformat json --pipeline salie --batch 500 --miniemode miniemode --graphstructure clique --weighting embedding --weightingmodel data/embeddings/miniemode-wikipedia.glove.500.bin --rankingprior extractionOrder --alpha 0.1 --iterations 2
[error] Aug 17, 2021 11:34:21 AM org.apache.uima.internal.util.XMLUtils createSaxTransformerFactory(614)
[error] WARNING: SAXTransformerFactory didn't recognize setting attribute http://javax.xml.XMLConstants/property/accessExternalDTD
[error] Aug 17, 2021 11:34:21 AM org.apache.uima.internal.util.XMLUtils createSaxTransformerFactory(621)
[error] WARNING: SAXTransformerFactory didn't recognize setting attribute http://javax.xml.XMLConstants/property/accessExternalStylesheet
[error] Aug 17, 2021 11:34:22 AM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase scan(422)
[error] INFO: Scanning [file:/content/SalIE/../content/data2/]
[error] Aug 17, 2021 11:34:26 AM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase initialize(248)
[error] INFO: Found [92579] resources to be read
[error] Aug 17, 2021 11:34:28 AM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase nextFile(347)
[error] INFO: 0 of 92579: file:/content/SalIE/../content/data2/data1.txt
[error] Aug 17, 2021 11:34:28 AM de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase nextFile(347)
[error] INFO: 1 of 92579 (1%  ETA 53:18:34.194  RUN 00:00:02.73   AVG 2073  LAST 99): file:/content/SalIE/../content/data2/data10.txt\
[error] Aug 17, 2021 11:34:57 AM de.tudarmstadt.ukp.dkpro.core.api.resources.internal.ApacheCommonsLoggingAdapter info
[error] INFO: :: loading settings :: url = jar:file:/root/.ivy2/cache/org.apache.ivy/ivy/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[error] Aug 17, 2021 11:34:58 AM de.tudarmstadt.ukp.dkpro.core.api.resources.internal.ApacheCommonsLoggingAdapter info
[error] INFO: :: loading settings :: url = jar:file:/root/.ivy2/cache/org.apache.ivy/ivy/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[error] Aug 17, 2021 11:34:58 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase configure
[error] INFO: Producing resource from [jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-tagger-en-bidirectional-distsim/jars/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-tagger-en-bidirectional-distsim-20140616.jar!/de/tudarmstadt/ukp/dkpro/core/stanfordnlp/lib/tagger-en-bidirectional-distsim.tagger] redirected from [jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-model-tagger-en-bidirectional-distsim/jars/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-model-tagger-en-bidirectional-distsim-20140616.1.jar!/de/tudarmstadt/ukp/dkpro/core/stanfordnlp/lib/tagger-en-bidirectional-distsim.properties]
[error] Aug 17, 2021 11:34:59 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase loadResource
[error] INFO: Producing resource took 1033ms
[error] Aug 17, 2021 11:34:59 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase configure
[error] INFO: Producing resource from jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.lexmorph-asl/jars/de.tudarmstadt.ukp.dkpro.core.api.lexmorph-asl-1.9.3.jar!/de/tudarmstadt/ukp/dkpro/core/api/lexmorph/tagset/en-ptb-pos.map
[error] Aug 17, 2021 11:34:59 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase loadResource
[error] INFO: Producing resource took 0ms
[error] Aug 17, 2021 11:35:00 AM de.tudarmstadt.ukp.dkpro.core.api.resources.internal.ApacheCommonsLoggingAdapter info
[error] INFO: :: loading settings :: url = jar:file:/root/.ivy2/cache/org.apache.ivy/ivy/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
[error] Aug 17, 2021 11:35:00 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase configure
[error] INFO: Producing resource from [jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-parser-en-rnn/jars/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-parser-en-rnn-20140104.jar!/de/tudarmstadt/ukp/dkpro/core/stanfordnlp/lib/parser-en-rnn.ser.gz] redirected from [jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-model-parser-en-rnn/jars/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-model-parser-en-rnn-20140104.1.jar!/de/tudarmstadt/ukp/dkpro/core/stanfordnlp/lib/parser-en-rnn.properties]
[error] Aug 17, 2021 11:35:00 AM de.tudarmstadt.ukp.dkpro.core.stanfordnlp.StanfordParser$StanfordParserModelProvider produceResource(567)
[error] INFO: Loading parser from serialized file jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-parser-en-rnn/jars/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-upstream-parser-en-rnn-20140104.jar!/de/tudarmstadt/ukp/dkpro/core/stanfordnlp/lib/parser-en-rnn.ser.gz ...
[error] Aug 17, 2021 11:35:02 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase loadResource
[error] INFO: Producing resource took 2244ms
[error] Aug 17, 2021 11:35:02 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase configure
[error] INFO: Producing resource from jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.lexmorph-asl/jars/de.tudarmstadt.ukp.dkpro.core.api.lexmorph-asl-1.9.3.jar!/de/tudarmstadt/ukp/dkpro/core/api/lexmorph/tagset/en-ptb-pos.map
[error] Aug 17, 2021 11:35:02 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase loadResource
[error] INFO: Producing resource took 1ms
[error] Aug 17, 2021 11:35:02 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase configure
[error] INFO: Producing resource from jar:file:/root/.ivy2/cache/de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.api.syntax-asl/jars/de.tudarmstadt.ukp.dkpro.core.api.syntax-asl-1.9.3.jar!/de/tudarmstadt/ukp/dkpro/core/api/syntax/tagset/en-ptb-constituency.map
[error] Aug 17, 2021 11:35:02 AM de.tudarmstadt.ukp.dkpro.core.api.resources.ResourceObjectProviderBase loadResource
[error] INFO: Producing resource took 0ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.