diff --git a/benches/lib.rs b/benches/lib.rs index 1aeec8b..bbf3b1a 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -15,21 +15,20 @@ fn load_content() -> json::JsonValue { } fn bench_engine(c: &mut Criterion) { - c.bench_function("add 100", |bencher| { + c.bench_function("add books", |bencher| { let j = load_content(); let mut books: Vec<(&str, &str)> = Vec::new(); - for book in j.members() { - let title = book["title"].as_str().unwrap(); - books.push((title, title)); + for title in j.members() { + books.push((title.as_str().unwrap(), title.as_str().unwrap())); } bencher.iter_batched_ref( || SimSearch::new(), |engine| { for (title, terms) in &books { - engine.insert(title, terms); + engine.insert(*title, *terms); } }, BatchSize::SmallInput, @@ -39,9 +38,8 @@ fn bench_engine(c: &mut Criterion) { let mut engine = SimSearch::new(); let j = load_content(); - for book in j.members() { - let title = book["title"].as_str().unwrap(); - engine.insert(title, title); + for title in j.members() { + engine.insert(title.as_str().unwrap(), title.as_str().unwrap()); } bencher.iter(|| engine.search("odl sea")); diff --git a/books.json b/books.json index 6a69796..0024636 100644 --- a/books.json +++ b/books.json @@ -1,1002 +1,533 @@ [ - { - "author": "Chinua Achebe", - "country": "Nigeria", - "imageLink": "images/things-fall-apart.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Things_Fall_Apart\n", - "pages": 209, - "title": "Things Fall Apart", - "year": 1958 - }, - { - "author": "Hans Christian Andersen", - "country": "Denmark", - "imageLink": "images/fairy-tales.jpg", - "language": "Danish", - "link": "https://en.wikipedia.org/wiki/Fairy_Tales_Told_for_Children._First_Collection.\n", - "pages": 784, - "title": "Fairy tales", - "year": 1836 - }, - { - "author": "Dante Alighieri", - "country": "Italy", - "imageLink": "images/the-divine-comedy.jpg", - "language": "Italian", - "link": "https://en.wikipedia.org/wiki/Divine_Comedy\n", - "pages": 928, - "title": "The Divine Comedy", - "year": 1315 - }, - { - "author": "Unknown", - "country": "Sumer and Akkadian Empire", - "imageLink": "images/the-epic-of-gilgamesh.jpg", - "language": "Akkadian", - "link": "https://en.wikipedia.org/wiki/Epic_of_Gilgamesh\n", - "pages": 160, - "title": "The Epic Of Gilgamesh", - "year": -1700 - }, - { - "author": "Unknown", - "country": "Achaemenid Empire", - "imageLink": "images/the-book-of-job.jpg", - "language": "Hebrew", - "link": "https://en.wikipedia.org/wiki/Book_of_Job\n", - "pages": 176, - "title": "The Book Of Job", - "year": -600 - }, - { - "author": "Unknown", - "country": "India/Iran/Iraq/Egypt/Tajikistan", - "imageLink": "images/one-thousand-and-one-nights.jpg", - "language": "Arabic", - "link": "https://en.wikipedia.org/wiki/One_Thousand_and_One_Nights\n", - "pages": 288, - "title": "One Thousand and One Nights", - "year": 1200 - }, - { - "author": "Unknown", - "country": "Iceland", - "imageLink": "images/njals-saga.jpg", - "language": "Old Norse", - "link": "https://en.wikipedia.org/wiki/Nj%C3%A1ls_saga\n", - "pages": 384, - "title": "Nj\u00e1l's Saga", - "year": 1350 - }, - { - "author": "Jane Austen", - "country": "United Kingdom", - "imageLink": "images/pride-and-prejudice.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Pride_and_Prejudice\n", - "pages": 226, - "title": "Pride and Prejudice", - "year": 1813 - }, - { - "author": "Honor\u00e9 de Balzac", - "country": "France", - "imageLink": "images/le-pere-goriot.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Le_P%C3%A8re_Goriot\n", - "pages": 443, - "title": "Le P\u00e8re Goriot", - "year": 1835 - }, - { - "author": "Samuel Beckett", - "country": "Republic of Ireland", - "imageLink": "images/molloy-malone-dies-the-unnamable.jpg", - "language": "French, English", - "link": "https://en.wikipedia.org/wiki/Molloy_(novel)\n", - "pages": 256, - "title": "Molloy, Malone Dies, The Unnamable, the trilogy", - "year": 1952 - }, - { - "author": "Giovanni Boccaccio", - "country": "Italy", - "imageLink": "images/the-decameron.jpg", - "language": "Italian", - "link": "https://en.wikipedia.org/wiki/The_Decameron\n", - "pages": 1024, - "title": "The Decameron", - "year": 1351 - }, - { - "author": "Jorge Luis Borges", - "country": "Argentina", - "imageLink": "images/ficciones.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/Ficciones\n", - "pages": 224, - "title": "Ficciones", - "year": 1965 - }, - { - "author": "Emily Bront\u00eb", - "country": "United Kingdom", - "imageLink": "images/wuthering-heights.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Wuthering_Heights\n", - "pages": 342, - "title": "Wuthering Heights", - "year": 1847 - }, - { - "author": "Albert Camus", - "country": "Algeria, French Empire", - "imageLink": "images/l-etranger.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/The_Stranger_(novel)\n", - "pages": 185, - "title": "The Stranger", - "year": 1942 - }, - { - "author": "Paul Celan", - "country": "Romania, France", - "imageLink": "images/poems-paul-celan.jpg", - "language": "German", - "link": "\n", - "pages": 320, - "title": "Poems", - "year": 1952 - }, - { - "author": "Louis-Ferdinand C\u00e9line", - "country": "France", - "imageLink": "images/voyage-au-bout-de-la-nuit.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Journey_to_the_End_of_the_Night\n", - "pages": 505, - "title": "Journey to the End of the Night", - "year": 1932 - }, - { - "author": "Miguel de Cervantes", - "country": "Spain", - "imageLink": "images/don-quijote-de-la-mancha.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/Don_Quixote\n", - "pages": 1056, - "title": "Don Quijote De La Mancha", - "year": 1610 - }, - { - "author": "Geoffrey Chaucer", - "country": "England", - "imageLink": "images/the-canterbury-tales.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/The_Canterbury_Tales\n", - "pages": 544, - "title": "The Canterbury Tales", - "year": 1450 - }, - { - "author": "Anton Chekhov", - "country": "Russia", - "imageLink": "images/stories-of-anton-chekhov.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/List_of_short_stories_by_Anton_Chekhov\n", - "pages": 194, - "title": "Stories", - "year": 1886 - }, - { - "author": "Joseph Conrad", - "country": "United Kingdom", - "imageLink": "images/nostromo.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Nostromo\n", - "pages": 320, - "title": "Nostromo", - "year": 1904 - }, - { - "author": "Charles Dickens", - "country": "United Kingdom", - "imageLink": "images/great-expectations.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Great_Expectations\n", - "pages": 194, - "title": "Great Expectations", - "year": 1861 - }, - { - "author": "Denis Diderot", - "country": "France", - "imageLink": "images/jacques-the-fatalist.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Jacques_the_Fatalist\n", - "pages": 596, - "title": "Jacques the Fatalist", - "year": 1796 - }, - { - "author": "Alfred D\u00f6blin", - "country": "Germany", - "imageLink": "images/berlin-alexanderplatz.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/Berlin_Alexanderplatz\n", - "pages": 600, - "title": "Berlin Alexanderplatz", - "year": 1929 - }, - { - "author": "Fyodor Dostoevsky", - "country": "Russia", - "imageLink": "images/crime-and-punishment.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/Crime_and_Punishment\n", - "pages": 551, - "title": "Crime and Punishment", - "year": 1866 - }, - { - "author": "Fyodor Dostoevsky", - "country": "Russia", - "imageLink": "images/the-idiot.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/The_Idiot\n", - "pages": 656, - "title": "The Idiot", - "year": 1869 - }, - { - "author": "Fyodor Dostoevsky", - "country": "Russia", - "imageLink": "images/the-possessed.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/Demons_(Dostoyevsky_novel)\n", - "pages": 768, - "title": "The Possessed", - "year": 1872 - }, - { - "author": "Fyodor Dostoevsky", - "country": "Russia", - "imageLink": "images/the-brothers-karamazov.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/The_Brothers_Karamazov\n", - "pages": 824, - "title": "The Brothers Karamazov", - "year": 1880 - }, - { - "author": "George Eliot", - "country": "United Kingdom", - "imageLink": "images/middlemarch.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Middlemarch\n", - "pages": 800, - "title": "Middlemarch", - "year": 1871 - }, - { - "author": "Ralph Ellison", - "country": "United States", - "imageLink": "images/invisible-man.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Invisible_Man\n", - "pages": 581, - "title": "Invisible Man", - "year": 1952 - }, - { - "author": "Euripides", - "country": "Greece", - "imageLink": "images/medea.jpg", - "language": "Greek", - "link": "https://en.wikipedia.org/wiki/Medea_(play)\n", - "pages": 104, - "title": "Medea", - "year": -431 - }, - { - "author": "William Faulkner", - "country": "United States", - "imageLink": "images/absalom-absalom.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Absalom,_Absalom!\n", - "pages": 313, - "title": "Absalom, Absalom!", - "year": 1936 - }, - { - "author": "William Faulkner", - "country": "United States", - "imageLink": "images/the-sound-and-the-fury.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/The_Sound_and_the_Fury\n", - "pages": 326, - "title": "The Sound and the Fury", - "year": 1929 - }, - { - "author": "Gustave Flaubert", - "country": "France", - "imageLink": "images/madame-bovary.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Madame_Bovary\n", - "pages": 528, - "title": "Madame Bovary", - "year": 1857 - }, - { - "author": "Gustave Flaubert", - "country": "France", - "imageLink": "images/l-education-sentimentale.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Sentimental_Education\n", - "pages": 606, - "title": "Sentimental Education", - "year": 1869 - }, - { - "author": "Federico Garc\u00eda Lorca", - "country": "Spain", - "imageLink": "images/gypsy-ballads.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/Gypsy_Ballads\n", - "pages": 218, - "title": "Gypsy Ballads", - "year": 1928 - }, - { - "author": "Gabriel Garc\u00eda M\u00e1rquez", - "country": "Colombia", - "imageLink": "images/one-hundred-years-of-solitude.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/One_Hundred_Years_of_Solitude\n", - "pages": 417, - "title": "One Hundred Years of Solitude", - "year": 1967 - }, - { - "author": "Gabriel Garc\u00eda M\u00e1rquez", - "country": "Colombia", - "imageLink": "images/love-in-the-time-of-cholera.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/Love_in_the_Time_of_Cholera\n", - "pages": 368, - "title": "Love in the Time of Cholera", - "year": 1985 - }, - { - "author": "Johann Wolfgang von Goethe", - "country": "Saxe-Weimar", - "imageLink": "images/faust.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/Goethe%27s_Faust\n", - "pages": 158, - "title": "Faust", - "year": 1832 - }, - { - "author": "Nikolai Gogol", - "country": "Russia", - "imageLink": "images/dead-souls.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/Dead_Souls\n", - "pages": 432, - "title": "Dead Souls", - "year": 1842 - }, - { - "author": "G\u00fcnter Grass", - "country": "Germany", - "imageLink": "images/the-tin-drum.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/The_Tin_Drum\n", - "pages": 600, - "title": "The Tin Drum", - "year": 1959 - }, - { - "author": "Jo\u00e3o Guimar\u00e3es Rosa", - "country": "Brazil", - "imageLink": "images/the-devil-to-pay-in-the-backlands.jpg", - "language": "Portuguese", - "link": "https://en.wikipedia.org/wiki/The_Devil_to_Pay_in_the_Backlands\n", - "pages": 494, - "title": "The Devil to Pay in the Backlands", - "year": 1956 - }, - { - "author": "Knut Hamsun", - "country": "Norway", - "imageLink": "images/hunger.jpg", - "language": "Norwegian", - "link": "https://en.wikipedia.org/wiki/Hunger_(Hamsun_novel)\n", - "pages": 176, - "title": "Hunger", - "year": 1890 - }, - { - "author": "Ernest Hemingway", - "country": "United States", - "imageLink": "images/the-old-man-and-the-sea.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/The_Old_Man_and_the_Sea\n", - "pages": 128, - "title": "The Old Man and the Sea", - "year": 1952 - }, - { - "author": "Homer", - "country": "Greece", - "imageLink": "images/the-iliad-of-homer.jpg", - "language": "Greek", - "link": "https://en.wikipedia.org/wiki/Iliad\n", - "pages": 608, - "title": "Iliad", - "year": -735 - }, - { - "author": "Homer", - "country": "Greece", - "imageLink": "images/the-odyssey-of-homer.jpg", - "language": "Greek", - "link": "https://en.wikipedia.org/wiki/Odyssey\n", - "pages": 374, - "title": "Odyssey", - "year": -800 - }, - { - "author": "Henrik Ibsen", - "country": "Norway", - "imageLink": "images/a-Dolls-house.jpg", - "language": "Norwegian", - "link": "https://en.wikipedia.org/wiki/A_Doll%27s_House\n", - "pages": 68, - "title": "A Doll's House", - "year": 1879 - }, - { - "author": "James Joyce", - "country": "Irish Free State", - "imageLink": "images/ulysses.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Ulysses_(novel)\n", - "pages": 228, - "title": "Ulysses", - "year": 1922 - }, - { - "author": "Franz Kafka", - "country": "Czechoslovakia", - "imageLink": "images/stories-of-franz-kafka.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/Franz_Kafka_bibliography#Short_stories\n", - "pages": 488, - "title": "Stories", - "year": 1924 - }, - { - "author": "Franz Kafka", - "country": "Czechoslovakia", - "imageLink": "images/the-trial.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/The_Trial\n", - "pages": 160, - "title": "The Trial", - "year": 1925 - }, - { - "author": "Franz Kafka", - "country": "Czechoslovakia", - "imageLink": "images/the-castle.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/The_Castle_(novel)\n", - "pages": 352, - "title": "The Castle", - "year": 1926 - }, - { - "author": "K\u0101lid\u0101sa", - "country": "India", - "imageLink": "images/the-recognition-of-shakuntala.jpg", - "language": "Sanskrit", - "link": "https://en.wikipedia.org/wiki/Abhij%C3%B1%C4%81na%C5%9B%C4%81kuntalam\n", - "pages": 147, - "title": "The recognition of Shakuntala", - "year": 150 - }, - { - "author": "Yasunari Kawabata", - "country": "Japan", - "imageLink": "images/the-sound-of-the-mountain.jpg", - "language": "Japanese", - "link": "https://en.wikipedia.org/wiki/The_Sound_of_the_Mountain\n", - "pages": 288, - "title": "The Sound of the Mountain", - "year": 1954 - }, - { - "author": "Nikos Kazantzakis", - "country": "Greece", - "imageLink": "images/zorba-the-greek.jpg", - "language": "Greek", - "link": "https://en.wikipedia.org/wiki/Zorba_the_Greek\n", - "pages": 368, - "title": "Zorba the Greek", - "year": 1946 - }, - { - "author": "D. H. Lawrence", - "country": "United Kingdom", - "imageLink": "images/sons-and-lovers.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Sons_and_Lovers\n", - "pages": 432, - "title": "Sons and Lovers", - "year": 1913 - }, - { - "author": "Halld\u00f3r Laxness", - "country": "Iceland", - "imageLink": "images/independent-people.jpg", - "language": "Icelandic", - "link": "https://en.wikipedia.org/wiki/Independent_People\n", - "pages": 470, - "title": "Independent People", - "year": 1934 - }, - { - "author": "Giacomo Leopardi", - "country": "Italy", - "imageLink": "images/poems-giacomo-leopardi.jpg", - "language": "Italian", - "link": "\n", - "pages": 184, - "title": "Poems", - "year": 1818 - }, - { - "author": "Doris Lessing", - "country": "United Kingdom", - "imageLink": "images/the-golden-notebook.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/The_Golden_Notebook\n", - "pages": 688, - "title": "The Golden Notebook", - "year": 1962 - }, - { - "author": "Astrid Lindgren", - "country": "Sweden", - "imageLink": "images/pippi-longstocking.jpg", - "language": "Swedish", - "link": "https://en.wikipedia.org/wiki/Pippi_Longstocking\n", - "pages": 160, - "title": "Pippi Longstocking", - "year": 1945 - }, - { - "author": "Lu Xun", - "country": "China", - "imageLink": "images/diary-of-a-madman.jpg", - "language": "Chinese", - "link": "https://en.wikipedia.org/wiki/A_Madman%27s_Diary\n", - "pages": 389, - "title": "Diary of a Madman", - "year": 1918 - }, - { - "author": "Naguib Mahfouz", - "country": "Egypt", - "imageLink": "images/children-of-gebelawi.jpg", - "language": "Arabic", - "link": "https://en.wikipedia.org/wiki/Children_of_Gebelawi\n", - "pages": 355, - "title": "Children of Gebelawi", - "year": 1959 - }, - { - "author": "Thomas Mann", - "country": "Germany", - "imageLink": "images/buddenbrooks.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/Buddenbrooks\n", - "pages": 736, - "title": "Buddenbrooks", - "year": 1901 - }, - { - "author": "Thomas Mann", - "country": "Germany", - "imageLink": "images/the-magic-mountain.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/The_Magic_Mountain\n", - "pages": 720, - "title": "The Magic Mountain", - "year": 1924 - }, - { - "author": "Herman Melville", - "country": "United States", - "imageLink": "images/moby-dick.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Moby-Dick\n", - "pages": 378, - "title": "Moby Dick", - "year": 1851 - }, - { - "author": "Michel de Montaigne", - "country": "France", - "imageLink": "images/essais.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Essays_(Montaigne)\n", - "pages": 404, - "title": "Essays", - "year": 1595 - }, - { - "author": "Elsa Morante", - "country": "Italy", - "imageLink": "images/history.jpg", - "language": "Italian", - "link": "https://en.wikipedia.org/wiki/History_(novel)\n", - "pages": 600, - "title": "History", - "year": 1974 - }, - { - "author": "Toni Morrison", - "country": "United States", - "imageLink": "images/beloved.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Beloved_(novel)\n", - "pages": 321, - "title": "Beloved", - "year": 1987 - }, - { - "author": "Murasaki Shikibu", - "country": "Japan", - "imageLink": "images/the-tale-of-genji.jpg", - "language": "Japanese", - "link": "https://en.wikipedia.org/wiki/The_Tale_of_Genji\n", - "pages": 1360, - "title": "The Tale of Genji", - "year": 1006 - }, - { - "author": "Robert Musil", - "country": "Austria", - "imageLink": "images/the-man-without-qualities.jpg", - "language": "German", - "link": "https://en.wikipedia.org/wiki/The_Man_Without_Qualities\n", - "pages": 365, - "title": "The Man Without Qualities", - "year": 1931 - }, - { - "author": "Vladimir Nabokov", - "country": "Russia/United States", - "imageLink": "images/lolita.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Lolita\n", - "pages": 317, - "title": "Lolita", - "year": 1955 - }, - { - "author": "George Orwell", - "country": "United Kingdom", - "imageLink": "images/nineteen-eighty-four.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Nineteen_Eighty-Four\n", - "pages": 272, - "title": "Nineteen Eighty-Four", - "year": 1949 - }, - { - "author": "Ovid", - "country": "Roman Empire", - "imageLink": "images/the-metamorphoses-of-ovid.jpg", - "language": "Classical Latin", - "link": "https://en.wikipedia.org/wiki/Metamorphoses\n", - "pages": 576, - "title": "Metamorphoses", - "year": 100 - }, - { - "author": "Fernando Pessoa", - "country": "Portugal", - "imageLink": "images/the-book-of-disquiet.jpg", - "language": "Portuguese", - "link": "https://en.wikipedia.org/wiki/The_Book_of_Disquiet\n", - "pages": 272, - "title": "The Book of Disquiet", - "year": 1928 - }, - { - "author": "Edgar Allan Poe", - "country": "United States", - "imageLink": "images/tales-and-poems-of-edgar-allan-poe.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Edgar_Allan_Poe_bibliography#Tales\n", - "pages": 842, - "title": "Tales", - "year": 1950 - }, - { - "author": "Marcel Proust", - "country": "France", - "imageLink": "images/a-la-recherche-du-temps-perdu.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/In_Search_of_Lost_Time\n", - "pages": 2408, - "title": "In Search of Lost Time", - "year": 1920 - }, - { - "author": "Fran\u00e7ois Rabelais", - "country": "France", - "imageLink": "images/gargantua-and-pantagruel.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Gargantua_and_Pantagruel\n", - "pages": 623, - "title": "Gargantua and Pantagruel", - "year": 1533 - }, - { - "author": "Juan Rulfo", - "country": "Mexico", - "imageLink": "images/pedro-paramo.jpg", - "language": "Spanish", - "link": "https://en.wikipedia.org/wiki/Pedro_P%C3%A1ramo\n", - "pages": 124, - "title": "Pedro P\u00e1ramo", - "year": 1955 - }, - { - "author": "Rumi", - "country": "Sultanate of Rum", - "imageLink": "images/the-masnavi.jpg", - "language": "Persian", - "link": "https://en.wikipedia.org/wiki/Masnavi\n", - "pages": 438, - "title": "The Masnavi", - "year": 1236 - }, - { - "author": "Salman Rushdie", - "country": "United Kingdom, India", - "imageLink": "images/midnights-children.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Midnight%27s_Children\n", - "pages": 536, - "title": "Midnight's Children", - "year": 1981 - }, - { - "author": "Saadi", - "country": "Persia, Persian Empire", - "imageLink": "images/bostan.jpg", - "language": "Persian", - "link": "https://en.wikipedia.org/wiki/Bustan_(book)\n", - "pages": 298, - "title": "Bostan", - "year": 1257 - }, - { - "author": "Tayeb Salih", - "country": "Sudan", - "imageLink": "images/season-of-migration-to-the-north.jpg", - "language": "Arabic", - "link": "https://en.wikipedia.org/wiki/Season_of_Migration_to_the_North\n", - "pages": 139, - "title": "Season of Migration to the North", - "year": 1966 - }, - { - "author": "Jos\u00e9 Saramago", - "country": "Portugal", - "imageLink": "images/blindness.jpg", - "language": "Portuguese", - "link": "https://en.wikipedia.org/wiki/Blindness_(novel)\n", - "pages": 352, - "title": "Blindness", - "year": 1995 - }, - { - "author": "William Shakespeare", - "country": "England", - "imageLink": "images/hamlet.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Hamlet\n", - "pages": 432, - "title": "Hamlet", - "year": 1603 - }, - { - "author": "William Shakespeare", - "country": "England", - "imageLink": "images/king-lear.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/King_Lear\n", - "pages": 384, - "title": "King Lear", - "year": 1608 - }, - { - "author": "William Shakespeare", - "country": "England", - "imageLink": "images/othello.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Othello\n", - "pages": 314, - "title": "Othello", - "year": 1609 - }, - { - "author": "Sophocles", - "country": "Greece", - "imageLink": "images/oedipus-the-king.jpg", - "language": "Greek", - "link": "https://en.wikipedia.org/wiki/Oedipus_the_King\n", - "pages": 88, - "title": "Oedipus the King", - "year": -430 - }, - { - "author": "Stendhal", - "country": "France", - "imageLink": "images/le-rouge-et-le-noir.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/The_Red_and_the_Black\n", - "pages": 576, - "title": "The Red and the Black", - "year": 1830 - }, - { - "author": "Laurence Sterne", - "country": "England", - "imageLink": "images/the-life-and-opinions-of-tristram-shandy.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/The_Life_and_Opinions_of_Tristram_Shandy,_Gentleman\n", - "pages": 640, - "title": "The Life And Opinions of Tristram Shandy", - "year": 1760 - }, - { - "author": "Italo Svevo", - "country": "Italy", - "imageLink": "images/confessions-of-zeno.jpg", - "language": "Italian", - "link": "https://en.wikipedia.org/wiki/Zeno%27s_Conscience\n", - "pages": 412, - "title": "Confessions of Zeno", - "year": 1923 - }, - { - "author": "Jonathan Swift", - "country": "Ireland", - "imageLink": "images/gullivers-travels.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Gulliver%27s_Travels\n", - "pages": 178, - "title": "Gulliver's Travels", - "year": 1726 - }, - { - "author": "Leo Tolstoy", - "country": "Russia", - "imageLink": "images/war-and-peace.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/War_and_Peace\n", - "pages": 1296, - "title": "War and Peace", - "year": 1867 - }, - { - "author": "Leo Tolstoy", - "country": "Russia", - "imageLink": "images/anna-karenina.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/Anna_Karenina\n", - "pages": 864, - "title": "Anna Karenina", - "year": 1877 - }, - { - "author": "Leo Tolstoy", - "country": "Russia", - "imageLink": "images/the-death-of-ivan-ilyich.jpg", - "language": "Russian", - "link": "https://en.wikipedia.org/wiki/The_Death_of_Ivan_Ilyich\n", - "pages": 92, - "title": "The Death of Ivan Ilyich", - "year": 1886 - }, - { - "author": "Mark Twain", - "country": "United States", - "imageLink": "images/the-adventures-of-huckleberry-finn.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Adventures_of_Huckleberry_Finn\n", - "pages": 224, - "title": "The Adventures of Huckleberry Finn", - "year": 1884 - }, - { - "author": "Valmiki", - "country": "India", - "imageLink": "images/ramayana.jpg", - "language": "Sanskrit", - "link": "https://en.wikipedia.org/wiki/Ramayana\n", - "pages": 152, - "title": "Ramayana", - "year": -450 - }, - { - "author": "Virgil", - "country": "Roman Empire", - "imageLink": "images/the-aeneid.jpg", - "language": "Classical Latin", - "link": "https://en.wikipedia.org/wiki/Aeneid\n", - "pages": 442, - "title": "The Aeneid", - "year": -23 - }, - { - "author": "Vyasa", - "country": "India", - "imageLink": "images/the-mahab-harata.jpg", - "language": "Sanskrit", - "link": "https://en.wikipedia.org/wiki/Mahabharata\n", - "pages": 276, - "title": "Mahabharata", - "year": -700 - }, - { - "author": "Walt Whitman", - "country": "United States", - "imageLink": "images/leaves-of-grass.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Leaves_of_Grass\n", - "pages": 152, - "title": "Leaves of Grass", - "year": 1855 - }, - { - "author": "Virginia Woolf", - "country": "United Kingdom", - "imageLink": "images/mrs-dalloway.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/Mrs_Dalloway\n", - "pages": 216, - "title": "Mrs Dalloway", - "year": 1925 - }, - { - "author": "Virginia Woolf", - "country": "United Kingdom", - "imageLink": "images/to-the-lighthouse.jpg", - "language": "English", - "link": "https://en.wikipedia.org/wiki/To_the_Lighthouse\n", - "pages": 209, - "title": "To the Lighthouse", - "year": 1927 - }, - { - "author": "Marguerite Yourcenar", - "country": "France/Belgium", - "imageLink": "images/memoirs-of-hadrian.jpg", - "language": "French", - "link": "https://en.wikipedia.org/wiki/Memoirs_of_Hadrian\n", - "pages": 408, - "title": "Memoirs of Hadrian", - "year": 1951 - } -] \ No newline at end of file + "Unlocking Android", + "Android in Action, Second Edition", + "Specification by Example", + "Flex 3 in Action", + "Flex 4 in Action", + "Collective Intelligence in Action", + "Zend Framework in Action", + "Flex on Java", + "Griffon in Action", + "OSGi in Depth", + "Flexible Rails", + "Hello! Flex 4", + "Coffeehouse", + "Team Foundation Server 2008 in Action", + "Brownfield Application Development in .NET", + "MongoDB in Action", + "Distributed Application Development with PowerBuilder 6.0", + "Jaguar Development with PowerBuilder 7", + "Taming Jaguar", + "3D User Interfaces with Java 3D", + "Hibernate in Action", + "Hibernate in Action (Chinese Edition)", + "Java Persistence with Hibernate", + "JSTL in Action", + "iBATIS in Action", + "Designing Hard Software", + "Hibernate Search in Action", + "jQuery in Action", + "jQuery in Action, Second Edition", + "Building Secure and Reliable Network Applications", + "Ruby for Rails", + "The Well-Grounded Rubyist", + "Website Owner's Manual", + "ASP.NET 4.0 in Practice", + "Hello! Python", + "PFC Programmer's Reference Manual", + "Graphics File Formats", + "Visual Object Oriented Programming", + "iOS in Practice", + "iPhone in Action", + "Silverlight 2 in Action", + "The Quick Python Book, Second Edition", + "Internet and Intranet Applications with PowerBuilder 6", + "Practical Methods for Your Year 2000 Problem", + "Mobile Agents", + "Spring Dynamic Modules in Action", + "SQL Server 2008 Administration in Action", + "Android in Practice", + "Object Oriented Perl", + "GWT in Practice", + "Ajax in Action", + "Ajax in Practice", + "Prototype and Scriptaculous in Action", + "POJOs in Action", + "Data Munging with Perl", + "Hello! HTML5 & CSS3", + "Seam in Action", + "Wicket in Action", + "Open Source SOA", + "Struts 2 in Action", + "Essential Guide to Peoplesoft Development and Customization", + ".NET Multithreading", + "SCWCD Exam Study Kit Second Edition", + "Spring Roo in Action", + "SOA Governance in Action", + "RSS and Atom in Action", + "LDAP Programming, Management and Integration", + "Mule in Action", + "Java Foundation Classes", + "Managing Components with Modeler", + "Command-line Processing with CLI", + "Understanding and Using Chain", + "Working with the Logging and Discovery Components", + "Uploading files with FileUpload", + "Handling Protocols with the Net Component", + "XML Parsing with Digester", + "JXPath and Betwixt: Working with XML", + "Validating Data with Validator", + "Enhancing Java Core Libraries with Collections", + "Enhancing Java Core Libraries with BeanUtils and Lang", + "Pool and DBCP: Creating and Using Object Pools", + "Python and Tkinter Programming", + "Microsoft.NET for Programmers", + "Grails in Action", + "Up to Speed with Swing, Second Edition", + "OSGi in Action", + "GWT in Action", + "The Quick Python Book", + "SharePoint 2010 Site Owner's Manual", + "Java Development with Ant", + "Lucene in Action", + "Lucene in Action, Second Edition", + "PowerBuilder 6.0 Questions & Answers", + "The Awesome Power of PowerJ", + "The Awesome Power of Power++", + "Azure in Action", + "Distributed Agile in Action", + "Metaprogramming in .NET", + "Portlets and Apache Portals", + "Code Generation in Action", + "Illustrated Guide to HTTP", + "Agile ALM", + "Java Network Programming, Second Edition", + "Struts in Action", + "Camel in Action", + "Taming Text", + "JBoss in Action", + "Gnuplot in Action", + "Extending and Embedding Perl", + "iOS 4 in Action", + "Elements of Programming with Perl", + "Learn Windows PowerShell in a Month of Lunches", + "R in Action", + "Android in Practice", + "SOA Security", + "Rails 3 in Action", + "Continuous Integration in .NET", + "Technology Paradise Lost", + "Kermit 95+", + "Laszlo in Action", + "Groovy in Action", + "Groovy in Action, Second Edition", + "Object Technology Centers of Excellence", + "Test Driven", + "Effective Unit Testing", + "Making Java Groovy", + "The Awesome Power of Direct3D/DirectX", + "Practical Software Requirements", + "NHibernate in Action", + "Microsoft Reporting Services in Action", + "AspectJ in Action", + "AspectJ in Action, Second Edition", + "Hadoop in Action", + "SQR in PeopleSoft and Other Applications", + "SQR in PeopleSoft and Other Applications, Second Edition", + "F# in Action", + "Tuscany SCA in Action", + "Client/Server Yellow Pages", + "Object Oriented Application Frameworks", + "Tapestry in Action", + "WebWork in Action", + "MacRuby in Action", + "Erlang and OTP in Action", + "SharePoint 2007 Developer's Guide to Business Data Catalog", + "Doing IT Right", + "Adobe AIR in Action", + "Ant in Action", + "Restlet in Action", + "iText in Action", + "iText in Action, Second Edition", + "Power-3D", + "SNA and TCP/IP Enterprise Networking", + "Subversion in Action", + "Minimal Perl", + "Distributed Programming with Java", + "Comprehensive Networking Glossary and Acronym Guide", + "JavaServer Faces in Action", + "LINQ in Action", + "Internet BBSs", + "Algorithms of the Intelligent Web", + "JUnit in Action", + "Tika in Action", + "Ruby in Practice", + "Inside LotusScript", + "Maximum MIDI", + "Planning and Managing ATM Networks", + "Client/Server Applications on ATM Networks", + "JavaFX in Action", + "Entity Framework 4 in Action", + "ASP.NET 2.0 Web Parts in Action", + "Sass and Compass in Action", + "Core OWL 5.0", + "Advanced OWL 5.0", + "Server-Based Java Programming", + "SQL Server MVP Deep Dives", + "SQL Server MVP Deep Dives", + "SQL Server MVP Deep Dives", + "PostGIS in Action", + "Programming Mac OS X", + "The Art of Unit Testing", + "Mahout in Action", + "ASP.NET MVC in Action", + "ASP.NET MVC 2 in Action", + "ASP.NET MVC 4 in Action", + "EJB 3 in Action", + "EJB 3 in Action, Second Edition", + "Explorer's Guide to the Semantic Web", + "Practical LotusScript", + "Domino Development with Java", + "Windows PowerShell in Action", + "Windows PowerShell in Action, Second Edition", + "Silverlight 4 in Action, Revised Edition", + "Silverlight 5 in Action", + "Hibernate Quickly", + "Generative Art", + "Windows Phone 7 in Action", + "Lift in Action", + "Web Development with Apache and Perl", + "Real-World Functional Programming", + "Machine Learning in Action", + "Dependency Injection", + "Understanding Enterprise SOA", + "Open-Source ESBs in Action", + "Activiti in Action", + "DSLs in Boo: Domain-Specific Languages in .NET", + "JUnit Recipes", + "wxPython in Action", + "Clojure in Action", + "Scala in Action", + "Working with Objects", + "PHP in Action", + "Secrets of the JavaScript Ninja", + "Microsoft Office Essentials", + "Swing", + "Swing Second Edition", + "The Awesome Power of Java Beans", + "Personal Videoconferencing", + "The Cloud at Your Service", + "Implementing Elliptic Curve Cryptography", + "SOA Patterns", + "Hello World!", + "SCBCD Exam Study Kit", + "Portlets in Action", + "SWT/JFace in Action", + "OpenCL in Action", + "Multiprotocol over ATM", + "Dependency Injection in .NET", + "Java 3D Programming", + "Liferay in Action", + "JSP Tag Libraries", + "Instant Messaging in Java", + "Java Applets and Channels Without Programming", + "PowerShell in Practice", + "PowerShell and WMI", + "Making Sense of Java", + "C++/CLI in Action", + "C# in Depth", + "C# in Depth, Second Edition", + "Magical A-Life Avatars", + "Becoming Agile", + "ActiveMQ in Action", + "Implementing PeopleSoft Financials", + "SQL Server DMVs in Action", + "Scala in Depth", + "JMX in Action", + "EJB Cookbook", + "GWT in Action, Second Edition", + "JUnit in Action, Second Edition", + "Bitter Java", + "Bitter EJB", + "Spring Batch in Action", + "JDK 1.4 Tutorial", + "iPhone and iPad in Action", + "SQL Server 2005 Reporting Services in Action", + "Ten Years of UserFriendly.Org", + "Graphics Programming with Perl", + "RabbitMQ in Action", + "XDoclet in Action", + "Spring in Action", + "Spring in Action, Second Edition", + "Spring in Action, Third Edition", + "Spring in Practice", + "Java 2 Micro Edition", + "SharePoint 2010 Workflows in Action", + "SharePoint 2010 Web Parts in Action", + "C++ Concurrency in Action", + "Java Servlets by Example", + "XML Programming with VB and ASP", + "Oracle8i Database Administration", + "The Engaging Web", + "Enterprise OSGi In Action", + "Ext JS in Action, Second Edition", + "Android in Action, Third Edition", + "Arduino in Action", + "Node.js in Action", + "Third-Party JavaScript ", + "Multimedia Computing", + "Web Development with JavaServer Pages", + "Up to Speed with Swing", + "Manager's Guide to Open Source", + "Programming Web Services with Java", + "TCP/IP Programming for OS/2", + "Implementing SAP R/3, Second Edition", + "Implementing SAP R/3", + "Using C-Kermit: Communication Software", + "SCWCD Exam Study Kit", + "Unit Testing in C++", + "Big Data", + "CoffeeScript in Action", + "SQL Server MVP Deep Dives, Volume 2", + "HTML5 in Action", + "Java Persistence with Hibernate, Second Edition", + "Hadoop in Practice", + "HBase in Action", + "Flex Mobile in Action", + "HTML5 for .NET Developers", + "50 Android Hacks", + "PowerShell in Depth", + "Augmented Reality Revealed", + "Building Well-Structured JavaScript Applications", + "Linked Data", + "Mule in Action, Second Edition", + "Single Page Web Applications", + "The Art of Unit Testing, Second Edition", + "Play for Java", + "Hello World! Second Edition", + "Dart in Action", + "Redis in Action", + "Using the TI-83 Plus/TI-84 Plus", + "Neo4j in Action", + "Programming the TI-83 Plus/TI-84 Plus", + "Functional Programming in Scala", + "Play for Scala", + "Node.js in Practice", + "SonarQube in Action", + "Windows Store App Development: C# and XAML", + "Learn Windows IIS in a Month of Lunches", + "Mondrian in Action", + "RabbitMQ in Depth", + "Akka in Action", + "Extending jQuery", + "OCA Java SE 7 Programmer I Certification Guide", + "Kanban in Action", + "Solr in Action", + "Making Sense of NoSQL", + "Jaguar Development with PowerBuilder 7", + "Grails in Action, Second Edition", + "Rails 4 in Action", + "Learn Windows PowerShell in a Month of Lunches, Second Edition", + "AOP in .NET", + "Learn PowerShell Toolmaking in a Month of Lunches", + "CMIS and Apache Chemistry in Action", + "Action Guide (aka VB .NET)", + "Learn Active Directory Management in a Month of Lunches", + "Spring in Action, Fourth Edition", + "The Mikado Method", + "The Responsive Web", + "Fast ASP.NET Websites", + "SBT in Action", + "PowerShell Deep Dives", + "Gradle in Action", + "Scalatra in Action", + "AngularJS in Action", + "Software Development Metrics", + "F# Deep Dives", + "C# in Depth, Third Edition", + "PostGIS in Action, Second Edition", + "R in Action, Second Edition", + "The Joy of Clojure, Second Edition", + "iOS 7 in Action", + "Hello App Inventor!", + "Ember.js in Action", + "Netty in Action", + "RavenDB in Action", + "OCP Java SE 7 Programmer II Certification Guide", + "Backbone.js in Action", + "Clojure in Action, Second Edition", + "Practical Data Science with R", + "Secrets of the JavaScript Ninja pBook upgrade", + "ArcGIS Web Development", + "Elasticsearch in Action", + "Learn SCCM 2012 in a Month of Lunches", + "Programming for Musicians and Digital Artists", + "BDD in Action", + "Windows Phone 8 in Action", + "Titanium Alloy in Action", + "Giraph in Action", + "The Well-Grounded Rubyist, Second Edition", + "Go in Action", + "The Programmer's Guide to Apache Thrift ", + "Grokking Functional Programming", + "CORS in Action", + "Reactive Design Patterns", + "Storm Applied", + "Real-World Machine Learning", + "jQuery UI in Action", + "Web Components in Action", + "JavaScript Application Design", + "Git in Practice", + "Impala in Action", + "Java 8 in Action", + "Elixir in Action", + "MongoDB in Action, Second Edition", + "Getting MEAN with Mongo, Express, Angular, and Node", + "jQuery in Action, Third Edition", + "D3.js in Action", + "Learn SQL Server Administration in a Month of Lunches", + "Geoprocessing with Python", + "Barcodes with iOS", + "Chef in Action", + "Hadoop in Practice, Second Edition", + "Oculus Rift in Action", + "OpenStack in Action", + "PowerShell in Depth, Second Edition", + "Practical Probabilistic Programming", + "Unity in Action", + "Express.js in Action", + "Learn Git in a Month of Lunches", + "Understanding SPAs", + "XSLT Quickly", + "Windows Forms Programming with C#", + "Windows Forms in Action", + "Event Processing in Action", + "The Well-Grounded Java Developer", + "Objective-C Fundamentals", + "ADO.NET Programming", + "WPF in Action with Visual Studio 2008", + "Location-Aware Applications", + "Web Development with JavaServer Pages, Second Edition", + "IntelliJ IDEA in Action", + "Spring Integration in Action", + "The Joy of Clojure", + "Dynamic WAP Application Development", + "IronPython in Action", + "Art of Java Web Development", + "Java Reflection in Action", + "Programming Windows Server 2003", + "Struts Recipes", + "Hello! iOS Development", + "Jess in Action", + "Remote LAN Access", + "J2EE and XML Development", + "Eclipse in Action", + "ASP.NET AJAX in Action", + "Ext JS in Action", + "Sencha Touch in Action", + "DSLs in Action", + "Database Programming for Handheld Devices", + "Jakarta Commons Online Bookshelf", + "Browsing with HttpClient", + "Codec: Encoders and Decoders", + "Things Fall Apart", + "Fairy tales", + "The Divine Comedy", + "The Epic Of Gilgamesh", + "The Book Of Job", + "One Thousand and One Nights", + "Njál's Saga", + "Pride and Prejudice", + "Le Père Goriot", + "Molloy, Malone Dies, The Unnamable, the trilogy", + "The Decameron", + "Ficciones", + "Wuthering Heights", + "The Stranger", + "Poems", + "Journey to the End of the Night", + "Don Quijote De La Mancha", + "The Canterbury Tales", + "Stories", + "Nostromo", + "Great Expectations", + "Jacques the Fatalist", + "Berlin Alexanderplatz", + "Crime and Punishment", + "The Idiot", + "The Possessed", + "The Brothers Karamazov", + "Middlemarch", + "Invisible Man", + "Medea", + "Absalom, Absalom!", + "The Sound and the Fury", + "Madame Bovary", + "Sentimental Education", + "Gypsy Ballads", + "One Hundred Years of Solitude", + "Love in the Time of Cholera", + "Faust", + "Dead Souls", + "The Tin Drum", + "The Devil to Pay in the Backlands", + "Hunger", + "The Old Man and the Sea", + "Iliad", + "Odyssey", + "A Doll's House", + "Ulysses", + "Stories", + "The Trial", + "The Castle", + "The recognition of Shakuntala", + "The Sound of the Mountain", + "Zorba the Greek", + "Sons and Lovers", + "Independent People", + "Poems", + "The Golden Notebook", + "Pippi Longstocking", + "Diary of a Madman", + "Children of Gebelawi", + "Buddenbrooks", + "The Magic Mountain", + "Moby Dick", + "Essays", + "History", + "Beloved", + "The Tale of Genji", + "The Man Without Qualities", + "Lolita", + "Nineteen Eighty-Four", + "Metamorphoses", + "The Book of Disquiet", + "Tales", + "In Search of Lost Time", + "Gargantua and Pantagruel", + "Pedro Páramo", + "The Masnavi", + "Midnight's Children", + "Bostan", + "Season of Migration to the North", + "Blindness", + "Hamlet", + "King Lear", + "Othello", + "Oedipus the King", + "The Red and the Black", + "The Life And Opinions of Tristram Shandy", + "Confessions of Zeno", + "Gulliver's Travels", + "War and Peace", + "Anna Karenina", + "The Death of Ivan Ilyich", + "The Adventures of Huckleberry Finn", + "Ramayana", + "The Aeneid", + "Mahabharata", + "Leaves of Grass", + "Mrs Dalloway", + "To the Lighthouse", + "Memoirs of Hadrian" +] diff --git a/examples/books.rs b/examples/books.rs index dcb2a08..b5df859 100644 --- a/examples/books.rs +++ b/examples/books.rs @@ -14,9 +14,8 @@ fn main() -> io::Result<()> { let j = json::parse(&content).unwrap(); - for book in j.members() { - let title = book["title"].as_str().unwrap(); - engine.insert(title.to_owned(), title); + for title in j.members() { + engine.insert(title.as_str().unwrap(), title.as_str().unwrap()); } println!("Please input a query string and hit enter (e.g 'old man'):",); diff --git a/tests/lib.rs b/tests/lib.rs index caa516a..fd0260e 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -22,9 +22,8 @@ fn populate_engine() -> SimSearch { let j = json::parse(&content).unwrap(); - for book in j.members() { - let title = book["title"].as_str().unwrap(); - engine.insert(title.to_owned(), title); + for title in j.members() { + engine.insert(title.as_str().unwrap().to_string(), title.as_str().unwrap()); } engine