Skip to content

Commit 94bbbef

Browse files
redesign. refactoring. tuned serach engine
1 parent 6c30c02 commit 94bbbef

File tree

4 files changed

+53
-36
lines changed

4 files changed

+53
-36
lines changed

Client/ContentsViewer/ContentsViewerStandard.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ ul.tag-list.removable li a:hover::before{
391391
margin: 0px;
392392
padding: 2em 0 0 0;
393393
}
394+
394395
#main-footer {
395396
font-size: 13px;
396397
}
398+
397399
#center-column {
398400
margin-left: 27%;
399401
margin-right: 17%;
@@ -408,6 +410,12 @@ ul.tag-list.removable li a:hover::before{
408410
background-color: white;
409411
flex-grow: 1;
410412
overflow: auto;
413+
display: flex;
414+
flex-direction: column;
415+
}
416+
417+
#main article{
418+
flex-grow: 1;
411419
}
412420

413421
.overlay-enabled #center-column {

Frontend/viewer.php

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -215,34 +215,6 @@
215215
<?php endforeach; ?>
216216
</ul>
217217
</div>
218-
219-
<div class="left-right-content-link-container clear-fix">
220-
<?php if (isset($vars['leftContent'])): ?>
221-
<a class="left-content-link" href="<?=$vars['leftContent']['url']?>">
222-
<svg viewBox="0 0 48 48">
223-
<path d="M30.83 32.67l-9.17-9.17 9.17-9.17L28 11.5l-12 12 12 12z"></path>
224-
</svg>
225-
<?=mb_strimwidth($vars['leftContent']['title'], 0, 40, "...")?>
226-
</a>
227-
<?php endif;?>
228-
<?php if (isset($vars['rightContent'])): ?>
229-
<a class="right-content-link" href="<?=$vars['rightContent']['url']?>">
230-
<?=mb_strimwidth($vars['rightContent']['title'], 0, 40, "...")?>
231-
<svg viewBox="0 0 48 48">
232-
<path d="M17.17 32.92l9.17-9.17-9.17-9.17L20 11.75l12 12-12 12z"></path>
233-
</svg>
234-
</a>
235-
<?php endif;?>
236-
</div>
237-
238-
<div id='main-footer-responsive'>
239-
<?php if (isset($vars['addPlainTextLink']) && $vars['addPlainTextLink']): ?>
240-
<a href="?plainText"><?=Localization\Localize('viewTheSourceCodeOfThisPage', 'View the Source Code of this page')?></a>
241-
<?php endif;?>
242-
</div>
243-
<div id='main-footer'>
244-
<div style='float: right'><?=$breadcrumbList?><span><?=$vars['pageHeading']['title']?></span></div>
245-
</div>
246218
<div id='printfooter'>
247219
<?php if (isset($vars['canonialUrl'])):?>
248220
<?=Localization\Localize('retrievedFrom', 'Retrieved from "{0}"', $vars['canonialUrl'])?>
@@ -251,6 +223,33 @@
251223
<?php endif;?>
252224
</div>
253225
</article>
226+
<div class="left-right-content-link-container clear-fix">
227+
<?php if (isset($vars['leftContent'])): ?>
228+
<a class="left-content-link" href="<?=$vars['leftContent']['url']?>">
229+
<svg viewBox="0 0 48 48">
230+
<path d="M30.83 32.67l-9.17-9.17 9.17-9.17L28 11.5l-12 12 12 12z"></path>
231+
</svg>
232+
<?=mb_strimwidth($vars['leftContent']['title'], 0, 40, "...")?>
233+
</a>
234+
<?php endif;?>
235+
<?php if (isset($vars['rightContent'])): ?>
236+
<a class="right-content-link" href="<?=$vars['rightContent']['url']?>">
237+
<?=mb_strimwidth($vars['rightContent']['title'], 0, 40, "...")?>
238+
<svg viewBox="0 0 48 48">
239+
<path d="M17.17 32.92l9.17-9.17-9.17-9.17L20 11.75l12 12-12 12z"></path>
240+
</svg>
241+
</a>
242+
<?php endif;?>
243+
</div>
244+
245+
<div id='main-footer-responsive'>
246+
<?php if (isset($vars['addPlainTextLink']) && $vars['addPlainTextLink']): ?>
247+
<a href="?plainText"><?=Localization\Localize('viewTheSourceCodeOfThisPage', 'View the Source Code of this page')?></a>
248+
<?php endif;?>
249+
</div>
250+
<div id='main-footer'>
251+
<div style='float: right'><?=$breadcrumbList?><span><?=$vars['pageHeading']['title']?></span></div>
252+
</div>
254253
</main>
255254
<?php if (isset($vars['pageBottomHTML'])):?>
256255
<div id='page-bottom'><?=$vars['pageBottomHTML']?></div>

Module/SearchEngine.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,32 @@ public static function Search($query){
9797
* ]
9898
*/
9999
$hitInfo = [];
100-
101-
if(mb_strlen($term) <= 1){
102-
$term = ' ' . $term . ' ';
103-
}
100+
// Note:
101+
// 2020-6-6:
102+
// 下のように, 一文字のみ前後に空白を入れて, 一文字ヒットして多くの検索候補が出るのを防げた.
103+
// だが, 一文字より多い場合でも, 多くの検索候補が出ている
104+
// if(mb_strlen($term) <= 1){
105+
// $term = ' ' . $term . ' ';
106+
// }
107+
108+
// Note:
109+
// 2020-6-6:
110+
// 下のように, 前に空白を入れて単語として認識できるようにする.
111+
// 前後に入れると, 部分文字列がヒットしずらくなった.
112+
// ただし部分文字列がどうなるか?
113+
$term = ' ' . $term;
104114
$sequence = Utils::Bigram($term);
105115
$gramCount = count($sequence);
106116
for($j = 0; $j < $gramCount; $j++){
107117
$gram = $sequence[$j];
108118

109119
if(array_key_exists($gram, Index::$data['index2id'])){
110-
120+
111121
foreach(Index::$data['index2id'][$gram] as $id => $offsetInfo){
112122
if(array_key_exists($id, $hitInfo)){
113123
$pos = \BinarySearch::FindInsertPosition($offsetInfo, $hitInfo[$id]['offset'], 1, $offsetInfo[0]);
114124
// \Debug::Log($gram);
125+
// \Debug::Log($id);
115126
// \Debug::Log($pos);
116127
// \Debug::Log($offsetInfo);
117128
if($pos <= $offsetInfo[0] && $hitInfo[$id]['offset'] < $offsetInfo[$pos]){
@@ -139,7 +150,6 @@ public static function Search($query){
139150
}
140151
}
141152
}
142-
143153
}
144154

145155
// var_dump($hitInfo);
@@ -154,6 +164,7 @@ public static function Search($query){
154164
foreach($scoreMap as $id => $score){
155165
$suggestions[] = ['id' => $id, 'score' => $score];
156166
}
167+
// \Debug::Log($suggestions);
157168
return $suggestions;
158169
}
159170
}

Service/related-search-service.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@
107107
if(!$titleTagFullMatch){
108108
$titleSuggestions = SelectSuggestions(
109109
SearchEngine\Searcher::Search($titleQuery),
110-
$exclusionPathMap,
111-
0.8
110+
$exclusionPathMap
112111
);
113112
$titleSuggestions = SelectAnotherDirectory($titleSuggestions, dirname($currentContent->path));
114113
}

0 commit comments

Comments
 (0)