-
Notifications
You must be signed in to change notification settings - Fork 0
/
lattice.php
89 lines (78 loc) · 1.99 KB
/
lattice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE HTML>
<meta charset="utf-8">
<title>Lattice — FCA search engine</title>
<style type="text/css">
body {
width: 1000px;
margin: auto;
}
.intent {
border: 1px dashed gray;
padding: 5px;
margin-right: 10px;
line-height: 50px;
}
hr {
clear: both;
}
.searchconcept {
color: red;
border: 1px dashed red;
font-weight: bold;
}
.left {
text-align: left;
font-size: 80%;
}
.unused {
color: gray;
}
</style>
<div style="text-align:center;">
<?php
define('ROOT', dirname(__FILE__) . '/');
if ($_GET['hash'] && $_GET['database']) {
$hash = $_GET['hash'];
$database = $_GET['database'];
$path = ROOT . 'cache/' . $database . '/' . $hash . '.txt';
if (file_exists($path)) {
$data = file_get_contents($path);
$json = json_decode($data);
$lattice = $json->lattice;
$siblings = $lattice->siblings;
$lensibl = count($siblings);
$half = intval($lensibl / 2);
$left = array_slice($siblings, 0, $half);
$right = array_slice($siblings, $half);
echo "<div class='left'>Upper neighbors:</div>";
printIntentLine($lattice->upper, 'Upper neighbor');
echo "<hr>";
echo "<div class='left'>Siblings:</div>";
echo "<table><tr><td>";
printIntentLine($left, 'Sibling');
echo "</td><td width='200'>";
echo "<span class='intent searchconcept' title='Search concept'>" . implode(", ", $lattice->conceptintent) . "</span>";
echo "</td><td>";
printIntentLine($right, 'Sibling');
echo "</td></tr></table><hr>";
echo "<div class='left'>Lower neighbors:</div>";
printIntentLine($lattice->lower, 'Lower neighbor');
echo "<hr>";
echo "<div class='left'>Unused concepts:</div>";
echo "<div class='unused'>";
printIntentLine($lattice->trash, 'Unused concept');
echo "</div>";
} else {
echo $path;
}
}
function printIntentLine($intents, $title) {
foreach ($intents as $intent) {
echo intent2string($intent, $title);
}
}
function intent2string($concept, $title) {
return "<span class='intent' title='$title'>" . implode(", ", $concept) . "</span class='intent'> ";
}
?>
</div>