Code Monkey home page Code Monkey logo

trec-engine's Introduction

TREC Search Engine

Project Structure

trec-engine
|-- README.md
|-- build.gradle
|-- dat // various data (see dependencies), not version-controlled
|-- eval // evaluation results, not version-controlled
|-- gradle
|-- gradlew
|-- gradlew.bat
|-- scripts // misc scripts
|-- settings.gradle
`-- src // java source files

Usage

usage: java -jar trec.jar
 -d,--docmap <arg>         build document map. default: ./dat/file.txt
 -e,--expansion <arg>      query expansion method for VSM mode: 0 for
                           none, 1 for weighted, 2 for pseudo relevance
                           feedback, 3 for local association analysis, 4
                           for local correlation analysis. default: 0
 -h,--help                 print this message
 -i,--index <arg>          build index for the given postings file.
                           default: ./dat/post.txt
 -k,--top-k <arg>          top k documents to retrieve. default: 1000
 -m,--mode <arg>           query mode: 0 for VSM, 1 for Proximity.
                           default: 0
 -o,--output <arg>         output file path. default: output.txt
 -p,--stopwords <arg>      stopwords file path. default:
                           ./dat/stopwords.txt
 -r,--retrieve <arg>       retrieve documents for the given query file.
                           default: ./dat/queryT.txt
 -t,--threads <arg>        number of threads to use. default: 10
 -x,--max-distance <arg>   maximum distance between two terms in a phrase
                           query. default: 10

Build

./gradlew build -x test

# Output in ./build/libs/trec.jar

The program can also be run without an explicit build step using the Gradle wrapper:

./gradlew run --args="..."

Data and Dependencies

Name Version Description
Java 8 Java SDK
Gradle 7.4 Build Tool
./dat/post.txt NA Postings File
./dat/file.txt NA Document Metadata
./dat/queryT.txt NA Query File (short)
./dat/queryTDN.txt NA Query File (long)
./dat/stopwords.txt NA Stopwords List
./eval/trec_eval NA Evaluation Tool
./eval/judgerobust NA Benchmarking File

Since the current indexing procesure is slow, a pre-built index is made available here. Refer to this post to understand how to use this file.

Examples

The following commands are run in the project root directory. You should also have a Redis server running and set up the proper environment variables.

export REDIS_HOST=localhost
export REDIS_PORT=6379

# Build inverted file index
./gradlew run --args="-i ./dat/post.txt -t 50"

# Build document map
./gradlew run --args="-d ./dat/file.txt"

# VSM Query
./gradlew run --args="-r ./dat/queryT.txt -o ./eval/T_VSM.ret -p ./dat/stopwords.txt -k 1000 -m 0 -e 0 -t 20"
./gradlew run --args="-r ./dat/queryTDN.txt -o ./eval/TDN_VSM.ret -p ./dat/stopwords.txt -k 1000 -m 0 -e 0 -t 20"

# Weighted VSM Query
./gradlew run --args="-r ./dat/queryTDN.txt -o ./eval/TDN_W.ret -p ./dat/stopwords.txt -k 1000 -m 0 -e 1 -t 20"

# Proximity Query
./gradlew run --args="-r ./dat/queryT.txt -o ./eval/T_P.ret -p ./dat/stopwords.txt -k 1000 -m 1 -e 1 -x 15 -t 20"

Evaluation

The TREC evaluation tool is available at https://github.com/usnistgov/trec_eval. You should install it to the ./eval folder.

# Generate evaluation results for all queries
for file in ./eval/*.ret; do
    ./eval/trec_eval ./eval/judgerobust $file > "${file%.ret}".eval
done

# Generate diagrams for the evaluation results
python3 ./scripts/plot.py -i `ls -1 ./eval/*.eval | tr '\n' ','` -o ./eval/PR.png,./eval/P.png

trec-engine's People

Contributors

mcxd avatar therobert0728 avatar

Watchers

 avatar

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.