{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# List all files in the wiki folder\n", "\n", "We can create a list with the names of all files in the wiki folder using the `os.listdir()` function." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "999" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import os\n", "\n", "file_names = os.listdir(\"wiki\")\n", "len(file_names)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Read the first file\n", "\n", "Let's read the first file and print its contents. We need to join the name of the file with the `wiki` folder. We can do this using the `os.path.join()` function." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "\n", "\n", "Dragnet (franchise) - Wikipedia\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\t
\n", "\t\t
\n", "\t\t
\n", "\t\t\t\n", "\n", "\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t
\n", "
\n", "\t\t\t

Dragnet (franchise)

\n", "\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t
From Wikipedia, the free encyclopedia
\n", "\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\tJump to:\t\t\t\t\tnavigation, \t\t\t\t\tsearch\n", "\t\t\t\t
\n", "\t\t\t\t
For other uses, see Dragnet (policing).
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
Dragnet
\"Dragnet\n", "
Dragnet opening frame from the 1950s version
\n", "
Created byJack Webb
StarringJack Webb
\n", "Ben Alexander
\n", "Harry Morgan
Narrated byHal Gibney
\n", "John Stephenson
\n", "George Fenneman
\n", "Jack Webb
Opening themeexcerpt from Miklós Rózsa's score for The Killers
Composer(s)Walter Schumann (1951-1958)
\n", "Nathan Scott (1958-1959)
\n", "Lyn Murray (1967-1968)
\n", "Frank Comstock (1968-1970)
Country of originUnited States
Original language(s)English
No. of seasons8 (1951–1959)
\n", "4 (1967–1970)
\n", "2 (1989–1991 & 2003–2004)
\n", "16 (total)
No. of episodes314 (radio 1949-1957)
\n", "276 (TV 1951–1959)
\n", "98 (TV 1967–1970)
\n", "52 (TV 1989–1991)
\n", "22 (TV 2003–2004)
\n", "762 (total)
Production
Executive producer(s)Jack Webb
Producer(s)Jack Webb
Location(s)Los Angeles, U.S.
Running time30 minutes (1951–1959; 1967–1970; 1989–1991)
\n", "60 minutes (2003–2004)
Production company(s)Mark VII Productions
\n", "(1951-1954)
\n", "Mark VII Limited (1954,
\n", "1954-1959, 1967-1970)
\n", "Universal Television (1967-1970, 1989-1990, 2003-2004)
\n", "NBC Universal Television Studio (2004)
\n", "The Arthur Company
\n", "(1989-1990)
\n", "Wolf Films (2003-2004)
DistributorMCA TV
\n", "(1951-1959, 1974-1997)
\n", "Warner Bros. (1954)
\n", "Universal Television
\n", "(1970-1974, 1997-1998, 2002-2004)
\n", "Studios USA Television
\n", "(1998-2002)
\n", "NBCUniversal Television Distribution (2004-present)
Release
Original networkNBC (1951-1959, 1967-1970)
\n", "Syndication (1989-1991)
\n", "ABC (2003-2004)
\n", "Film (1954)
Original releaseDecember 16, 1951 – December 4, 2004 (last run)
\n", "

Dragnet was an American radio, television and motion picture series, enacting the cases of a dedicated Los Angeles police detective, Sergeant Joe Friday, and his partners. The show takes its name from the police term \"dragnet\", meaning a system of coordinated measures for apprehending criminals or suspects.

\n", "

Dragnet is perhaps the most famous and influential police procedural drama in media history. The series gave audience members a feel for the danger and heroism of police work. Dragnet earned praise for improving the public opinion of police officers.[1]

\n", "

Actor and producer Jack Webb's aims in Dragnet were for realism and unpretentious acting; he achieved both goals,[peacock term] and Dragnet remains a key influence on subsequent police dramas in many media.[citation needed]

\n", "

The show's cultural impact is such that after five decades, elements of Dragnet are familiar to those who have never seen or heard the program:

\n", "
    \n", "
  • The ominous, four-note introduction to the brass and tympani theme music (titled \"Danger Ahead\") is instantly recognizable (though its origins date to Miklós Rózsa's score for the 1946 film version of The Killers).
  • \n", "
  • Another Dragnet trademark is the show's opening narration: \"Ladies and gentlemen: the story you are about to hear is true. Only the names have been changed to protect the innocent.\" This underwent minor revisions over time. The \"only\" and \"ladies and gentlemen\" were dropped at some point, and for the television version \"hear\" was changed to \"see\". Variations on this narration have been featured in subsequent crime dramas, and in parodies of the dramas (e.g. \"Only the facts have been changed to protect the guilty\").
  • \n", "
\n", "

\n", "\n", "

\n", "

Radio[edit]

\n", "\n", "\n", "

Television[edit]

\n", "

1951–59 original[edit]

\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "

1967–70 revival[edit]

\n", "\n", "
\n", "
\"\"\n", "
\n", "
\n", "Webb and Morgan in 1968.
\n", "
\n", "
\n", "

Webb relaunched Dragnet in 1966, with NBC once again chosen to air the series. He tried to persuade Ben Alexander to rejoin him as Frank Smith. Alexander was then committed to an ABC police series, Felony Squad, and the producers would not release him. Webb reluctantly came up with a new character to take the role of Joe Friday's partner, calling upon his longtime friend Harry Morgan to play Officer Bill Gannon. Morgan had previously portrayed rooming house proprietor Luther Gage in the 1949 radio series episode \"James Vickers\". George Fenneman returned as the show's primary announcer with John Stephenson replacing Hal Gibney in the role of announcing the trial dates and subsequent punishments for the offenders. Fenneman replaced Stephenson in that role during the fourth season. Unlike the previous Dragnet series, the revival was produced and aired in color.

\n", "

Webb produced a TV movie pilot for the new version of the show for Universal Television, although the pilot was not aired until January 1969. NBC bought the show on the strength of the movie and it debuted as a midseason replacement for the sitcom The Hero on Thursday nights in January 1967. To distinguish it from the original, the year was included in the title of the show (i.e., Dragnet 1967). Although Friday had been promoted to lieutenant in the final episode of the 1950s production, Webb chose to have Friday revert to sergeant with his familiar badge, \"714\".[2]

\n", "

When real-life LAPD Sergeant Dan Cooke, Webb's contact in the department during production of the revived Dragnet series, was promoted to lieutenant, he arranged to carry the same lieutenant's badge, number 714, as worn by Joe Friday. Cooke was technical advisor to the KNBC documentary \"Police Unit 2A-26\", directed by John Orland. He brought that to the attention of Webb, who hired Orland to direct and film \"This is the City\", a series of minidocumentaries about Los Angeles that preceded most TV episodes during the 1969 and 1970 seasons.[citation needed] The show had good ratings on NBC's schedule for four seasons, although its popularity did not exceed that of the 1950s version.

\n", "

Much as was done 11 years earlier, Webb decided voluntarily to discontinue Dragnet after its fourth season to focus on producing and directing his other projects through Mark VII Limited. The first of these projects was a spinoff of Dragnet titled Adam-12, a 30-minute police procedural like its parent series, but focusing on patrol officers rather than detectives. The series premiered in the fall of 1968 and ran for seven seasons, coming to an end in 1975. Adam-12, in turn, spawned its own spinoff in early 1972 called Emergency!; running as a weekly series until 1977 and as a series of made-for-television movies for two years after that, Emergency! was centered around a fictitious Los Angeles County Fire Department paramedic rescue unit, Squad 51, the latter of which was a relatively new and different concept.

\n", "

Reruns of this version were popular on local stations, usually during the late afternoons or early evenings, in the early 1970s. In the late 1980s, they found their way to Nick at Nite and, beginning in the late 1990s, to sister cable channel TV Land. From October 1, 2011, to April 26, 2013, the series ran daily on digital cable channel Antenna TV and before that, the show aired on Retro Television Network.

\n", "

Dragnet currently airs Monday through Friday on Me-TV. The show is part of the \"CriMe TV\" morning block with Perry Mason and The Rockford Files, with Dragnet airing back to back from 11:00 am until 12:00 pm. In December 2014, Me-TV added a third airing of Dragnet to its late-night lineup; the series airs at 12:30 am following a second episode of Perry Mason. Me-TV ended the run of Dragnet on January 1, 2015, whereupon it became part of Cozi TV's regular lineup.

\n", "

All four seasons are available on DVD and for free on-demand streaming on Hulu.com and Netflix (until Summer 2015) for US residents.[citation needed]

\n", "

Later in Webb's career[edit]

\n", "

Webb had begun working on a revival of Dragnet in 1982, writing and producing five scripts and keeping his role as Joe Friday. Once again he needed to create a new character for Friday's partner; Ben Alexander had died in 1969 and Harry Morgan was tied up with his commitments to M*A*S*H and its already greenlit followup AfterMASH. Webb decided on Kent McCord, the former Adam-12 star who had several guest appearances early in the 1967 revival series, to fill the undefined role; no indication was given whether McCord would be playing a totally new character or his Jim Reed character from Adam-12. Webb died suddenly from a heart attack on December 23, 1982, and the revival was scrapped.

\n", "

After Webb's death, Chief Daryl Gates of the Los Angeles Police Department announced that badge number 714 — Webb's number on the television show — was retired, and Los Angeles city offices lowered their flags to half staff. At Webb's funeral, the LAPD provided an honor guard, and the Chief of Police commented on Webb's connection with the LAPD. An LAPD auditorium was named in his honor. Jack Webb's LAPD sergeant's badge and ID card are on display at the Los Angeles Police Academy.

\n", "

Film versions[edit]

\n", "

Dragnet (1954)[edit]

\n", "
Main article: Dragnet (1954 film)
\n", "

In 1954, a theatrical feature film entitled Dragnet, an adaptation of the series, was released with Webb, Alexander, and Richard Boone. Dennis Weaver plays R. A. Lohrman, a detective captain. The film begins with the shooting of small-time hood Miller Starkie (Dub Taylor) on orders from his boss, Max Troy (Stacy Harris). Friday's and Smith's superior is LAPD Intelligence Division Captain Jim Hamilton (Boone), a department member and the film's technical advisor. The Intelligence Division focused on the pursuit of organized-crime figures, and some of Max Troy's habits resemble that of Mickey Cohen, the known Los Angeles underworld boss; for example, Troy's LAPD file reads that he could be found at \"Sunset Strip taverns and joints,\" as could Cohen. The film depicts the working relationship between the LAPD and the Los Angeles County District Attorney's office; Friday and Smith work to gather evidence that the DA's office deems sufficient to gain the indictment and ultimate conviction of Troy and his fellows. One scene contains a violent fist-fight involving the two detectives, with the close-up cinematic technique typical of Webb's style of direction. The movie's ending represents a departure from most \"Dragnet' stories; no arrest is made at the story's conclusion. Chester Davitt (Willard Sage), Troy's underling and Starkie's killer, is killed by underworld figures, and Troy succumbs to cancer before the detectives, having gathered sufficient evidence against him, can make the arrest.

\n", "

The film earned an estimated $4.7 million at the North American box office during its first year of release.[3][4]

\n", "

Dragnet 1966 (aired 1969)[edit]

\n", "

Dragnet 1966 is a made-for-TV movie that initiated the return of the Dragnet series to television. It was intended as the TV pilot of Dragnet 1967 but was not aired as planned. It was eventually broadcast in 1969. The movie stars Jack Webb as Sgt. Friday and Harry Morgan as Officer Bill Gannon. The story focuses on crime more typical of the 1960s than of the previous Dragnet era; the detectives are assigned to find a voyeuristic serial killer similar to Harvey Glatman (played by Vic Perrin, who appeared in the 1954 film as an assistant district attorney). Also appearing is Virginia Gregg, who had a role in the 1954 feature and was a frequent guest actor in the 1951-59 series and the 1967-70 episodes, and John Roseboro, a catcher for the Los Angeles Dodgers who dabbled in acting in the off season; Roseboro played a plainclothes detective who had been the target of racial slurs by a child molester until Friday came to his aid.

\n", "

Dragnet (1987)[edit]

\n", "
Main article: Dragnet (1987 film)
\n", "

In 1987, a comedy movie version of Dragnet appeared starring Dan Aykroyd as the stiff Joe Friday (the original Detective Friday's nephew), and Tom Hanks as partner Pep Streebeck. The film contrasted the terse, clipped character of Friday, a hero from another age, with the 'real world' of Los Angeles in 1987 to broad comedic effect. Beyond Aykroyd's imitation of Webb's Joe Friday and Harry Morgan's small role reprising Bill Gannon, this film version shares little with previous incarnations. The film was more a parody, and a hit with audiences, though no follow-up films were produced. LAPD Lieutenant Dan Cooke, who had served as technical advisor for the Jack Webb series, was technical advisor for this production.

\n", "

Remakes after Webb's death[edit]

\n", "

1989 series: The New Dragnet[edit]

\n", "\n", "

The show returned to television in the fall of 1989 as The New Dragnet in first-run syndication, featuring new characters, and airing in tandem with The New Adam-12, a remake of another Webb-produced police drama, Adam-12. The New Dragnet starred Jeff Osterhage and Bernard White as the detectives, and Don Stroud as their captain. Fifty-two episodes were aired over two seasons. The first 26 episodes aired between October 24, 1989 and January 21, 1990, with the second season of 26 episodes, airing between April 19 and September 9, 1990.

\n", "

2003 series: L.A. Dragnet[edit]

\n", "\n", "

In 2003, a Dragnet series was produced by Dick Wolf, the producer of NBC's Law & Order series and spin-offs, in turn strongly influenced by Dragnet. It aired on ABC, and starred Ed O'Neill as Joe Friday and Ethan Embry as Frank Smith. After a 12-episode season that followed the traditional formula, the format of the series was changed to an ensemble crime drama in an attempt to boost ratings.

\n", "

Retitled L.A. Dragnet, Friday was promoted to Lieutenant with less screen time and Frank Smith was written out, in favor of younger and ethnically diverse cast played by Eva Longoria, Desmond Harrington, Evan Dexter Parke, and Christina Chang. Roselyn Sanchez was added to the regular cast, in a few episodes. With the Dragnet formula no longer in place, the program had the feel of a typical procedural drama. It was canceled five episodes into its second season. Three episodes premiered on USA Network in early 2004, with the final two on the Sleuth channel in 2006. In places such as the Netherlands, the show is retitled Murder Investigation.

\n", "

Related works[edit]

\n", "

Music[edit]

\n", "
Main article: Dragnet (theme music)
\n", "

The theme from Dragnet has been recorded by many artists, achieving popular success. Artists who charted with it include Ray Anthony (1953) and The Art of Noise (1987).

\n", "

Nonfiction[edit]

\n", "
    \n", "
  • In 1958, Webb authored a book titled The Badge, chapters of true stories told from the view of a patrolman, sergeant, lieutenant, and others. It had a number of photographs and recently was reissued with a foreword by James Ellroy, author of LA Confidential.
  • \n", "
\n", "

Parodies[edit]

\n", "
    \n", "
  • St. George and the Dragonet, a 1953 short audio satire by Stan Freberg, was a smash hit reaching #1 on both the Billboard and the Cash Box record charts. In this satire, Freberg used the line \"Just the facts, ma'am\", which entered popular lexicography as an actual catchphrase from Dragnet despite the line never being used on the show. Freberg followed St. George... with Little Blue Riding Hood and Christmas Dragnet.
  • \n", "
  • The 1954 Woody Woodpecker cartoon Under the Counter Spy was a parody of Dragnet. At the beginning, a narrator says, \"The story you are about to see is a big fat lie. No names have been changed to protect anybody!\" At the end, a hammer and stamp make the words \"THE END\", and the hammerer hits his thumb.
  • \n", "
  • The 1955 Three Stooges short film \"Blunder Boys\" parodies Dragnet. In place of the familiar \"Dragnet\" theme, the first four notes of \"The Song of the Volga Boatmen\", which is in the public domain, is used. At the end of the film, Moe stamps Larry's head with a hammer; Larry's forehead then reads, \"VII 1/2 The End\".
  • \n", "
  • A 1956 Looney Tunes short, Rocket Squad, starred Daffy Duck and Porky Pig as Sgt. Joe Monday and Det. Schmoe Tuesday, respectively. Daffy narrated, giving a running timeline in the manner of Sgt. Friday. This police adventure ends with both officers convicted and imprisoned for false arrest. The opening title reads: \"Ladies and Gentlemen, The story you are about to see is true. The drawings have been changed to protect the Innocent\". Another short Tree Cornered Tweety, featured Tweety imitating the narrator of Dragnet as he is being pursued by Sylvester again.
  • \n", "
  • A segment of the Rocky and Bullwinkle cartoon show called \"Bullwinkle's Corner\", which featured Bullwinkle Moose in a poetry reading of \"Tom, Tom the Piper's Son,\" parodied Dragnet as Bullwinkle is apprehended in the act of stealing a pig by two detectives who interrogate Bullwinkle using a terse, clipped monotone similar in style to Joe Friday and Frank Smith (\"You got a name?\" \"I'm Tom, Tom the Piper's Son.\" \"All right, Piperson, what were you going to do with the pig?\").
  • \n", "
  • In 1968, Jack Webb appeared in the \"Copper Clapper Caper\" sketch on The Tonight Show Starring Johnny Carson, playing the poker-faced Joe Friday interviewing the equally deadpan victim of a robbery (played by Carson). The details of the crime started with the alliterative \"k\" or \"kl\" consonant sound, such as \"Claude Cooper, the kleptomaniac from Cleveland.\"[5]
  • \n", "
  • The final segment of each episode of PBS's Square One was titled Mathnet and opened with the Dragnet theme and an arrangement of the lines \"The story you're about to see is a fib — but it's short. The names are made up, but the problems are real.\" Each story arc of the show's five-season run lasted five daily episodes (one week) and featured detectives Kate Monday (seasons 1–3) or Pat Tuesday (seasons 4–5) and George Ernest Frankly (all five seasons), of the LAPD in the first two of the show's five seasons and the New York Police Department in the last three seasons, using mathematics to solve crimes.
  • \n", "
  • In 1983, \"Prog #310\" of UK sci-fi comic 2000AD featured a time-travelling parody of Dragnet in the story \"Chrono Cops\", written by Alan Moore and illustrated by Dave Gibbons. In five pages, \"Joe Saturday\" and \"Ed Thursday\" encounter several time-travel \"tropes\", including a character attempting to kill his own great-grandfather.[6]
  • \n", "
  • November 19, 1995 The Simpsons episode \"Mother Simpson\" has Homer Simpson's mother, Mona Simpson, as a fugitive from Charles Montgomery Burns, who is about to be captured after 27 years. Burns is helped by officers Joe Friday and Bill Gannon (voiced by Harry Morgan).
  • \n", "
  • Dragnet is parodied at the end of the episode of The New Adventures of Winnie-the-Pooh entitled: Sorry, Wrong Slusher. Winnie-the-Pooh performs a closing narration as a mug shot of Christopher Robin is shown on screen, in the style of Dragnet.
  • \n", "
  • Craig Lancaster's novel 600 Hours of Edward features a title character with Asperger's syndrome who watches Dragnet religiously every day and relates much of his life back to it. Dragnet is also mentioned in the sequel Edward Adrift.
  • \n", "
\n", "

DVD releases[edit]

\n", "

Original series (1951–59)[edit]

\n", "

Most, if not all, episodes of this series are in the public domain, and 52 episodes were released by many DVD labels.These collections feature a variety of the same 52 episodes. These include \"The Human Bomb\", \"The Big Actor\", \"The Big Mother\", \"The Big Cast\", \"The Big September Man\", \"The Big Phone Call\", \"The Big Casing\", \"The Big Lamp\", \"The Big Seventeen\", \"A .22 Caliber Rifle For Christmas\", \"The Big Grandma\", \"The Big Show\", \"The Big Break\", \"The Big Frank\", \"The Big Hands\", \"The Big Barrette\", \"The Big Dance\", \"The Big Betty\", \"The Big Will\", \"The Big Thief\", \"The Big Little Jesus\", \"The Big Trunk\", \"The Big Boys\", \"The Big Children\", \"The Big Winchester\", \"The Big Shoplift\", \"The Big Hit & Run Killer\", \"The Big Girl\", \"The Big Frame\", \"The Big False Make\", \"The Big Producer\", \"The Big Fraud\", \"The Big Crime\", \"The Big Pair\", \"The Big Missing\", \"The Big Bar\", \"The Big Present\", \"The Big New Year\", \"The Big Rod\", \"The Big Lift\", \"The Big Gap\", \"The Big Look\", \"The Big Glasses\", \"The Big Bird\", \"the Big Smoke\", \"The Big Bounce\", \"The Big Deal\", \"The Big Hat\", \"The Big Net\", \"The Big War\", \"The Big Oskar\", and \"The Big Counterfeit\". Often some are mislabeled as no onscreen titles are used.

\n", "

Three collections released from Alpha Video feature four episodes each. Eclectic DVD released a collection of three episodes.

\n", "

Platinum Video released seven episodes from the original series in 2002. The episodes are: \"Big Crime\", \"Big Pair\", \"Big Producer\", \"Big Break\", \"Big September Man\", \"Big Betty\", and \"Big Trunk\". The two-disc set includes episodes from Burke's Law, Peter Gunn, Richard Diamond, Private Detective, Mr. Wong, Detective, and Bulldog Drummond.

\n", "

Dragnet feature film (1954)[edit]

\n", "

This movie was released on DVD in 2009 as part of Universal Studios' \"Vault Series\".

\n", "

Dragnet pilot movie (1966)[edit]

\n", "

This movie is a bonus feature on Shout! Factory's \"Dragnet 1968: Season Two\" (Release Date: July 6, 2010).

\n", "

Dragnet (1967–70)[edit]

\n", "

On June 7, 2005, Universal Studios Home Entertainment released the first season on DVD in Region 1. Because sales numbers did not meet Universal's expectations, no plans were made to release the remaining three seasons.

\n", "

On March 17, 2010, Shout! Factory acquired the rights to distribute the series (under license from Universal). They released seasons 2-4.

\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
DVD NameEp #Release Date
Season 1[7]17June 7, 2005
Season 2[8]28July 6, 2010
Season 3[9]27December 7, 2010
Season 4[10]26April 12, 2011
\n", "

The New Dragnet (1989)[edit]

\n", "

No DVD releases to date of this remake that lasted two seasons.

\n", "

L.A. Dragnet (2003)[edit]

\n", "

Universal Studios Home Entertainment was going to release the first season of this short-lived remake on DVD on November 11, 2003, but this release was cancelled. It is not known if the set will be released,[11] though it is available for viewing on Hulu.

\n", "

References[edit]

\n", "
\n", "
    \n", "
  1. ^ On a March, 1953 episode, the Detroit Police Officers' Association gave Dragnet a commendation, citing the program's efforts at increasing public esteem of policemen, and furthermore describing Dragnet as the \"finest and most accurate\" police program on radio or television.
  2. \n", "
  3. ^ Snauffer, Douglas (2006). Crime Television, The Praeger television collection. Greenwood Publishing Group. ISBN 978-0275988074. 
  4. \n", "
  5. ^ 'The Top Box-Office Hits of 1954', Variety Weekly, January 5, 1955
  6. \n", "
  7. ^ TCM.com
  8. \n", "
  9. ^ Funniest Moments: Copper Clapper Caper On Johnny Carson's Tonight Show. YouTube (official channel). August 27, 2012. Retrieved October 19, 2014. 
  10. \n", "
  11. ^ Againwiththecomics.com
  12. \n", "
  13. ^ DVD Empire
  14. \n", "
  15. ^ DVD Empire
  16. \n", "
  17. ^ DVD Empire
  18. \n", "
  19. ^ DVD Empire
  20. \n", "
  21. ^ Dragnet DVD news: Dragnet (2003) DVD Cancelled | TVShowsOnDVD.com
  22. \n", "
\n", "
\n", "

Sources[edit]

\n", "
    \n", "
  • Dunning, John, On The Air: The Encyclopedia of Old-Time Radio, Oxford University Press, 1998, ISBN 0-19-507678-8.
  • \n", "
  • Michael J. Hayde, My Name's Friday: The Unauthorized but True Story of Dragnet and the Films of Jack Webb, Cumberland House, 2001, ISBN 1-58182-190-5
  • \n", "
  • Jason Mittell, Genre and Television: From Cop Shows to Cartoons in American Culture. Routledge, 2004, ISBN 0-415-96903-4.
  • \n", "
\n", "

External links[edit]

\n", "\n", "\n", "\n", "\n", "\n", "
\"\"Wikimedia Commons has media related to Dragnet (series).
\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\t\t\t\t\t\n", "\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t
\n", "\t\t\t

Navigation menu

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t

Personal tools

\n", "\t\t\t\t\t\t\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t

Namespaces

\n", "\t\t\t\t\t\t
    \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
  • Article
  • \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
  • Talk
  • \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t\t\t

\n", "\t\t\t\t\t\t\tVariants\n", "\t\t\t\t\t\t

\n", "\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t
    \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t

Views

\n", "\t\t\t\t\t\t
    \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
  • Read
  • \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
  • Edit
  • \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
  • View history
  • \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t

More

\n", "\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t
    \n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t

\n", "\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t

\n", "\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\n", "\t\t\t\t\t\t
\n", "\t\t\t\t\t
\n", "\t\t\t\t\t\t\t\t\t
\n", "\t\t\t
\n", "\t\t\t
\n", "\t\t\t\t
\n", "\t\t\t\t\t\t
\n", "\t\t\t

Navigation

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\t
\n", "\t\t\t

Interaction

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\t
\n", "\t\t\t

Tools

\n", "\n", "\t\t\t\n", "\t\t
\n", "\t\t\t
\n", "\t\t\t

Print/export

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\t
\n", "\t\t\t

In other projects

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\t
\n", "\t\t\t

Languages

\n", "\n", "\t\t\t
\n", "\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\t\t
\n", "\t\t
\n", "\t\t
\n", "\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t\t\t\t\t\n", "\t\t\t\t\t\t
\n", "\t\t
\n", "\t\t\n", "\t\n", "\n", "\n" ] } ], "source": [ "with open(os.path.join(\"wiki\", file_names[0])) as f:\n", " print(f.read())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Adding the MapReduce function to this project\n", "\n", "We start by adding the MapReduce function so that we can use throughout the project." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import math\n", "import functools\n", "from multiprocessing import Pool\n", "\n", "def make_chunks(data, num_chunks):\n", " chunk_size = math.ceil(len(data) / num_chunks)\n", " return [data[i:i+chunk_size] for i in range(0, len(data), chunk_size)]\n", "\n", "def map_reduce(data, num_processes, mapper, reducer):\n", " chunks = make_chunks(data, num_processes)\n", " pool = Pool(num_processes)\n", " chunk_results = pool.map(mapper, chunks)\n", " pool.close()\n", " pool.join()\n", " return functools.reduce(reducer, chunk_results)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Counting the total number of lines on all files\n", "\n", "It was not required but can use MapReduce to count the total number of lines on all files in the wiki folder! If you did in some other way, that is fine as well." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "499797" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def map_line_count(file_names):\n", " total = 0\n", " for fn in file_names:\n", " with open(os.path.join(\"wiki\", fn)) as f:\n", " total += len(f.readlines())\n", " return total\n", " \n", "def reduce_line_count(count1, count2):\n", " return count1 + count2\n", "\n", "target = \"data\"\n", "map_reduce(file_names, 8, map_line_count, reduce_line_count)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Grep string function\n", "\n", "We defined a `mapreduce_grep_string()` function that takes two arguments as input:\n", "\n", "1. A path to a folder. In the case of this guided project we will only use it on the `wiki` folder but having this argument makes the function easier to reuse.\n", "\n", "2. The string that we want to find.\n", "\n", "The mapper function receives a chunk of filenames and calculates all occurrences of the target string on them. If a file contains no occurrences, we chose to not include an entry for that file in the result dictionary.\n", "\n", "The reducer function uses the `dict.update()` method to merge the result dictionaries.\n", "\n", "Note that the `target` variable will be defined outside and will be the string we are looking for." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# The target variable is defined outside and contains the string \n", "def map_grep(file_names):\n", " results = {}\n", " for fn in file_names:\n", " with open(fn) as f:\n", " lines = [line for line in f.readlines()]\n", " for line_index, line in enumerate(lines):\n", " if target in line:\n", " if fn not in results:\n", " results[fn] = []\n", " results[fn].append(line_index)\n", " return results\n", "\n", "def reduce_grep(lines1, lines2):\n", " lines1.update(lines2)\n", " return lines1\n", "\n", "def mapreduce_grep(path, num_processes):\n", " file_names = [os.path.join(path, fn) for fn in os.listdir(path)]\n", " return map_reduce(file_names, num_processes, map_grep, reduce_grep)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding the occurences of \"data\"" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": false }, "outputs": [], "source": [ "target = \"data\"\n", "data_occurrences = mapreduce_grep(\"wiki\", 8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Allow for case insensitive matches\n", "\n", "We can allow case insensitive matches by converting both the target and the file contents to lowercase before we match." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "def map_grep_insensitive(file_names):\n", " results = {}\n", " for fn in file_names:\n", " with open(fn) as f:\n", " lines = [line.lower() for line in f.readlines()]\n", " for line_index, line in enumerate(lines):\n", " if target.lower() in line:\n", " if fn not in results:\n", " results[fn] = []\n", " results[fn].append(line_index)\n", " return results\n", "\n", "def mapreduce_grep_insensitive(path, num_processes):\n", " file_names = [os.path.join(path, fn) for fn in os.listdir(path)]\n", " return map_reduce(file_names, num_processes, map_grep_insensitive, reduce_grep)\n", "\n", "target = \"data\"\n", "new_data_occurrences = mapreduce_grep_insensitive(\"wiki\", 8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Checking that we find more matches\n", "\n", "We already stored the results into variables `data_occurrences` and `new_data_occurrences`. To check that we find more matches with the second version of the algorithm, we can loop over the file names and print the length difference between the results." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Found 6 new matches on file wiki/Dragnet_(franchise).html\n", "Found 1 new matches on file wiki/Jazz_in_Turkey.html\n", "Found 2 new matches on file wiki/Kate_Harwood.html\n", "Found 1 new matches on file wiki/Rally_for_Democracy_and_Progress_(Benin).html\n", "Found 1 new matches on file wiki/Morning_Glory_(2010_film).html\n", "Found 2 new matches on file wiki/Jules_Verne_ATV.html\n", "Found 1 new matches on file wiki/Claudia_Neidig.html\n", "Found 2 new matches on file wiki/Gordon_Bau.html\n", "Found 1 new matches on file wiki/Colchester_Village_Historic_District.html\n", "Found 1 new matches on file wiki/Sahanpur.html\n", "Found 1 new matches on file wiki/Harry_Hill_Bandholtz.html\n", "Found 1 new matches on file wiki/Morgana_King.html\n", "Found 1 new matches on file wiki/Nuno_Leal_Maia.html\n", "Found 1 new matches on file wiki/Alex_Kurtzman.html\n", "Found 1 new matches on file wiki/Camp_Nelson_Confederate_Cemetery.html\n", "Found 1 new matches on file wiki/Dewoitine_D.21.html\n", "Found 1 new matches on file wiki/WLSR.html\n", "Found 7 new matches on file wiki/List_of_people_from_Bangor,_Maine.html\n", "Found 1 new matches on file wiki/Qalat_Kat.html\n", "Found 1 new matches on file wiki/83_(number).html\n", "Found 1 new matches on file wiki/Typhoon_Hester_(1952).html\n", "Found 1 new matches on file wiki/Salem-Auburn_Streets_Historic_District.html\n", "Found 1 new matches on file wiki/Copamyntis_infusella.html\n", "Found 1 new matches on file wiki/Syngenor.html\n", "Found 2 new matches on file wiki/Kim_Yong-hwa.html\n", "Found 1 new matches on file wiki/Failing_Office_Building.html\n", "Found 1 new matches on file wiki/Westchester,_Los_Angeles.html\n", "Found 1 new matches on file wiki/Blue_SWAT.html\n", "Found 1 new matches on file wiki/Bahmanabad-e_Olya.html\n", "Found 3 new matches on file wiki/Maniitsoq_structure.html\n", "Found 1 new matches on file wiki/Functoid.html\n", "Found 1 new matches on file wiki/Teiji_Ito.html\n", "Found 1 new matches on file wiki/Pictogram.html\n", "Found 1 new matches on file wiki/Kattukukke.html\n", "Found 1 new matches on file wiki/Devil_on_Horseback.html\n", "Found 1 new matches on file wiki/Saravan,_Gilan.html\n", "Found 1 new matches on file wiki/KMTZ.html\n", "Found 4 new matches on file wiki/List_of_molecular_graphics_systems.html\n", "Found 1 new matches on file wiki/Dean_Kukan.html\n", "Found 1 new matches on file wiki/L._Fry.html\n", "Found 3 new matches on file wiki/Code_page_1023.html\n", "Found 1 new matches on file wiki/Hayateumi_Hidehito.html\n", "Found 1 new matches on file wiki/Jack_Goes_Home.html\n", "Found 1 new matches on file wiki/Meleh_Kabud-e_Sofla.html\n", "Found 2 new matches on file wiki/Taipa_Houses%E2%80%93Museum.html\n", "Found 1 new matches on file wiki/Cryptographic_primitive.html\n", "Found 2 new matches on file wiki/Precorrin-6A_reductase.html\n", "Found 1 new matches on file wiki/Curtiss-Wright_Hangar_(Columbia,_South_Carolina).html\n", "Found 1 new matches on file wiki/Battle_of_Wattignies.html\n", "Found 1 new matches on file wiki/Acceptance_(Heroes).html\n", "Found 1 new matches on file wiki/Benny_Lee.html\n", "Found 1 new matches on file wiki/Medicago_murex.html\n", "Found 1 new matches on file wiki/Companys,_proc%C3%A9s_a_Catalunya.html\n", "Found 1 new matches on file wiki/Shabbir_Kumar.html\n", "Found 1 new matches on file wiki/Oldfield_Baby_Great_Lakes.html\n", "Found 1 new matches on file wiki/Old_Mill_Creek,_Illinois.html\n", "Found 1 new matches on file wiki/Avengers_Academy.html\n", "Found 2 new matches on file wiki/Agaritine_gamma-glutamyltransferase.html\n", "Found 1 new matches on file wiki/Amborella.html\n", "Found 1 new matches on file wiki/Swathi_Chinukulu.html\n", "Found 1 new matches on file wiki/Derek_Acorah.html\n", "Found 1 new matches on file wiki/Ek_Dil_Sau_Afsane.html\n", "Found 1 new matches on file wiki/Holly_Golightly_(comics).html\n", "Found 1 new matches on file wiki/Golabkhvaran.html\n", "Found 1 new matches on file wiki/Antibiotic_use_in_livestock.html\n", "Found 1 new matches on file wiki/Lower_Blackburn_Grade_Bridge.html\n", "Found 1 new matches on file wiki/Roxbury_Presbyterian_Church.html\n", "Found 1 new matches on file wiki/Imperial_Venus_(film).html\n", "Found 1 new matches on file wiki/Demographics_of_American_Samoa.html\n", "Found 1 new matches on file wiki/The_Future_(film).html\n", "Found 1 new matches on file wiki/Weiser_River.html\n", "Found 1 new matches on file wiki/Bias.html\n", "Found 1 new matches on file wiki/The_Gentleman_Without_a_Residence_(1915_film).html\n", "Found 1 new matches on file wiki/Vojin_%C4%86etkovi%C4%87.html\n", "Found 1 new matches on file wiki/Danish_Maritime_Safety_Administration.html\n", "Found 1 new matches on file wiki/Gulliver_Mickey.html\n", "Found 1 new matches on file wiki/Cobble_Hill,_Brooklyn.html\n", "Found 1 new matches on file wiki/Filip_Pyrochta.html\n", "Found 1 new matches on file wiki/List_of_Uzbek_films_of_2014.html\n", "Found 1 new matches on file wiki/Furto_di_sera_bel_colpo_si_spera.html\n", "Found 1 new matches on file wiki/Craig_Chester.html\n", "Found 1 new matches on file wiki/%C3%89cole_des_Mines_de_Douai.html\n", "Found 1 new matches on file wiki/Taylor_Williamson.html\n", "Found 1 new matches on file wiki/Jonathan_A._Goldstein.html\n", "Found 1 new matches on file wiki/Ordinary,_Virginia.html\n", "Found 1 new matches on file wiki/Smilax_laurifolia.html\n", "Found 1 new matches on file wiki/Don_Parsons_(ice_hockey).html\n", "Found 1 new matches on file wiki/Daniel_Cerone.html\n", "Found 1 new matches on file wiki/Sol_Eclipse.html\n", "Found 1 new matches on file wiki/1953%E2%80%9354_FA_Cup_qualifying_rounds.html\n", "Found 2 new matches on file wiki/Viva_Villa!.html\n", "Found 1 new matches on file wiki/King_Parker_House.html\n", "Found 1 new matches on file wiki/Pushkar.html\n", "Found 1 new matches on file wiki/Manhattan_Murder_Mystery.html\n", "Found 1 new matches on file wiki/Appa_(film).html\n", "Found 1 new matches on file wiki/Panchamrutham.html\n", "Found 1 new matches on file wiki/Table_Point_Formation.html\n", "Found 2 new matches on file wiki/Claire_Danes.html\n", "Found 1 new matches on file wiki/HD_90156.html\n", "Found 1 new matches on file wiki/West_Park_Bridge.html\n", "Found 1 new matches on file wiki/Urs_Burkart.html\n", "Found 1 new matches on file wiki/Embraer_Unidade_Gavi%C3%A3o_Peixoto_Airport.html\n", "Found 1 new matches on file wiki/Shoreyjeh-ye_Do.html\n", "Found 1 new matches on file wiki/Kokan_Colony.html\n", "Found 1 new matches on file wiki/PTPRS.html\n", "Found 1 new matches on file wiki/Don_Raye.html\n", "Found 1 new matches on file wiki/Peter_Collingwood.html\n", "Found 1 new matches on file wiki/Rudy:_The_Rudy_Giuliani_Story.html\n", "Found 2 new matches on file wiki/Shpolskii_matrix.html\n", "Found 1 new matches on file wiki/Doumanaba.html\n", "Found 1 new matches on file wiki/Lis_L%C3%B8wert.html\n", "Found 1 new matches on file wiki/Kul_Gul.html\n", "Found 1 new matches on file wiki/Bibiana_Beglau.html\n", "Found 1 new matches on file wiki/Wilhelm_Wagenfeld_House.html\n", "Found 1 new matches on file wiki/Tim_Spencer_(singer).html\n", "Found 1 new matches on file wiki/Mudramothiram.html\n", "Found 2 new matches on file wiki/The_Audacity_to_Podcast.html\n", "Found 1 new matches on file wiki/Lake_County_Examiner.html\n", "Found 1 new matches on file wiki/Ingrid_Guimar%C3%A3es.html\n", "Found 1 new matches on file wiki/Frost_Township,_Michigan.html\n", "Found 1 new matches on file wiki/Jon_Mullich.html\n", "Found 2 new matches on file wiki/List_of_Spaghetti_Western_films.html\n", "Found 1 new matches on file wiki/Julien_Boisselier.html\n", "Found 1 new matches on file wiki/Exploratorium_(film).html\n", "Found 1 new matches on file wiki/Mirisah.html\n", "Found 1 new matches on file wiki/Foulonia.html\n", "Found 1 new matches on file wiki/Tropical_sprue.html\n", "Found 1 new matches on file wiki/A_Beautiful_Valley.html\n", "Found 1 new matches on file wiki/C11orf30.html\n", "Found 1 new matches on file wiki/Wilson_Global_Explorer.html\n", "Found 1 new matches on file wiki/Winters-Wimberley_House.html\n", "Found 1 new matches on file wiki/Boardman_Township,_Mahoning_County,_Ohio.html\n", "Found 2 new matches on file wiki/Tomohiko_It%C5%8D_(director).html\n", "Found 1 new matches on file wiki/Brownfield_(software_development).html\n" ] } ], "source": [ "for fn in new_data_occurrences:\n", " if fn not in data_occurrences:\n", " print(\"Found {} new matches on file {}\".format(len(new_data_occurrences[fn]), fn))\n", " elif len(new_data_occurrences[fn]) > len(data_occurrences[fn]):\n", " print(\"Found {} new matches on file {}\".format(len(new_data_occurrences[fn]) - len(data_occurrences[fn]), fn))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding match indexes on lines\n", "\n", "We need to solve a subproblem before we implement this one: Given a string and a target, find all occurrences of the target within that string." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0, 27, 65]\n" ] } ], "source": [ "def find_match_indexes(line, target):\n", " results = []\n", " i = line.find(target, 0)\n", " while i != -1:\n", " results.append(i)\n", " i = line.find(target, i + 1)\n", " return results\n", "\n", "# Test implementation\n", "s = \"Data science is related to data mining, machine learning and big data.\".lower()\n", "print(find_match_indexes(s, \"data\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding all match locations\n", "\n", "We can use any of the above functions to find all match locations. We will use the third one.\n", "\n", "After finding all indexes in one line, we need to create pairs by adding the line index." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def map_grep_match_indexes(file_names):\n", " results = {}\n", " for fn in file_names:\n", " with open(fn) as f:\n", " lines = [line.lower() for line in f.readlines()]\n", " for line_index, line in enumerate(lines):\n", " match_indexes = find_match_indexes(line, target.lower())\n", " if fn not in results:\n", " results[fn] = []\n", " results[fn] += [(line_index, match_index) for match_index in match_indexes]\n", " return results\n", "\n", "def mapreduce_grep_match_indexes(path, num_processes):\n", " file_names = [os.path.join(path, fn) for fn in os.listdir(path)]\n", " return map_reduce(file_names, num_processes, map_grep_match_indexes, reduce_grep)\n", "\n", "target = \"science\"\n", "occurrences = mapreduce_grep_match_indexes(\"wiki\", 8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Displaying the results\n", "\n", "Let's display the results. We will create a CSV file listing all occurrences. We will also show the text around each occurrence." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "import csv\n", "\n", "# How many character to show before and after the match\n", "context_delta = 30\n", "\n", "with open(\"results.csv\", \"w\") as f:\n", " writer = csv.writer(f)\n", " rows = [[\"File\", \"Line\", \"Index\", \"Context\"]]\n", " for fn in occurrences:\n", " with open(fn) as f:\n", " lines = [line.strip() for line in f.readlines()]\n", " for line, index in occurrences[fn]:\n", " start = max(index - context_delta, 0)\n", " end = index + len(target) + context_delta\n", " rows.append([fn, line, index, lines[line][start:end]])\n", " writer.writerows(rows)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
FileLineIndexContext
0wiki/Rally_for_Democracy_and_Progress_(Benin)....15540f=\"/wiki/Outline_of_political_science#Politics...
1wiki/Rally_for_Democracy_and_Progress_(Benin)....15596\" title=\"Outline of political science\">Other c...
2wiki/Jules_Verne_ATV.html208507century French <a href=\"/wiki/Science-fiction\"...
3wiki/Jules_Verne_ATV.html208551n\" class=\"mw-redirect\" title=\"Science-fiction\"...
4wiki/Jules_Verne_ATV.html208568rect\" title=\"Science-fiction\">science-fiction<...
5wiki/Jules_Verne_ATV.html427231text\" href=\"http://www.futura-sciences.com/fr/...
6wiki/Jules_Verne_ATV.html427427nnés\"</a> (in French). Futura Sciences<span cl...
7wiki/Jules_Verne_ATV.html427831ft_id=http%3A%2F%2Fwww.futura-sciences.com%2Ff...
8wiki/Jules_Verne_ATV.html42797115986-1%2F&amp;rft.pub=Futura+Sciences&amp;rft...
9wiki/Jules_Verne_ATV.html94160ogramme_for_Life_and_Physical_Sciences_in_Spac...
\n", "
" ], "text/plain": [ " File Line Index \\\n", "0 wiki/Rally_for_Democracy_and_Progress_(Benin).... 155 40 \n", "1 wiki/Rally_for_Democracy_and_Progress_(Benin).... 155 96 \n", "2 wiki/Jules_Verne_ATV.html 208 507 \n", "3 wiki/Jules_Verne_ATV.html 208 551 \n", "4 wiki/Jules_Verne_ATV.html 208 568 \n", "5 wiki/Jules_Verne_ATV.html 427 231 \n", "6 wiki/Jules_Verne_ATV.html 427 427 \n", "7 wiki/Jules_Verne_ATV.html 427 831 \n", "8 wiki/Jules_Verne_ATV.html 427 971 \n", "9 wiki/Jules_Verne_ATV.html 941 60 \n", "\n", " Context \n", "0 f=\"/wiki/Outline_of_political_science#Politics... \n", "1 \" title=\"Outline of political science\">Other c... \n", "2 century French science-fiction<... \n", "5 text\" href=\"http://www.futura-sciences.com/fr/... \n", "6 nnés\" (in French). Futura Sciences