diff --git a/mangaki/mangaki/management/commands/add_anidb.py b/mangaki/mangaki/management/commands/add_anidb.py new file mode 100644 index 000000000..b9c393002 --- /dev/null +++ b/mangaki/mangaki/management/commands/add_anidb.py @@ -0,0 +1,21 @@ +from django.core.management.base import BaseCommand +from mangaki.utils.anidb import AniDB +from mangaki.models import Work, Category +from urllib.parse import urlparse + +def create_anime(**kwargs): + anime = Category.objects.get(slug='anime') + return Work.objects.update_or_create(category=anime, anidb_aid=kwargs['anidb_aid'], defaults=kwargs)[0] + +class Command(BaseCommand): + args = '' + help = 'Retrieve AniDB data' + + def add_arguments(self, parser): + parser.add_argument('id', type=int) + + def handle(self, *args, **options): + anidb = AniDB('mangakihttp', 1) + anime = create_anime(**anidb.get(options.get('id'))) + anime.retrieve_poster() # Save for future use + self.stdout.write(self.style.SUCCESS('Successfully added %s' % anime)) diff --git a/mangaki/mangaki/models.py b/mangaki/mangaki/models.py index e07e95acc..18abf3fc2 100644 --- a/mangaki/mangaki/models.py +++ b/mangaki/mangaki/models.py @@ -141,6 +141,7 @@ def retrieve_poster(self, url=None, session=None): return False filename = os.path.basename(urlparse(url).path) + # Hé mais ça va pas écraser des posters / créer des collisions, ça ? try: r = session.get(url, timeout=5, stream=True) diff --git a/mangaki/mangaki/tests/test_anidb.py b/mangaki/mangaki/tests/test_anidb.py new file mode 100644 index 000000000..17d1c0dfb --- /dev/null +++ b/mangaki/mangaki/tests/test_anidb.py @@ -0,0 +1,27 @@ +from django.test import TestCase +from mangaki.models import Work, Category, Editor, Studio +from mangaki.utils.anidb import AniDB + + +class AniDBTest(TestCase): + + def create_anime(self, **kwargs): + anime = Category.objects.get(slug='anime') + return Work.objects.create(category=anime, **kwargs) + + def setUp(self): + # FIXME: The defaults for editor and studio in Work requires those to + # exist, or else foreign key constraints fail. + Editor.objects.create(pk=1) + Studio.objects.create(pk=1) + self.anidb = AniDB('mangakihttp', 1) + + """ + def test_anidb_search(self): + results = self.anidb.search(q='sangatsu no lion') + self.assertNotEqual(len(results), 0) + + def test_anidb_get(self): + anime = self.create_anime(**self.anidb.get(11606)) + self.assertNotEqual(anime.title, '') + """ \ No newline at end of file diff --git a/mangaki/mangaki/utils/anidb.py b/mangaki/mangaki/utils/anidb.py index 488fc2cbd..19eef6b47 100644 --- a/mangaki/mangaki/utils/anidb.py +++ b/mangaki/mangaki/utils/anidb.py @@ -1,17 +1,20 @@ import requests from bs4 import BeautifulSoup - from datetime import datetime +from urllib.parse import urljoin + BASE_URL = "http://api.anidb.net:9001/httpapi" SEARCH_URL = "http://anisearch.outrance.pl/" PROTOCOL_VERSION = 1 -try: - str = unicode -except: - pass - # str = str +def to_python_datetime(mal_date): + """ + Converts myAnimeList's XML date YYYY-MM-DD to Python datetime format. + >>> to_python_datetime('2015-07-14') + datetime.datetime(2015, 7, 14, 0, 0) + """ + return datetime(*list(map(int, mal_date.split("-")))) class AniDB: def __init__(self, client_id, client_ver=0): @@ -45,98 +48,47 @@ def search(self, q): results = [] animetitles = BeautifulSoup(r.text, 'xml').animetitles for anime in animetitles.find_all('anime'): - results.append(Anime({ - 'id': int(anime['aid']), - 'title': str(anime.find('title', attrs={'type': "official"}).string), - 'picture': "http://img7.anidb.net/pics/anime/" + str(anime.find('picture').string), - }, partial=True, updater=lambda: self.get(anime.id))) - + results.append( + (int(anime['aid']), + str(anime.find('title', attrs={'type': "official"}).string)) + ) return results - def get(self, id): + def get(self, anidb_aid): """ Allows retrieval of non-file or episode related information for a specific anime by AID (AniDB anime id). http://wiki.anidb.net/w/HTTP_API_Definition#Anime """ - id = int(id) # why? + anidb_aid = int(anidb_aid) - r = self._request("anime", {'aid': id}) + r = self._request("anime", {'aid': anidb_aid}) soup = BeautifulSoup(r.text.encode('utf-8'), 'xml') # http://stackoverflow.com/questions/31126831/beautifulsoup-with-xml-fails-to-parse-full-unicode-strings#comment50430922_31146912 - """with open('backup.xml', 'w') as f: - f.write(r.text)""" if soup.error is not None: raise Exception(soup.error.string) anime = soup.anime - titles = anime.titles - - a = Anime({ - 'id': id, - 'type': str(anime.type.string), - 'episodecount': int(anime.episodecount.string), - 'startdate': datetime(*list(map(int, anime.startdate.string.split("-")))), - 'enddate': datetime(*list(map(int, anime.enddate.string.split("-")))), - 'titles': [( - str(title.string), - title['type'] if 'type' in title else "unknown" - ) for title in anime.find_all('title')], - 'title': str(titles.find('title', attrs={'type': "main"}).string), - 'relatedanime': [], - 'url': str(anime.url.string) if anime.url else None, - 'creators': anime.creators, - 'description': str(anime.description.string), - 'ratings': SmartDict({ - 'permanent': float(anime.ratings.permanent.string), - 'temporary': float(anime.ratings.temporary.string), - 'review': float(anime.ratings.review.string) if anime.ratings.review else '' - }), - 'picture': "http://img7.anidb.net/pics/anime/" + str(anime.picture.string), - 'categories': [], - 'tags': [], - 'characters': [], - 'episodes': [], - }) - - self._cache[id] = a - - return a - -class SmartDict(dict): - def __init__(self, *a, **kw): - super(SmartDict, self).__init__(**kw) - for x in a: - try: - self.update(x) - except TypeError: - self.update(x.__dict__) - self.__dict__ = self - -class Anime: - def __init__(self, data={}, partial=False, **kw): - self._data = data - self._partial = partial - if partial: - self._updater = kw['updater'] - - def _update(self): - if not self._partial: - raise Exception("Attempted to update a ready object") - else: - self._data = self._updater()._data - self._partial = False - - def __getattr__(self, name): - if name in self._data: - return self._data[name] - else: - if self._partial: - self._update() - if name in self._data: - return self._data[name] - else: - raise AttributeError("no attribute called '%s'" % name) - else: - raise AttributeError("no attribute called '%s'" % name) - - def __repr__(self): - return u'' % (self.id, self.title) + all_titles = anime.titles + # creators = anime.creators # TODO + # episodes = anime.episodes + # tags = anime.tags + # characters = anime.characters + # ratings = anime.ratings.{permanent, temporary} + + anime_dict = { + 'title': str(all_titles.find('title', attrs={'type': "main"}).string), + 'source': 'AniDB: ' + str(anime.url.string) if anime.url else None, + 'ext_poster': urljoin('http://img7.anidb.net/pics/anime/', str(anime.picture.string)), + # 'nsfw': ? + 'date': to_python_datetime(anime.startdate.string), + # not yet in model: 'enddate': to_python_datetime(anime.enddate.string), + 'synopsis': str(anime.description.string), + # 'artists': ? from anime.creators + 'nb_episodes': int(anime.episodecount.string), + 'anime_type': str(anime.type.string), + 'anidb_aid': anidb_aid + } + return anime_dict + +if __name__ == "__main__": + import doctest + doctest.testmod() diff --git a/notebooks/Visualizations.ipynb b/notebooks/Visualizations.ipynb index 1074f5b6e..c86c587c8 100644 --- a/notebooks/Visualizations.ipynb +++ b/notebooks/Visualizations.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "collapsed": false }, @@ -22,24 +22,34 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Computing M: (668 × 10325)\n", + "fill and center matrix [494 ms]\n", + "Shapes (668, 20) (20, 10325)\n", + "factor matrix [11038 ms]\n" + ] + }, { "data": { "text/plain": [ - "0.83654836310611103" + "0.29997468538119143" ] }, - "execution_count": 3, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "svd = MangakiPCA(20)\n", + "svd = MangakiALS(20)\n", "X = ratings[:,0:2].astype(int)\n", "# Y = [rating_values[rating] for rating in ratings[:,2]] # Mangaki\n", "Y = [rating for rating in ratings[:,2]] # Movielens\n", @@ -58,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": { "collapsed": false }, @@ -67,10 +77,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "[ 3.63700734 3.62649663 3.6433236 3.63719043 3.64155642 3.62671834\n", - " 3.61853431 3.62725301 3.63015759 3.62725581 3.63283668 3.62177879\n", - " 3.6399311 3.62598001 3.62647401 3.64981411 3.63318533 3.62729403\n", - " 3.62705417 3.61526324]\n", + "[ 4.15166522 2.44094455 3.85189977 4.2123204 4.36926123 4.07850853\n", + " 3.51195664 3.70937669 3.54927138 1.96362594 4.11263074 1.68869999\n", + " 4.23178909 2.84840204 2.07273326 3.99032469 4.3642483 3.98384462\n", + " 3.94021971 2.82077176]\n", "[4.0, 1.5, 4.0, 4.0, 4.0, 4.0, 3.0, 4.0, 3.0, 0.5, 4.0, 0.5, 4.5, 1.5, 0.5, 4.0, 4.0, 4.5, 3.0, 2.5]\n" ] } @@ -82,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": { "collapsed": false }, @@ -119,31 +129,31 @@ "Apollo 13 (1995) 197 votes\n", "Speed (1994) 197 votes\n", "Seven (a.k.a. Se7en) (1995) 196 votes\n", - "Aladdin (1992) 191 votes\n", "Sixth Sense, The (1999) 191 votes\n", + "Aladdin (1992) 191 votes\n", "Lord of the Rings: The Fellowship of the Ring, The (2001) 189 votes\n", "Saving Private Ryan (1998) 187 votes\n", "True Lies (1994) 184 votes\n", "Lion King, The (1994) 179 votes\n", - "Ace Ventura: Pet Detective (1994) 173 votes\n", "Mission: Impossible (1996) 173 votes\n", + "Ace Ventura: Pet Detective (1994) 173 votes\n", "Men in Black (a.k.a. MIB) (1997) 172 votes\n", "Princess Bride, The (1987) 171 votes\n", - "Indiana Jones and the Last Crusade (1989) 167 votes\n", "Lord of the Rings: The Two Towers, The (2002) 167 votes\n", - "Mrs. Doubtfire (1993) 166 votes\n", + "Indiana Jones and the Last Crusade (1989) 167 votes\n", "Lord of the Rings: The Return of the King, The (2003) 166 votes\n", + "Mrs. Doubtfire (1993) 166 votes\n", "Die Hard (1988) 165 votes\n", - "Terminator, The (1984) 164 votes\n", "Gladiator (2000) 164 votes\n", + "Terminator, The (1984) 164 votes\n", "Rock, The (1996) 160 votes\n", "Shrek (2001) 158 votes\n", - "Batman Forever (1995) 157 votes\n", + "Groundhog Day (1993) 157 votes\n", "Stargate (1994) 157 votes\n", "Aliens (1986) 157 votes\n", - "Groundhog Day (1993) 157 votes\n", - "Blade Runner (1982) 156 votes\n", + "Batman Forever (1995) 157 votes\n", "E.T. the Extra-Terrestrial (1982) 156 votes\n", + "Blade Runner (1982) 156 votes\n", "Alien (1979) 156 votes\n", "Memento (2000) 156 votes\n", "Monty Python and the Holy Grail (1975) 154 votes\n", @@ -163,10 +173,10 @@ "Good Will Hunting (1997) 140 votes\n", "Ghostbusters (a.k.a. Ghost Busters) (1984) 139 votes\n", "L.A. Confidential (1997) 137 votes\n", - "Willy Wonka & the Chocolate Factory (1971) 136 votes\n", "Star Wars: Episode I - The Phantom Menace (1999) 136 votes\n", - "GoldenEye (1995) 135 votes\n", + "Willy Wonka & the Chocolate Factory (1971) 136 votes\n", "Goodfellas (1990) 135 votes\n", + "GoldenEye (1995) 135 votes\n", "Clear and Present Danger (1994) 134 votes\n", "Clockwork Orange, A (1971) 134 votes\n", "Reservoir Dogs (1992) 131 votes\n", @@ -176,15 +186,15 @@ "Sleepless in Seattle (1993) 127 votes\n", "Dark Knight, The (2008) 127 votes\n", "2001: A Space Odyssey (1968) 126 votes\n", + "Casablanca (1942) 125 votes\n", "Four Weddings and a Funeral (1994) 125 votes\n", "Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964) 125 votes\n", - "Casablanca (1942) 125 votes\n", "Home Alone (1990) 124 votes\n", "Jerry Maguire (1996) 124 votes\n", "Being John Malkovich (1999) 124 votes\n", "Waterworld (1995) 123 votes\n", - "Interview with the Vampire: The Vampire Chronicles (1994) 122 votes\n", "Truman Show, The (1998) 122 votes\n", + "Interview with the Vampire: The Vampire Chronicles (1994) 122 votes\n", "Ocean's Eleven (2001) 119 votes\n", "Amelie (Fabuleux destin d'Amélie Poulain, Le) (2001) 119 votes\n", "Taxi Driver (1976) 118 votes\n", @@ -206,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -217,7 +227,7 @@ "(20, 10325)" ] }, - "execution_count": 7, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -235,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": { "collapsed": false }, @@ -246,7 +256,7 @@ "(20, 10325)" ] }, - "execution_count": 8, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -261,7 +271,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "metadata": { "collapsed": false }, @@ -274,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "metadata": { "collapsed": false }, @@ -285,7 +295,7 @@ "(10325, 10325)" ] }, - "execution_count": 11, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -296,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "metadata": { "collapsed": false }, @@ -310,7 +320,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 20, "metadata": { "collapsed": false }, @@ -319,35 +329,41 @@ "name": "stdout", "output_type": "stream", "text": [ - "Aladdin (1992)\n", - "Mrs. Doubtfire (1993)\n", - "Groundhog Day (1993)\n", - "Saving Private Ryan (1998)\n", - "Pulp Fiction (1994)\n" + "Reservoir Dogs (1992)\n", + "Pulp Fiction (1994)\n", + "Twister (1996)\n", + "Gladiator (2000)\n", + "Shrek (2001)\n", + "Babe (1995)\n", + "Dumb & Dumber (Dumb and Dumber) (1994)\n", + "Home Alone (1990)\n", + "Memento (2000)\n", + "Pretty Woman (1990)\n" ] } ], "source": [ - "sampled_items = list(map(lambda x: popular[int(x)], dpplib.sample_k(5, D, V)))\n", + "sampled_items = list(map(lambda x: popular[int(x)], dpplib.sample_k(10, D, V)))\n", "for i in sampled_items:\n", " print(works[i, 1])" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [], "source": [ "X = svd.VT.T[np.array(sampled_items)]\n", - "# X = svd.VT.T[np.array(sampled_items)[np.array([0, 2, 3, 4, 7, 8])]]" + "# 1..-1\n", + "X = svd.VT.T[np.array(sampled_items)[np.array([0, 3, 4, 5, 6, 7, 8, 9])]]" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "metadata": { "collapsed": false }, @@ -355,14 +371,17 @@ { "data": { "text/plain": [ - "array([[ 0.49878715, 0.50121285],\n", - " [ 0.49874555, 0.50125445],\n", - " [ 0.50254882, 0.49745118],\n", - " [ 0.50374561, 0.49625439],\n", - " [ 0.49366342, 0.50633658]])" + "array([[ 0.35882245, 0.64117755],\n", + " [ 0.61379769, 0.38620231],\n", + " [ 0.3224256 , 0.6775744 ],\n", + " [ 0.76941013, 0.23058987],\n", + " [ 0.49692358, 0.50307642],\n", + " [ 0.28776088, 0.71223912],\n", + " [ 0.41227464, 0.58772536],\n", + " [ 0.35195767, 0.64804233]])" ] }, - "execution_count": 16, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -373,7 +392,7 @@ "\n", "clf = LogisticRegression(fit_intercept=False)\n", "# clf = LinearRegression(fit_intercept=False)\n", - "clf.fit(X, [1, 1, 0, 0, 1])\n", + "clf.fit(X, [1, -1, 1, -1, -1, 1, 1, 1])\n", "#pred = clf.coef_[0]\n", "predx, predy = clf.coef_[0][:2]\n", "clf.predict_proba(X)" @@ -381,7 +400,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -389,10 +408,10 @@ { "data": { "text/plain": [ - "(0.019735315617398521, -0.021387541105625088)" + "(-0.08229352440904425, -0.47006453813220955)" ] }, - "execution_count": 17, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -404,7 +423,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 15, "metadata": { "collapsed": false }, @@ -415,7 +434,7 @@ "'JJ = 1587\\nRB = 188\\njjx, jjy = svd.U[JJ,0], svd.U[JJ,1]\\nrbx, rby = svd.U[RB,0], svd.U[RB,1]'" ] }, - "execution_count": 18, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -430,7 +449,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -441,6 +460,7 @@ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", + "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", @@ -499,6 +519,9 @@ " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", @@ -568,6 +591,15 @@ " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", @@ -624,8 +656,9 @@ " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", @@ -758,10 +791,10 @@ "}\n", "\n", "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n", - " var x0 = msg['x0'];\n", - " var y0 = fig.canvas.height - msg['y0'];\n", - " var x1 = msg['x1'];\n", - " var y1 = fig.canvas.height - msg['y1'];\n", + " var x0 = msg['x0'] / mpl.ratio;\n", + " var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n", + " var x1 = msg['x1'] / mpl.ratio;\n", + " var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", @@ -917,8 +950,8 @@ " this.canvas_div.focus();\n", " }\n", "\n", - " var x = canvas_pos.x;\n", - " var y = canvas_pos.y;\n", + " var x = canvas_pos.x * mpl.ratio;\n", + " var y = canvas_pos.y * mpl.ratio;\n", "\n", " this.send_message(name, {x: x, y: y, button: event.button,\n", " step: event.step,\n", @@ -1039,6 +1072,7 @@ "};\n", "\n", "mpl.figure.prototype.handle_close = function(fig, msg) {\n", + " var width = fig.canvas.width/mpl.ratio\n", " fig.root.unbind('remove')\n", "\n", " // Update the output cell to use the data from the current canvas.\n", @@ -1047,7 +1081,7 @@ " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable()\n", - " $(fig.parent_element).html('');\n", + " $(fig.parent_element).html('');\n", " fig.close_ws(fig, msg);\n", "}\n", "\n", @@ -1058,8 +1092,9 @@ "\n", "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", + " var width = this.canvas.width/mpl.ratio\n", " var dataURL = this.canvas.toDataURL();\n", - " this.cell_info[1]['text/html'] = '';\n", + " this.cell_info[1]['text/html'] = '';\n", "}\n", "\n", "mpl.figure.prototype.updated_canvas_event = function() {\n", @@ -1148,12 +1183,9 @@ " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", - " event.shiftKey = false;\n", - " // Send a \"J\" for go to next cell\n", - " event.which = 74;\n", - " event.keyCode = 74;\n", - " manager.command_mode();\n", - " manager.handle_keydown(event);\n", + " // select the cell after this one\n", + " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", + " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", @@ -1202,7 +1234,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1263,20 +1295,20 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tengen Toppa Gurren Lagann -0.007899\n", - "Fairy Tail -0.538188\n", - "Le Château dans le ciel 0.802614\n", - "Death Note 0.438318\n", - "Yu-Gi-Oh! GX -0.469742\n" + "ename": "IndexError", + "evalue": "index 1587 is out of bounds for axis 0 with size 668", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mjj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msvd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mU\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mJJ\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mwork_id\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msampled_items\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtitles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mwork_id\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mround\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mjj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msvd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mVT\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mwork_id\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mIndexError\u001b[0m: index 1587 is out of bounds for axis 0 with size 668" ] } ], @@ -1753,7 +1785,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1" + "version": "3.6.0" } }, "nbformat": 4,