* improve search history by using common word sequence of query and search result name

* ignore aka titles in OpenSubtitles search
This commit is contained in:
Reinhard Pointner 2009-02-22 14:32:52 +00:00
parent b7f0529d88
commit 4346a6e05b
5 changed files with 33 additions and 12 deletions

View File

@ -231,9 +231,6 @@ public class SeriesNameMatcher {
if (i == 0 && len == seq1.length) if (i == 0 && len == seq1.length)
return seq1; return seq1;
if (j == 0 && len == seq2.length)
return seq2;
return Arrays.copyOfRange(seq1, i, i + len); return Arrays.copyOfRange(seq1, i, i + len);
} }
} }

View File

@ -27,6 +27,7 @@ import javax.swing.SwingWorker;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
import net.sourceforge.filebot.web.SearchResult; import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ui.LabelProvider; import net.sourceforge.tuned.ui.LabelProvider;
@ -157,13 +158,13 @@ public abstract class AbstractSearchPanel<S, E> extends FileBotPanel {
return; return;
} }
String title = requestProcessor.getTitle(); String historyEntry = requestProcessor.getHistoryEntry();
if (!searchHistory.contains(title)) { if (historyEntry != null && !searchHistory.contains(historyEntry)) {
searchHistory.add(title); searchHistory.add(historyEntry);
} }
tab.setTitle(title); tab.setTitle(requestProcessor.getTitle());
// fetch elements of the selected search result // fetch elements of the selected search result
new FetchTask(requestProcessor).execute(); new FetchTask(requestProcessor).execute();
@ -308,6 +309,15 @@ public abstract class AbstractSearchPanel<S, E> extends FileBotPanel {
} }
public String getHistoryEntry() {
SeriesNameMatcher nameMatcher = new SeriesNameMatcher();
// the common word sequence of query and search result
// common name will maintain the exact word characters (incl. case) of the first argument
return nameMatcher.matchByFirstCommonWordSequence(searchResult.getName(), request.getSearchText());
}
public Icon getIcon() { public Icon getIcon() {
return null; return null;
} }

View File

@ -17,6 +17,7 @@ import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
@ -40,8 +41,11 @@ public class SelectDialog<T> extends JDialog {
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// initialize list and select first element // initialize list
list = new JList(new ArrayListModel(options)); list = new JList(new ArrayListModel(options));
// select first element
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setSelectedIndex(0); list.setSelectedIndex(0);
list.setCellRenderer(new SelectListCellRenderer()); list.setCellRenderer(new SelectListCellRenderer());

View File

@ -11,6 +11,8 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import javax.swing.Icon;
import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.EventList;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
@ -162,9 +164,8 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleClient, SubtitleP
@Override @Override
public String getTitle() { public Icon getIcon() {
// add additional information to default title return request.client.getIcon();
return String.format("%s [%s]", super.getTitle(), request.getLanguage().getDisplayName(Locale.ENGLISH));
} }

View File

@ -183,7 +183,16 @@ public class OpenSubtitlesClient {
ArrayList<MovieDescriptor> movies = new ArrayList<MovieDescriptor>(); ArrayList<MovieDescriptor> movies = new ArrayList<MovieDescriptor>();
for (Map<String, String> movie : response.get("data")) { for (Map<String, String> movie : response.get("data")) {
movies.add(new MovieDescriptor(movie.get("title"), new Integer(movie.get("id")))); String title = movie.get("title");
// get end index of first non-aka title (aka titles are separated by Â)
int endIndex = title.indexOf('\u00C2');
if (endIndex > 0) {
title = title.substring(0, endIndex);
}
movies.add(new MovieDescriptor(title, new Integer(movie.get("id"))));
} }
return movies; return movies;