blob: 1e7df4b376ee62026f6c2f24965fbe8889306302 [file] [log] [blame]
alexander.behmc576c602012-07-06 02:41:15 +00001/*
2 * Description : Fuzzy joins two datasets, DBLP and CSX, based on the similarity-jaccard function of their titles' 3-gram tokens.
3 * DBLP has a 3-gram index on title, and we expect the join to be transformed into an indexed nested-loop join.
alexander.behm954083a2012-11-15 04:01:23 +00004 * We expect the top-level equi join introduced because of surrogate optimization to be removed, since it is not necessary.
alexander.behmc576c602012-07-06 02:41:15 +00005 * Success : Yes
6 */
7
8drop dataverse test if exists;
9create dataverse test;
10use dataverse test;
ramangrover29a3211202013-05-19 11:56:49 -070011set import-private-functions 'true';
alexander.behmc576c602012-07-06 02:41:15 +000012
13create type DBLPType as closed {
14 id: int32,
15 dblpid: string,
16 title: string,
17 authors: string,
18 misc: string
19}
20
21create type CSXType as closed {
22 id: int32,
23 csxid: string,
24 title: string,
25 authors: string,
26 misc: string
27}
28
ramangrover29669d8f62013-02-11 06:03:32 +000029create dataset DBLP(DBLPType) primary key id;
alexander.behmc576c602012-07-06 02:41:15 +000030
ramangrover29669d8f62013-02-11 06:03:32 +000031create dataset CSX(CSXType) primary key id;
alexander.behmc576c602012-07-06 02:41:15 +000032
alexander.behmc576c602012-07-06 02:41:15 +000033create index ngram_index on DBLP(title) type ngram(3);
34
alexander.behm954083a2012-11-15 04:01:23 +000035write output to nc1:"rttest/inverted-index-join-noeqjoin_ngram-jaccard.adm";
alexander.behmc576c602012-07-06 02:41:15 +000036
37for $a in dataset('DBLP')
38for $b in dataset('CSX')
alexander.behm954083a2012-11-15 04:01:23 +000039where similarity-jaccard(gram-tokens($a.title, 3, false), gram-tokens($b.title, 3, false)) >= 0.5f
alexander.behmc576c602012-07-06 02:41:15 +000040 and $a.id < $b.id
ramangrover29a3211202013-05-19 11:56:49 -070041return {"atitle": $a.title, "btitle": $b.title}