Code Monkey home page Code Monkey logo

bm25's Introduction

BM25

demo

資訊檢索(Information Retrieval)中 Okapi BM25 (BM代表最佳匹配)扮演著一種排名的方法,通常使用於搜索引擎,根據給定的搜索句子再找出排名匹配文檔最有關係之文檔。順帶一提 BM25 它所計算的方式,主要還是詞頻關係與分析並未考慮到句子架構語法故可以把它(文檔)想像成雜亂無序的 Bag 去進行排序。

簡單摘要(Brief Review Of BM25)

  • 資訊檢索(Information Retrieval)
  • 詞頻關係與分析並未考慮到句子架構語法
  • 計算文件與文件之間的相關性排名(Ranking Function)

使用方式

Input:

1.執行 BM25Test.java 並輸入以下類似之句子(EX:如何設定手機上網?)
2.可到/src/main/resources/TestFile.txt中的資料集尋找句子修改做測試。
註: 可在 TestFile.txt 修改成自己的 database 每個 document(文檔) 請用跳行分開

Output:

Data中最接近的句子:手機上網如何設定?
分數為:7.600866591869731

開發環境

Maven Project
IDEA Version:IntelliJ IDEA 2017.1.2 x64
JDK: java version "1.8.0_121"

補充

註:由於此為 demo project 故沒有,有效利用 BM25 該有之特性,它應適用於較長文件進行比對較為適合。
註:如果'文件個數'剛好是某個詞彙'出現在的文件個數'兩倍,就會導致 idf 分數為 0,如果超過可推得為負數
註:此程式斷詞 POS 部分,主要是使用'中研院 CKIP'的斷詞系統

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.