|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package org.openpsa.contacts |
|
4
|
|
|
* @author CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
|
5
|
|
|
* @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/ |
|
6
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Search for duplicate persons and groups in database |
|
11
|
|
|
* |
|
12
|
|
|
* @package org.openpsa.contacts |
|
13
|
|
|
*/ |
|
14
|
|
|
class org_openpsa_contacts_duplicates_check_group extends org_openpsa_contacts_duplicates_check |
|
15
|
|
|
{ |
|
16
|
|
|
protected function get_class() : string |
|
17
|
|
|
{ |
|
18
|
|
|
return org_openpsa_contacts_group_dba::class; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
protected function get_fields() : array |
|
22
|
|
|
{ |
|
23
|
|
|
return ['official', 'street', 'phone', 'homepage', 'city', 'id']; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Calculates P for the given two persons being duplicates |
|
28
|
|
|
* |
|
29
|
|
|
* @return array with overall P and matched checks |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function p_duplicate(array $group1, array $group2) : array |
|
32
|
|
|
{ |
|
33
|
|
|
$ret = [ |
|
34
|
|
|
'p' => 0, |
|
35
|
|
|
'homepage_match' => false, |
|
36
|
|
|
'phone_match' => false, |
|
37
|
|
|
'phone_street_match' => false, |
|
38
|
|
|
'official_match' => false, |
|
39
|
|
|
'official_city_match' => false, |
|
40
|
|
|
'official_street_match' => false |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
//TODO: read weight values from configuration |
|
44
|
|
|
if ($this->match('homepage', $group1, $group2)) { |
|
45
|
|
|
$ret['homepage_match'] = true; |
|
46
|
|
|
$ret['p'] += 0.2; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if ($this->match('phone', $group1, $group2)) { |
|
50
|
|
|
$ret['phone_match'] = true; |
|
51
|
|
|
$ret['p'] += 0.5; |
|
52
|
|
|
if ($this->match('street', $group1, $group2)) { |
|
53
|
|
|
$ret['phone_street_match'] = true; |
|
54
|
|
|
$ret['p'] += 1; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if ($this->match('official', $group1, $group2)) { |
|
59
|
|
|
$ret['official_match'] = true; |
|
60
|
|
|
$ret['p'] += 0.2; |
|
61
|
|
|
if ($this->match('street', $group1, $group2)) { |
|
62
|
|
|
$ret['official_street_match'] = true; |
|
63
|
|
|
$ret['p'] += 1; |
|
64
|
|
|
} |
|
65
|
|
|
if ($this->match('city', $group1, $group2)) { |
|
66
|
|
|
$ret['city_street_match'] = true; |
|
67
|
|
|
$ret['p'] += 0.5; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $ret; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|