cuulee / setrank Goto Github PK
View Code? Open in Web Editor NEWThis project forked from obartunov/setrank
tf*idf ranking
This project forked from obartunov/setrank
tf*idf ranking
float4 ts_rank_tfidf(text STATTABLE [, float4[] weights] tsvector, tsquery [, int flags]) STATTABLE: Name of table stored set-wide statistic. Table should be defined as CREATE TABLE table_name ( value text UNIQUE, ndoc int4 (or bigint) NOT NULL CHECK (ndoc>0) ); And row with null value means total number of documents. See an examples in sql/setrank.sql file example: Create STATTABLE: Table "public.apod" Column | Type | Collation | Nullable | Default ----------+----------+-----------+----------+--------- title | text | | | body | text | | | sdate | date | | | keywords | text | | | id | integer | | | fts | tsvector | | | Indexes: select word, ndoc into apod_stat from ts_stat('select fts from apod') order by ndoc desc; insert into apod_stat values(NULL, 1754); -- 'star' is very common word select title, ts_rank_tfidf('apod_stat', fts, to_tsquery('x-ray:a | star:a')) as rank from apod where fts @@ to_tsquery('x-ray:a| star:a') order by rank desc limit 10; title | rank ---------------------------------------------+---------- X-ray Moon and X-ray Star | 0.218907 X-Ray Pulsar | 0.1818 The X-Ray Sky | 0.178291 X-Ray Pleiades | 0.177293 X-Ray Pleiades | 0.177293 X-Ray Pleiades | 0.177293 XMM-Newton First Light: X-Rays From The LMC | 0.176329 The X-ray Timing Explorer | 0.175857 X-Rays From The Galactic Center | 0.175857 X-Ray Jet From Centaurus A | 0.175523 (10 rows) select title, ts_rank_cd(fts, to_tsquery('x-ray:a | star:a')) as rank from apod where fts @@ to_tsquery('x-ray:a| star:a') order by rank desc limit 10; title | rank ----------------------------+--------- X-ray Moon and X-ray Star | 3.66667 X-Ray Stars Of Orion | 2 The Pleiades Star Cluster | 1 X-Ray Jet From Centaurus A | 1 Star Wars in NGC 664 | 1 The Pleiades Star Cluster | 1 Stars in the Infrared Sky | 1 The X-Ray Moon | 1 The Pleiades Star Cluster | 1 The Crab Nebula in X-Rays | 1 (10 rows)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.