タイニー番組ナビゲータ本体
Revisión | 8896a72318f58dfde565169d579f0edd30a84375 (tree) |
---|---|
Tiempo | 2013-12-17 10:06:32 |
Autor | peeweedee <peeweedee@user...> |
Commiter | peeweedee |
番組追跡の処理の効率化ほか
@@ -333,7 +333,7 @@ public class Viewer extends JFrame { | ||
333 | 333 | if ( r.getRecorderIPAddr().equals("") ) { |
334 | 334 | continue; |
335 | 335 | } |
336 | - if ( r.getRecorderId().contains("RD-") || r.getRecorderId().contains("DBR-Z") ) { | |
336 | + if ( ! r.getRecorderId().contains("RD-") && ! r.getRecorderId().contains("DBR-Z") ) { | |
337 | 337 | continue; |
338 | 338 | } |
339 | 339 |
@@ -395,6 +395,11 @@ public abstract class AbsSettingView extends JScrollPane { | ||
395 | 395 | CommonSwingUtils.putComponentOn(jPanel_setting, getNoticeMsg(" 閾値を大きくすると判定が厳しくなります。キーワードが短いためにヒットしまくりで検索ノイズが多くなった場合に、値を大きくしてみてください。"), DESCRIPTION_WIDTH, PARTS_HEIGHT, SEP_WIDTH*2, y); |
396 | 396 | |
397 | 397 | y+=(PARTS_HEIGHT+SEP_HEIGHT); |
398 | + CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_traceOnlyTitle = new JCheckBoxPanel("タイトル中に含まれるサブタイトルは番組追跡の対象にしない",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); | |
399 | + jCBP_traceOnlyTitle.setSelected(env.getTraceOnlyTitle()); | |
400 | + jCBP_traceOnlyTitle.addItemListener(IL_RELOAD_PROG_NEEDED); | |
401 | + | |
402 | + y+=(PARTS_HEIGHT+SEP_HEIGHT); | |
398 | 403 | CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_syoboFilterByCenters = new JCheckBoxPanel("しょぼかるの検索結果も有効な放送局のみに絞る",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); |
399 | 404 | jCBP_syoboFilterByCenters.setSelected(env.getSyoboFilterByCenters()); |
400 | 405 | // RELOADリスナー不要 |
@@ -739,24 +744,11 @@ public abstract class AbsSettingView extends JScrollPane { | ||
739 | 744 | jCBP_autoEventIdComplete.setSelected(env.getAutoEventIdComplete()); |
740 | 745 | // RELOADリスナー不要 |
741 | 746 | |
742 | - { | |
743 | - y+=(PARTS_HEIGHT+SEP_HEIGHT); | |
744 | - CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_splitEpno = new JCheckBoxPanel("タイトルに話数が含まれる場合に以降を分離する",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); | |
745 | - jCBP_splitEpno.setSelected( ! env.getSplitEpno()); | |
746 | - jCBP_splitEpno.addItemListener(IL_RELOAD_PROG_NEEDED); | |
747 | - | |
748 | - y+=(PARTS_HEIGHT+SEP_HEIGHT); | |
749 | - CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_traceOnlyTitle = new JCheckBoxPanel("┗ サブタイトルを番組追跡の対象から除外する",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); | |
750 | - jCBP_traceOnlyTitle.setSelected(env.getTraceOnlyTitle()); | |
751 | - jCBP_traceOnlyTitle.addItemListener(IL_RELOAD_PROG_NEEDED); | |
747 | + y+=(PARTS_HEIGHT+SEP_HEIGHT); | |
748 | + CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_splitEpno = new JCheckBoxPanel("タイトルに話数が含まれる場合に以降を分離する",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); | |
749 | + jCBP_splitEpno.setSelected( ! env.getSplitEpno()); | |
750 | + jCBP_splitEpno.addItemListener(IL_RELOAD_PROG_NEEDED); | |
752 | 751 | |
753 | - // 連動設定 | |
754 | - | |
755 | - jCBP_splitEpno.addItemListener(al_splitepno); | |
756 | - | |
757 | - jCBP_splitEpno.setSelected( ! jCBP_splitEpno.isSelected()); | |
758 | - } | |
759 | - | |
760 | 752 | y+=(PARTS_HEIGHT+SEP_HEIGHT); |
761 | 753 | CommonSwingUtils.putComponentOn(jPanel_setting, jCBP_fixTitle = new JCheckBoxPanel("タイトル先頭の「アニメ 」を削除(NHKのみ)",LABEL_WIDTH), PARTS_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y); |
762 | 754 | jCBP_fixTitle.setSelected(env.getFixTitle()); |
@@ -160,13 +160,14 @@ public class MarkedProgramList { | ||
160 | 160 | } |
161 | 161 | else { |
162 | 162 | //あいまい検索・正引き |
163 | - fazScore = TraceProgram.sumScore(tvd.SearchStrKeys,tKey._getTitlePop()); | |
163 | + String target = ProgDetailList.tracenOnlyTitle ? tvd.splitted_titlePop : tvd.titlePop; | |
164 | + fazScore = TraceProgram.sumScore(target, tKey._getTitlePop()); | |
164 | 165 | if (fazScore >= tKey.getFazzyThreshold()) { |
165 | 166 | isFind = true; |
166 | 167 | } |
167 | 168 | else if ( ! this.disableFazzySearchReverse) { |
168 | 169 | // 逆引き |
169 | - fazScore = TraceProgram.sumScore(tKey._getSearchStrKeys(),tvd.titlePop); | |
170 | + fazScore = TraceProgram.sumScore(tKey._getTitlePop(), target); | |
170 | 171 | if (fazScore >= tKey.getFazzyThreshold()) { |
171 | 172 | isFind = true; |
172 | 173 | } |
@@ -354,7 +354,6 @@ public class PassedProgram extends TVProgramUtils implements TVProgram,Cloneable | ||
354 | 354 | // 検索用インデックスを生成 |
355 | 355 | data.titlePop = TraceProgram.replacePop(data.title); |
356 | 356 | data.detailPop = TraceProgram.replacePop(data.detail); |
357 | - data.SearchStrKeys = TraceProgram.splitKeys(data.titlePop); | |
358 | 357 | |
359 | 358 | // 終了時刻・実日付を生成 |
360 | 359 | String[] Ahm = data.start.split(":",2); |
@@ -91,7 +91,7 @@ public class ProgDetailList implements Cloneable { | ||
91 | 91 | // 検索高速化用のデータ |
92 | 92 | |
93 | 93 | /** |
94 | - * キーワード検索で使うよ | |
94 | + * キーワード検索・番組追跡で使うよ | |
95 | 95 | */ |
96 | 96 | String titlePop = ""; |
97 | 97 |
@@ -103,7 +103,7 @@ public class ProgDetailList implements Cloneable { | ||
103 | 103 | /** |
104 | 104 | * 番組追跡で使うよ |
105 | 105 | */ |
106 | - ArrayList<String> SearchStrKeys = null; | |
106 | + static boolean tracenOnlyTitle = false; | |
107 | 107 | |
108 | 108 | /******************************************************************************* |
109 | 109 | * NGワード処理 |
@@ -135,7 +135,6 @@ public class ProgDetailList implements Cloneable { | ||
135 | 135 | |
136 | 136 | titlePop = ""; |
137 | 137 | detailPop = ""; |
138 | - SearchStrKeys = new ArrayList<String>(); | |
139 | 138 | } |
140 | 139 | |
141 | 140 | /******************************************************************************* |
@@ -535,7 +534,6 @@ public class ProgDetailList implements Cloneable { | ||
535 | 534 | case TITLE: |
536 | 535 | this.title = body; |
537 | 536 | this.titlePop = TraceProgram.replacePop(this.title); |
538 | - this.SearchStrKeys = TraceProgram.splitKeys(this.titlePop); | |
539 | 537 | break; |
540 | 538 | case DETAIL: |
541 | 539 | this.detail = body; |
@@ -368,7 +368,6 @@ public class Syobocal extends TVProgramUtils implements TVProgram,Cloneable { | ||
368 | 368 | |
369 | 369 | // 詳細を登録する |
370 | 370 | pDetail.titlePop = TraceProgram.replacePop(pDetail.title); |
371 | - pDetail.SearchStrKeys = TraceProgram.splitKeys(pDetail.titlePop); | |
372 | 371 | pDetail.detailPop = TraceProgram.replacePop(pDetail.detail); |
373 | 372 | pDetail.length = Integer.valueOf(CommonUtils.getRecMin(pDetail.start.substring(0,2),pDetail.start.substring(3,5),pDetail.end.substring(0,2),pDetail.end.substring(3,5))); |
374 | 373 | } |
@@ -509,7 +509,8 @@ public class TVProgramUtils implements Cloneable { | ||
509 | 509 | pdl.titlePop = TraceProgram.replacePop(key_title); |
510 | 510 | pdl.detailPop = TraceProgram.replacePop(key_detail); |
511 | 511 | |
512 | - pdl.SearchStrKeys = TraceProgram.splitKeys(pdl.titlePop); | |
512 | + // 分離しない場合でも、番組追跡はサブタイトル抜きでの検索ができるようにしたい | |
513 | + pdl.splitted_titlePop = TraceProgram.replacePop(pdl.splitted_title); | |
513 | 514 | } |
514 | 515 | |
515 | 516 | /** |
@@ -850,7 +851,6 @@ public class TVProgramUtils implements Cloneable { | ||
850 | 851 | pd2.link = pd1.link; |
851 | 852 | pd2.titlePop = pd1.titlePop; |
852 | 853 | pd2.detailPop = pd1.detailPop; |
853 | - pd2.SearchStrKeys = pd1.SearchStrKeys; | |
854 | 854 | pd2.nosyobo = pd1.nosyobo; |
855 | 855 | pd2.extension = pd1.extension; |
856 | 856 | pd2.flag = pd1.flag; |
@@ -13,7 +13,6 @@ public class TraceKey implements SearchItem { | ||
13 | 13 | private String center = null; |
14 | 14 | private int fazzyThreshold = 0; |
15 | 15 | private String okiniiri = null; |
16 | - private ArrayList<String> SearchStrKeys = null; | |
17 | 16 | private boolean disableRepeat = false; |
18 | 17 | private boolean showLatestOnly = false; |
19 | 18 |
@@ -37,8 +36,6 @@ public class TraceKey implements SearchItem { | ||
37 | 36 | public String _getLabel() { return label; } |
38 | 37 | public void setTitlePop(String s) { titlePop = s; } |
39 | 38 | public String _getTitlePop() { return titlePop; } |
40 | - public void setSearchStrKeys(ArrayList<String> sa) { SearchStrKeys = sa; } | |
41 | - public ArrayList<String> _getSearchStrKeys() { return SearchStrKeys; } | |
42 | 39 | |
43 | 40 | // interface |
44 | 41 |
@@ -49,8 +49,6 @@ public class TraceProgram { | ||
49 | 49 | |
50 | 50 | tr.setTitlePop(replacePop(tr.getTitle())); |
51 | 51 | |
52 | - tr.setSearchStrKeys(splitKeys(tr._getTitlePop())); | |
53 | - | |
54 | 52 | tr.setLabel(getNewLabel(tr.getTitle(), tr.getCenter())); |
55 | 53 | } |
56 | 54 | } |
@@ -104,55 +102,44 @@ public class TraceProgram { | ||
104 | 102 | return(sb.toString()); |
105 | 103 | } |
106 | 104 | |
107 | - // あいまい検索用キー文字列群の生成 | |
108 | - public static ArrayList<String> splitKeys(String s) | |
109 | - { | |
110 | - ArrayList<String> SearchStrKeys = new ArrayList<String>(); | |
111 | - | |
112 | - int countStr=s.length(); | |
113 | - if (countStr == 1) { | |
114 | - SearchStrKeys.add(s); | |
115 | - } | |
116 | - else { | |
117 | - for (int i=1; i<countStr; i++) { | |
118 | - SearchStrKeys.add(s.substring(i-1, i+1)); | |
119 | - } | |
120 | - } | |
121 | - | |
122 | - return(SearchStrKeys); | |
123 | - } | |
124 | - | |
125 | - // 2つの文字を比較してスコアを計算する(special thanks to ◆kzz0PzTAMM) | |
126 | - public static int sumScore(String SearchStr1, String SearchStr2) | |
127 | - { | |
128 | - // 検索ワードが空なら検索終了 | |
129 | - if (SearchStr1.equals("") || SearchStr2.equals("")) { | |
130 | - return 0; | |
131 | - } | |
132 | - | |
133 | - // 検索ワードを基準に検索する | |
134 | - return sumScore(splitKeys(SearchStr1), SearchStr2); | |
135 | - } | |
136 | - public static int sumScore(ArrayList<String> SearchStr1Keys, String SearchStr2) | |
105 | + // 最少比較単位は2文字(バイグラム) | |
106 | + private static final int COMPCHARLEN = 2; | |
107 | + | |
108 | + /** | |
109 | + * 2つの文字を比較してスコアを計算する(special thanks to ◆kzz0PzTAMM) | |
110 | + * @param searchkey 番組追跡の検索キー | |
111 | + * @param target タイトル(中の文字がsearchkeyに何個含まれているかを確認する) | |
112 | + * @return | |
113 | + */ | |
114 | + public static int sumScore(String searchkey, String target) | |
137 | 115 | { |
138 | 116 | |
139 | 117 | // 検索ワードが空なら検索終了 |
140 | - if (SearchStr1Keys.size() == 0 || "".equals(SearchStr2)) { | |
118 | + if (searchkey == null || target == null || "".equals(searchkey) || "".equals(target)) { | |
141 | 119 | return 0; |
142 | 120 | } |
143 | 121 | |
144 | - // 検索ワードを基準に検索する | |
145 | - int searchCount=0; | |
146 | - int score=0; | |
147 | - for (String key : SearchStr1Keys) { | |
148 | - if (SearchStr2.indexOf(key) >= 0) { | |
149 | - score++; | |
150 | - } | |
151 | - searchCount++; | |
152 | - } | |
153 | - | |
154 | - score=Math.round(score*100/searchCount); | |
155 | - return(score); | |
122 | + int searchCountMax = searchkey.length(); | |
123 | + if ( searchCountMax > COMPCHARLEN ) { | |
124 | + // 検索キーが最少比較単位より長い | |
125 | + searchCountMax = searchCountMax - COMPCHARLEN + 1; | |
126 | + int score = 0; | |
127 | + int searchCount = 0; | |
128 | + for ( ; searchCount < searchCountMax; searchCount++ ) { | |
129 | + if ( target.indexOf(searchkey.substring(searchCount,searchCount+COMPCHARLEN)) != -1 ) { | |
130 | + score++; | |
131 | + } | |
132 | + } | |
133 | + return Math.round(score * 100 / searchCount); | |
134 | + } | |
135 | + else { | |
136 | + if ( target.indexOf(searchkey) != -1 ) { | |
137 | + System.err.println("xxxx "+target+", "+searchkey); | |
138 | + return 100; | |
139 | + } | |
140 | + } | |
141 | + | |
142 | + return 0; | |
156 | 143 | } |
157 | 144 | |
158 | 145 |
@@ -318,7 +318,6 @@ public class VWTraceKeyDialog extends JEscCancelDialog { | ||
318 | 318 | xKey.setCenter(jTextField_channel.getText()); |
319 | 319 | xKey.setTitle(jTextField_title.getText().trim()); |
320 | 320 | xKey.setTitlePop(TraceProgram.replacePop(xKey.getTitle())); |
321 | - xKey.setSearchStrKeys(TraceProgram.splitKeys(xKey._getTitlePop())); | |
322 | 321 | xKey.setFazzyThreshold(jSlider_fazzyThreshold.getValue()); |
323 | 322 | xKey.setOkiniiri((String) jComboBox_okiniiri.getSelectedItem()); |
324 | 323 | xKey.setDisableRepeat(jCheckBox_disableRepeat.isSelected()); |
@@ -3393,6 +3393,8 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H | ||
3393 | 3393 | |
3394 | 3394 | // 番組タイトルを整形する |
3395 | 3395 | private void fixTitle() { |
3396 | + // 番組追跡からサブタイトルを除外するかどうかのフラグ | |
3397 | + ProgDetailList.tracenOnlyTitle = env.getFixTitle() && env.getTraceOnlyTitle(); | |
3396 | 3398 | // |
3397 | 3399 | if ( ! env.getFixTitle()) { |
3398 | 3400 | return; |
@@ -3417,7 +3419,6 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H | ||
3417 | 3419 | // NHK系で先頭が「アニメ 」ではじまるものから「アニメ 」を削除する |
3418 | 3420 | tvd.title = tvd.title.replaceFirst("^アニメ[ ・]+",""); |
3419 | 3421 | tvd.titlePop = TraceProgram.replacePop(tvd.title); |
3420 | - tvd.SearchStrKeys = TraceProgram.splitKeys(tvd.titlePop); | |
3421 | 3422 | } |
3422 | 3423 | if ( tvd.title.contains("コメンタリ") || tvd.detail.contains("コメンタリ") ) { |
3423 | 3424 | // "コメンタリ"の記述のあるものは「副音声」扱いにする(副音声でなくても) |
@@ -3443,11 +3444,6 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H | ||
3443 | 3444 | // ジャンル=映画でサブジャンルが複数ありアニメが優先されてないものはアニメを優先する |
3444 | 3445 | tvd.subgenre = ProgSubgenre.MOVIE_ANIME; |
3445 | 3446 | } |
3446 | - | |
3447 | - // サブタイトルを番組追跡の対象から外す | |
3448 | - if ( env.getTraceOnlyTitle() && tvd.title != tvd.splitted_title ) { | |
3449 | - tvd.SearchStrKeys = TraceProgram.splitKeys(TraceProgram.replacePop(tvd.splitted_title)); // 番組追跡の検索用インデックスは、サブタイトルを削除したもので置き換える | |
3450 | - } | |
3451 | 3447 | } |
3452 | 3448 | } |
3453 | 3449 | } |