Ian Maxon | 857dc13 | 2015-09-25 17:13:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 19 | use dataverse fuzzy1; |
| 20 | |
| 21 | declare type DBLPType as open { |
| 22 | id: int32, |
| 23 | dblpid: string, |
| 24 | title: string, |
| 25 | authors: string, |
| 26 | misc: string |
| 27 | } |
| 28 | |
| 29 | declare type CSXType as open { |
| 30 | id: int32, |
| 31 | csxid: string, |
| 32 | title: string, |
| 33 | authors: string, |
| 34 | misc: string |
| 35 | } |
| 36 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame] | 37 | declare nodegroup group1 on asterix_nc1, asterix_nc2; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 38 | |
| 39 | declare dataset DBLP(DBLPType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 40 | primary key id on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 41 | |
| 42 | declare dataset CSX(CSXType) |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 43 | primary key id on group1; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 44 | |
Ian Maxon | f7b6453 | 2015-12-09 17:28:18 -0800 | [diff] [blame] | 45 | write output to asterix_nc1:'/tmp/pub.adm'; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 46 | |
| 47 | // |
| 48 | // -- - Stage 3 - -- |
| 49 | // |
| 50 | for $ridpair in |
| 51 | // |
| 52 | // -- - Stage 2 - -- |
| 53 | // |
| 54 | for $paperR in dataset('DBLP') |
| 55 | let $lenR := len(counthashed-word-tokens($paperR.title)) |
| 56 | let $tokensR := |
| 57 | for $word in counthashed-word-tokens($paperR.title) |
| 58 | for $token at $i in |
| 59 | // |
| 60 | // -- - Stage 1 - -- |
| 61 | // |
| 62 | for $paper in dataset('DBLP') |
| 63 | for $word in counthashed-word-tokens($paper.title) |
| 64 | group by $item := $word with $paper |
| 65 | order by count($paper) |
| 66 | return $item |
| 67 | where $word = $token |
| 68 | order by $i |
| 69 | return $i |
| 70 | for $prefix_tokenR in subset-collection( |
| 71 | $tokensR, |
| 72 | 0, |
| 73 | prefix-len($lenR, 'Jaccard', .5)) |
| 74 | |
| 75 | for $paperS in dataset('CSX') |
| 76 | let $lenS := len(counthashed-word-tokens($paperS.title)) |
| 77 | let $tokensS := |
| 78 | for $word in counthashed-word-tokens($paperS.title) |
| 79 | for $token at $i in |
| 80 | // |
| 81 | // -- - Stage 1 - -- |
| 82 | // |
| 83 | for $paper in dataset('DBLP') |
| 84 | for $word in counthashed-word-tokens($paper.title) |
| 85 | group by $item := $word with $paper |
| 86 | order by count($paper) |
| 87 | return $item |
| 88 | where $word = $token |
| 89 | order by $i |
| 90 | return $i |
| 91 | for $prefix_tokenS in subset-collection( |
| 92 | $tokensS, |
| 93 | 0, |
| 94 | prefix-len($lenS, 'Jaccard', .5)) |
| 95 | |
| 96 | where $prefix_tokenR = $prefix_tokenS |
| 97 | |
| 98 | let $sim := similarity( |
| 99 | $lenR, |
| 100 | $tokensR, |
| 101 | $lenS, |
| 102 | $tokensS, |
| 103 | $prefix_tokenR, |
| 104 | 'Jaccard', |
| 105 | .5) |
| 106 | where $sim >= .5 |
| 107 | group by $idR := $paperR.id, $idS := $paperS.id with $sim |
| 108 | return {'idR': $idR, 'idS': $idS, 'sim': $sim[0]} |
| 109 | |
| 110 | for $paperR in dataset('DBLP') |
| 111 | for $paperS in dataset('CSX') |
| 112 | where $ridpair.idR = $paperR.id and $ridpair.idS = $paperS.id |
| 113 | return { 'R': { 'dblpid': $paperR.dblpid, 'title': $paperR.title }, |
| 114 | 'S': { 'csxid': $paperS.csxid, 'title': $paperS.title }, |
| 115 | 'sim': $ridpair.sim } |