Walter welcomes\r\n          Davis up to The Head Table podium.\r\n                         \r\n                                                   WALTER\r\n                        Please everyone rise as The Grand\r\n                        Wizard leads us in a toast.\r\n                         \r\n          Davis steps to the podium raising his glass.\r\n                         \r\n                                                   DEVIN DAVIS\r\n                        Look around, today we are privileged\r\n                        to be among


to be among White Men such as\r\n                        yourselves, Real Warriors for The\r\n                        Real America, the One Our Ancestors\r\n                        Fought and Died for.\r\n                         \r\n          Everyone\'s face in the room brightens as Davis fills them all\r\n          with inspiration.\r\n                         \r\n                                    DEVIN DAVIS (CONT\'D)\r\n                        We are the True White American Race\r\n                        the Backbone from whence came Our\r\n


Great Southern Heritage. To the USA!\r\n                         \r\n          Everyone in the Hall shouts: TO THE USA! Everyone stands,\r\n          hoisting their glasses upward. Ron can see Holsters-- on\r\n          Belts, on Legs, on Ankles.\r\n                         \r\n          Ron\'s mouth goes agape realizing Everyone in the Room is\r\n          Armed.\r\n                         \r\n          Devin Davis at the Banquet table shoves a forkful of Prime\r\n          Rib into his mouth as he chats casually with Walter and\r\n          Jesse.\r\n                         \r\n          Felix and Connie


\r\n          Felix and Connie sit near The Head Table, eating. Flip sits\r\n          on the opposite end. Ron watches as Connie rises from her\r\n          seat. She leans down giving Felix a peck on his Cheek.\r\n                         \r\n          CLOSE - RON\'S POV - CONNIE\r\n                         \r\n          leaves the banquet hall and Ron watches her go out the front\r\n          door. Felix goes over to Davis, leaning down to greet him.\r\n                         \r\n                                                   FELIX\r\n                        I just want to say how Honored I


I just want to say how Honored I am\r\n                        to be in your presence.\r\n                         \r\n          They shake hands in the traditional Klan manner.\r\n                                     DEVIN DAVIS\r\n          The Honor is Mine.\r\n          CLOSE - WALKER\r\n                         \r\n          walks through the maze of tables with his second helping of\r\n          food when he notices...\r\n                         \r\n          CLOSE - WALKER\'S POV - FLIP\r\n                         \r\n          talking at the table with Walter and Davis. Flip is


at the table with Walter and Davis. Flip is very\r\n          chummy laughing and telling stories with them like old\r\n          friends.\r\n                         \r\n          Walker stares hard at Flip like he\'s trying to place him. He\r\n          sits next to Felix, still staring at Flip. Walker nods to\r\n          himself, speaking quietly.\r\n                         \r\n                                                     WALKER\r\n                       He\'s a Cop.\r\n                         \r\n                                                     FELIX\r\n


FELIX\r\n                       Who?\r\n                         \r\n                                                     WALKER\r\n                       That Guy.\r\n                         \r\n          Felix looks at Flip.\r\n                         \r\n                                                     FELIX\r\n                       Ron?\r\n                         \r\n


WALKER\r\n                       No, the other Guy.\r\n                         \r\n          Walker is talking about Flip too.\r\n                         \r\n                                                     FELIX\r\n                       Ron\'s a Cop?\r\n                         \r\n                                                  WALKER\r\n                       No, his name is Phillip but his\r\n                       nickname is Flip.\r\n


\r\n                                                  FELIX\r\n                       Who\'s Phillip?\r\n                         \r\n          Walker looks at Flip as he speaks to Davis.\r\n                         \r\n                                                  WALKER\r\n                       Who\'s Ron, that\'s Phillip.\r\n                         \r\n                                                  FELIX\r\n                       What the


What the Fuck are you talking about?\r\n                                                  WALKER\r\n                       That guy was the Cop that sent me\r\n                       away to Prison for Armed Fucking\r\n                       Robbery.\r\n                         \r\n          Flip eating with Davis.\r\n                                   WALKER (O.S.)\r\n                       His name is Phillip... Phillip\r\n                       Zimmerman.\r\n                         \r\n          Felix is


\r\n          Felix is shocked.\r\n                         \r\n                                                  FELIX\r\n                       What!\r\n                         \r\n                                                  WALKER\r\n                       Yeah, he\'s a Fuckin\' Pig.\r\n                         \r\n                                                  FELIX\r\n                       What\'s his name?\r\n                         \r\n


\r\n                                                  WALKER\r\n                       Phillip Zimmerman.\r\n                         \r\n                                                  FELIX\r\n                       Isn\'t that a Jew name?\r\n                         \r\n                                                  WALKER\r\n                       I don\'t know... probably.\r\n                         \r\n


FELIX\r\n                       So Ron Stallworth is a Fucking Jew.\r\n                         \r\n                                                  WALKER\r\n                       Coulda\' been worse.\r\n                         \r\n          Felix looks at him.\r\n                         \r\n                                                  WALKER (CONT\'D)\r\n                       Coulda\' been a Nigger.\r\n


\r\n          Felix thinks to himself, then looks over at\r\n                         \r\n                         RON\r\n                         \r\n          who is standing not far away from Devin Davis. Ron is\r\n                         WATCHING\r\n                         \r\n                         FELIX\r\n                         \r\n          and Walker focusing on Flip. The Two, Ron and Felix, share a\r\n          long uncomfortable stare. Felix has figured it all out.\r\n                         \r\n


\r\n                                                  FELIX\r\n                       He\'s a Nigger.\r\n                         \r\n          Walker turns to Felix.\r\n                         \r\n                                                  FELIX (CONT\'D)\r\n                       That Cop guarding Davis. Zimmerman is\r\n                       using his name.\r\n                                                    WALKER\r\n                         Let\'s tell Davis.\r\n


Let\'s tell Davis.\r\n                         \r\n          Walker starts to rise, Felix lowers him back.\r\n                         \r\n                                                    FELIX\r\n                         Not now, I\'ll find the moment.\r\n                         \r\n          Felix turns to Connie, whispering, they all then rise. Ron\r\n          knows something is askew. He gives Flip a look. Flip sees it\r\n          as Ron walks over to Davis.\r\n                         \r\n


RON STALLWORTH\r\n                         ...Mr. Davis, a favor to ask.\r\n                         Nobody\'s gonna believe me when I tell\r\n                         them I was your Bodyguard.\r\n                         \r\n          Ron holds up a Polaroid Camera.\r\n                         \r\n                                     RON STALLWORTH (CONT\'D)\r\n                         Care to take a Photo with me?\r\n                         \r\n          Davis laughs, looking around the table.\r\n


table.\r\n                         \r\n                                                    DEVIN DAVIS\r\n                         I don\'t see any harm in that. Hey\r\n                         Jesse... why don\'t you get in here\r\n                         too?\r\n                         \r\n          Jesse Nayyar, equally amused, walks over. Flip is already out\r\n          of his Seat, walking to Ron. Ron glances over seeing\r\n                         \r\n          FELIX, WALKER AND CONNIE AT THE BACK DOOR (RON\'S POV)\r\n


\r\n          Connie has her purse and Walker hands her a gym bag. Felix\r\n          pecks her on the lips. She exits the steakhouse with the gym\r\n          bag.\r\n                         \r\n          CLOSE - RON\r\n                         \r\n          then turns to Flip.\r\n                         \r\n                                                    RON STALLWORTH\r\n                         You mind taking it, Sir?\r\n                         \r\n          ANGLE - ROOM\r\n


\r\n          Flip nods and Ron hands him The Polaroid Camera.\r\n                         \r\n          Ron walks back and stands in between Davis, THE GRAND WIZARD\r\n          and Jesse, THE GRAND DRAGON.\r\n                                                  RON (CONT\'D)\r\n                       One... Two... Three!\r\n                         \r\n          Right as the Camera Flashes, Ron drapes his arms around both\r\n          Davis and Jesse, pulling them in real close. The Polaroid\r\n          clicks and spits out the Photo instantly.\r\n                         \r\n


\r\n          Davis is startled for a brief second... then it all happens\r\n          in a FLASH.\r\n                         \r\n          Davis and Ron spring toward Flip, each making a Mad Dash for\r\n          the Photo. Ron grabs it first. Davis lunges to grab the Photo\r\n          from Ron\'s hands but Ron yanks it away. Davis is up in Ron\'s\r\n          Face.\r\n                         \r\n                                                  DEVIN DAVIS\r\n                       Nigger, What the Fuck did you just\r\n                       do?\r\n


\r\n                                                  RON STALLWORTH\r\n                       If you lay one Finger on me, I\'ll\r\n                       arrest you for assaulting a Police\r\n                       Officer. That\'s worth about Five\r\n                       Years in Prison. Try me. See if I\'m\r\n                       playing.\r\n                         \r\n          The Room falls into Dead Silence. Klansmen mouths hang open,\r\n          watching their Leaders threatened by a DETECTIVE NIGGER.\r\n          Davis gives Ron the most vicious look


Davis gives Ron the most vicious look imaginable.\r\n                         \r\n          Ron stares back. It\'s a SHOWDOWN. Several Men in the Room\r\n          have their hands at their Waists, seconds away from drawing\r\n          their Guns.\r\n                         \r\n          Ron can do only one thing: he smiles.\r\n                         \r\n                                   RON STALLWORTH (CONT\'D)\r\n                       Thanks for the Photo, Mr. Davis. Big\r\n                       Fan. God Bless WHITE AMERICA.\r\n                         \r\n          Davis shakes his Head in


Davis shakes his Head in Disgust.\r\n                         \r\n          Bikers and others surround Ron. Flip looks wary knowing\r\n          something is up. He gets in Ron\'s face, threatening.\r\n                         \r\n                                                  FLIP\r\n                       Boy you get ya\' ass out NOW!\r\n                         \r\n          Ron breaks off from the roomful of disdain cutting through\r\n          the watching Crowd pushing past Bodies heading toward the\r\n          front door. Suddenly, Ron\'s arm is grabbed...\r\n                         \r\n


\r\n                                   FELIX (O.S.)\r\n                       Where\'s your Patrice?\r\n               Ron turns finding Felix holding his arm.\r\n                         \r\n                                                       FELIX\r\n                            Detective Stallworth!\r\n               Ron JERKS his arm away heading to the exit.\r\n                         \r\n              EXT. STEAKHOUSE/PARKING LOT - DAY\r\n                         \r\n               Ron rushes through the Lot


Ron rushes through the Lot hopping in his unmarked Car.\r\n                         \r\n          INT. RON\'S CAR - DAY\r\n               Ron throws the Car into gear. He Yells into his Radio.\r\n                         \r\n                                                       RON STALLWORTH\r\n                            Attention all Units. Be on the\r\n                            lookout for a White Pickup with a\r\n                            "White Pride" Bumper Sticker. License\r\n                            plate: KE-4108.\r\n


\r\n               Ron guns it down the street.\r\n                         \r\n                                                       RON STALLWORTH\r\n                            Request Backup. FREEDOM HOUSE.\r\n                         \r\n               INT. STEAKHOUSE - DAY\r\n                         \r\n               Walker and Felix sit on both sides of Flip. Flip grins at\r\n               them, then does a double take at Walker, who stares at him.\r\n                         \r\n


\r\n                                                       FELIX\r\n                            Ron, I believe you know my friend.\r\n                         \r\n               Flip stares at Walker playing it totally cool.\r\n                         \r\n                                                       FLIP\r\n                            No, I don\'t believe we\'ve ever met.\r\n                         \r\n                                                       WALKER\r\n


WALKER\r\n                            It\'s been a few years.\r\n                         \r\n                                                       FLIP\r\n                            No, sorry, I can\'t place you.\r\n                         \r\n                                                       DEVIN DAVIS\r\n                            Did you Guys go to School together?\r\n                         \r\n


WALKER\r\n                            No, I went to a Private School in\r\n                            Leavenworth, Kansas.\r\n                         \r\n                                                       FELIX\r\n                            Isn\'t that where the Prison is?\r\n                                                         WALKER\r\n                              Matter a fact it is.\r\n                         \r\n               Walker looks at Flip,


Walker looks at Flip, who says nothing.\r\n                         \r\n                                                         FELIX\r\n                              You know something about that. Don\'t\r\n                              you, Flip?\r\n                         \r\n               Felix\'s eyes burn into Flip, who doesn\'t flinch. Suddenly,\r\n               Josh the Waiter interrupts.\r\n                         \r\n                                                         JOSH\r\n


JOSH\r\n                              There\'s an emergency phone call in\r\n                              the Lobby for a -- Felix Kendrickson.\r\n                         \r\n               Felix rises.\r\n                         \r\n                                                         FELIX\r\n                              Don\'t say another word.\r\n                              I\'ll be right back. Flip.\r\n                         \r\n               Felix walks off. Walker watches him leave turning to Flip,\r\n


watches him leave turning to Flip,\r\n               who plays it cool. A confused Davis observes it all.\r\n                         \r\n               EXT. PHONE BOOTH - DAY - INTERCUT\r\n                         \r\n               ANGLE - FREEDOM HOUSE\r\n                         \r\n               Across the street from the Freedom House, a nervous Connie is\r\n               on the phone clearly rattled.\r\n                         \r\n                                                         CONNIE\r\n                              Jesus! They\'ve got Cops


Jesus! They\'ve got Cops everywhere\r\n                              here! Somebody tipped them off.\r\n                         \r\n               A Police Cruiser drives past.\r\n                         \r\n                                                         CONNIE (CONT\'D)\r\n                              My God there goes another one!\r\n                         \r\n          154A INT. STEAKHOUSE - LOBBY - DAY - INTERCUT\r\n                         \r\n               Felix talks to her from the Lobby of The Steakhouse trying


to her from the Lobby of The Steakhouse trying to\r\n               keep their conversation private.\r\n                         \r\n                                                         FELIX\r\n                              All right, calm down, we planned for\r\n                              this. We\'ll go to Plan B. Okay?\r\n                         \r\n                                                         CONNIE\r\n                              Okay... Plan B.\r\n


FELIX\r\n          You can do this. All right. I\'ll be\r\n          right there.\r\n                                                  CONNIE\r\n                       All right... Love You.\r\n                         \r\n          Dial tone. Felix has already hung up. She hangs up.\r\n                         \r\n          INT. STEAK HOUSE/LOBBY - DAY\r\n                         \r\n          Felix eyes Walker at the table with Flip and Davis. Felix\r\n          waves to Walker. Ivanhoe sees Felix and rushes to join them.\r\n


\r\n                                                  WALKER\r\n                       Excuse me Mister Davis.\r\n                         \r\n          Walker reluctantly leaves.\r\n                         \r\n                                                  DEVIN DAVIS\r\n                       What was all that about? And why did\r\n                       he keep calling you Flip?\r\n                         \r\n


FLIP\r\n                       We were in Prison together. Years\r\n                       ago. It\'s an inside joke.\r\n                         \r\n          Davis nods, concerned.\r\n                         \r\n                                                  DEVIN DAVIS\r\n                       I hope everything\'s all right?\r\n                         \r\n                                                  FLIP\r\n                       Yeah, but I think he may have\r\n


but I think he may have\r\n                       violated his Parole. Excuse me...\r\n          Flip stands watching Felix and Gang exit the Steakhouse.\r\n                         \r\n          EXT. ACADEMY BOULEVARD - DAY\r\n          Ron\'s Car weaves in between Traffic driving like crazy.\r\n                         \r\n          EXT. FREEDOM HOUSE - DAY\r\n                         \r\n          Ron zooms up to Freedom House SCREECHING to a stop! The event\r\n          is over. There are a few people outside conversing after the\r\n          event. Ron sees Hakeem and jumps out of the car.\r\n                         \r\n


\r\n                                                  RON STALLWORTH\r\n                       Where\'s Patrice???\r\n                         \r\n                                                  HAKEEM\r\n                       Patrice and Odetta took Mister\r\n                       Hopkins to his Hotel.\r\n                         \r\n          Ron jumps back in his Ride and burns rubber heading to\r\n          Patrice\'s place!\r\n          INT.    IVANHOE\'S CAR - DAY\r\n                         \r\n


\r\n            Ivanhoe speeds toward Patrice\'s House with Felix in the\r\n            passenger seat and Walker hovering over them in the rear.\r\n                         \r\n                           OMITTED\r\n                         \r\n             EXT. PATRICE\'S HOUSE - DAY\r\n                         \r\n            Connie drives up. She sits there for a long moment staring at\r\n            Patrice\'s House. Connie decides. She gets out of the Car\r\n            carrying her purse. She looks like an Avon lady coming to\r\n            call. She walks up on Patrice\'s porch looking around. She\r\n


on Patrice\'s porch looking around. She\r\n                           CAREFULLY SETS\r\n                         \r\n            CLOSE - HER PURSE\r\n                         \r\n            down by a pillar on the porch and slowly removes the Bomb.\r\n            She opens the mailbox to place the Bomb. She nervously flips\r\n            the toggle switch when she sees...\r\n                         \r\n            ANGLE - STREET\r\n                         \r\n            Patrice drives up. Flustered, Connie grabs her purse to put\r\n            the Bomb back inside while looking at Patrice and Odetta\r\n


and Odetta\r\n            getting out of the Car and getting Groceries from the trunk.\r\n                         \r\n            Patrice talks to Odetta, not noticing Connie. Connie quickly\r\n            leaves the porch striding to her car sweating, crazy nervous.\r\n            Patrice and Odetta talk, entering her House.\r\n                         \r\n            CLOSE - CONNIE\r\n                         \r\n            briskly moves toward the rear of Patrice\'s Car.\r\n                         \r\n            ANGLE - STREET\r\n                         \r\n            Ron whips around the corner seeing Connie


Ron whips around the corner seeing Connie through the\r\n            windshield! He SCREECHES to a stop!\r\n                         \r\n            Connie tries to nonchalantly head back to her vehicle.\r\n                         \r\n            Ron jumps out the car yelling!\r\n                         \r\n                                                     RON STALLWORTH\r\n                          CSPD! Stay where you are!\r\n                         \r\n            Connie looks back at Ron, increasing her pace.\r\n                         \r\n


\r\n                                      RON STALLWORTH(CONT\'D)\r\n                          Don\'t move!!!\r\n                         \r\n            Connie breaks into a run. Ron dashes after her grabbing her\r\n            as she opens the Pick Up Truck door.\r\n                                   RON STALLWORTH (CONT\'D)\r\n                       Where\'s that Bomb? Did you place it!\r\n                         \r\n          The Two fight as she SCREAMS, scratching and clawing at Ron.\r\n          The Fight moves from the Pick Up Truck as he throws her down\r\n          on the grass


her down\r\n          on the grass of a near by lawn, subduing the SCREAMING\r\n          Connie.\r\n                         \r\n                                   RON STALLWORTH (CONT\'D)\r\n                       Where is it!!!\r\n                         \r\n          Ron reaches back for his handcuffs...\r\n                         \r\n                                      CSPD OFFICER BRICKHOUSE\r\n                       Freeze!\r\n                         \r\n          Ron looks right and OFFICER BRICKHOUSE has his Gun pointed at\r\n


his Gun pointed at\r\n          him. Then looks left finding OFFICER MYERS, also White, 30\'s,\r\n          has his revolver aimed at him.\r\n                         \r\n                                      CSPD OFFICER BRICKHOUSE (CONT\'D)\r\n                       Get off her!\r\n                         \r\n          Ron slowly rises up off Connie, gradually turning to them.\r\n          With his hands raised you can see Ron\'s shoulder holster and\r\n          38 CALIBER SNUB-NOSE. Officer Myers sees it!\r\n                         \r\n                                   CSPD OFFICER


CSPD OFFICER MYERS\r\n                       He\'s got a Gun!\r\n                         \r\n                                                  RON STALLWORTH\r\n                       I\'m a Cop! I\'m a COP!!!\r\n                         \r\n          Connie springs up from the lawn! Pleading like crazy to the\r\n          cops!\r\n                         \r\n                                                  CONNIE\r\n                       He attacked me! That Nigger attacked\r\n


That Nigger attacked\r\n                       me, he tried to Rape me! Arrest him!\r\n                         \r\n          Myers and Brickhouse look at each other, unsure.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       I\'m Undercover!!!\r\n                         \r\n                                   CSPD OFFICER BRICKHOUSE\r\n                       Show me your badge!\r\n                         \r\n          Ron goes to reach in his pocket but the two Officers


to reach in his pocket but the two Officers make\r\n          aggressive moves with their Guns! Ron catches himself! He\r\n          doesn\'t want to get shot! He decides to just tell them.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       It\'s in my pocket.\r\n                                                  CONNIE\r\n                       You gonna believe this lying Nigger\r\n                       or me?\r\n                         \r\n


CSPD OFFICER MYERS\r\n                       Get on the ground!\r\n                         \r\n                                                  RON STALLWORTH\r\n                       I\'m a Cop goddammit! She\'s got a\r\n                       Bomb! She\'s a Terrorist!\r\n                         \r\n                                   CSPD OFFICER MYERS\r\n                       Get on the ground NOW!!!\r\n                         \r\n          Ron slowly lowers down to his knees and


Ron slowly lowers down to his knees and the two Cops push him\r\n          face down on the street! Felix drives up with Ivanhoe and\r\n          Walker in the back seat.\r\n                         \r\n          ANGLE - STREET\r\n          Felix has pulled up next to Patrice\'s Volkswagen Beetle.\r\n                         \r\n          INT./EXT. CAR - DAY\r\n                         \r\n                                                  FELIX\r\n                       Gimme\' a detonator.\r\n                         \r\n          Walker unzips his Bag quickly handing a


Walker unzips his Bag quickly handing a Detonator to Felix.\r\n                         \r\n          ANGLE - DOWN THE STREET\r\n                         \r\n          Ron yells at the Cops trying to explain!\r\n                         \r\n                                                  RON STALLWORTH\r\n                       THAT WOMAN HAS A BOMB SHE\'S TRYING TO\r\n                       BLOW THAT HOUSE UP!\r\n                         \r\n          ANGLE - PATRICE\'S HOUSE\r\n                         \r\n          Patrice hearing the


\r\n          Patrice hearing the commotion steps out on the porch with\r\n          Odetta.\r\n                         \r\n          Ivanhoe sees Patrice on the porch.\r\n                         \r\n                                                  IVANHOE\r\n                       There she is! Do it!\r\n                         \r\n          ANGLE - DOWN THE STREET\r\n                         \r\n                                                   RON STALLWORTH\r\n                       PATRICE!\r\n


PATRICE!\r\n                         \r\n          Officer Myers jabs Ron in the Belly with his Nightstick. Ron\r\n          doubles over.\r\n          CLOSE - PATRICE\r\n                         \r\n                                                     PATRICE\r\n                          Ron???\r\n                         \r\n          CLOSE - FELIX\r\n                         \r\n                                                     FELIX\r\n                          You\'re Dead Black Bitch.\r\n


You\'re Dead Black Bitch.\r\n                         \r\n          ANGLE - PATRICE\'S HOUSE\r\n                         \r\n          Patrice looks at Felix.\r\n                         \r\n          CLOSE - RON\r\n                         \r\n          recovering from the blow SCREAMS to her!\r\n                         \r\n                                                     RON STALLWORTH\r\n                          RUN!!! RUN!!! RUN!!!\r\n                         \r\n          ANGLE - STREET\r\n


ANGLE - STREET\r\n                         \r\n          Connie finally sees Felix in the car. Felix sees her, nods.\r\n          She then sees that they are parked... NEXT TO PATRICE\'S\r\n          CAR!!! Connie runs to Felix, screaming!\r\n                         \r\n                                                     CONNIE\r\n                          NO!!! FELIX!!! NO!!! FELIX!!!\r\n                         \r\n          Felix pushes the Button!\r\n                         \r\n                         THE BOMB\r\n


\r\n          is attached to the inside of the wheel well of Patrice\'s car.\r\n                         \r\n                         PATRICE\'S CAR\r\n                         \r\n          EXPLODES! THEN IT BLOWS UP FELIX\'S CAR NEXT TO IT!!! A double\r\n          explosion!!! THE IMPACT BLOWS OUT WINDOWS EVERYWHERE! Patrice\r\n          and Odetta are knocked to the ground. Connie is hurled to the\r\n          street! Glass and car parts flying! Ron and the Cops are\r\n          ROCKED by the force of the HUGE BLAST!\r\n                         \r\n          THE TWO CARS TOTALLY DESTROYED!


THE TWO CARS TOTALLY DESTROYED! ENGULFED IN FLAMES!!!\r\n                         \r\n          Connie on her knees on the street, weeping!\r\n                         \r\n          RON STILL HANDCUFFED\r\n                         \r\n          through the smoke and flames is able to make eye contact with\r\n          Patrice, on the steps of her porch. She is shaken but all\r\n          right. SIRENS in the distance heading toward them!\r\n                         \r\n          ANGLE - STREET\r\n          Flip drives up in a fury and jumps out and holds up his\r\n          BADGE.\r\n


\r\n                                                  FLIP\r\n                       Hey, you fucking idiots!!! We\'re\r\n                       undercover.\r\n                         \r\n          Officers Brickhouse and Myers lower their guns.\r\n                         \r\n          CLOSE - RON STALLWORTH\r\n                         \r\n                                                   RON STALLWORTH\r\n              YOU\'RE LATE.\r\n                         \r\n              CLOSE


\r\n              CLOSE - FLIP\r\n              Flip smiles.\r\n                         \r\n                               OMITTED\r\n                         \r\n                               OMITTED\r\n          INT. DIVE BAR - NIGHT\r\n                         \r\n          The place is full of Off Duty Cops and their Girlfriends, a\r\n          few Wives but mainly Cops drinking and having a good time.\r\n          Ron is in the corner talking with Patrice. They are sharing a\r\n          drink looking very intimate. Ron sees something.\r\n                         \r\n


\r\n                                                  RON STALLWORTH\r\n                       Jeezus Christ.\r\n                         \r\n                                                   PATRICE\r\n                       What?\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Your Boyfriend.\r\n                         \r\n          Patrice turns and sees.\r\n


\r\n                                                   PATRICE\r\n                       Oh My God.\r\n                         \r\n          Master Patrolman Landers nears them with a Beer in his hand.\r\n                         \r\n                                                  LANDERS\r\n                       Who\'s da\' Soul Sistah, Stallworth?\r\n                       You been holding out on me.\r\n                         \r\n          Patrice stares at him with contempt.\r\n


stares at him with contempt.\r\n                         \r\n                                                  PATRICE\r\n                       You don\'t remember me do you?\r\n                         \r\n          Landers stares at her.\r\n                                                    PATRICE (CONT\'D)\r\n                       Kwame Ture.\r\n                         \r\n          Landers doesn\'t know who that is.\r\n                         \r\n


PATRICE (CONT\'D)\r\n                       Stokely Carmichael.\r\n                         \r\n                                                  LANDERS\r\n                       Oh Yeah, Yeah, you looked good that\r\n                       night but you look even better now.\r\n                         \r\n                                                  PATRICE\r\n                       How often do you do that to Black\r\n                       People?\r\n


\r\n                                                    LANDERS\r\n                       Do what?\r\n                         \r\n                                                  PATRICE\r\n                       Pull us over for nothing. Harass us.\r\n                       Put your hands all over a Woman in\r\n                       the guise of searching her. Call us\r\n                       everything but A Child of God.\r\n                         \r\n


LANDERS\r\n                       I don\'t know what you\'re talking\r\n                       about.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       It\'s like what I told you. He just\r\n                       likes taking advantage but in the end\r\n                       he\'s All Hat and No Cattle.\r\n                         \r\n          Landers looks around then leans in close to Patrice and Ron.\r\n


to Patrice and Ron.\r\n          He speaks softly issuing a deadly threat.\r\n                         \r\n                                                  LANDERS\r\n                       Let me tell you both something, I\'ve\r\n                       been keeping you People in line in\r\n                       this City for years. What I did to\r\n                       your Girl that night, I can do to any\r\n                       of you, Anytime, Anyplace. That\'s my\r\n                       prerogative. I can even Bust a Cap in\r\n                       ya Black


ya Black Ass if I feel like it and\r\n                       nuthin\' will be done about it. Get\r\n                       it? Wish the both of you got blown up\r\n                       instead of Good White Folks.\r\n                         \r\n          Master Patrolman Landers raises up.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Ohhh, I get it.\r\n                         \r\n          Ron looks at Patrice.\r\n


RON STALLWORTH (CONT\'D)\r\n                       You get it, Patrice?\r\n                         \r\n                                                  PATRICE\r\n                       Oh, I totally and completely get it.\r\n                         \r\n          Landers looks confused with their response.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Good.\r\n                         \r\n


\r\n          Ron turns toward the Bar and shouts.\r\n                         \r\n                                   RON STALLWORTH (CONT\'D)\r\n                       You get it, Flip?\r\n                         \r\n          Behind the Bar, Flip leans out from the back room waving to\r\n          Ron wearing Headphones recording The Conversation.\r\n                         \r\n                                                  FLIP\r\n                       Oh, We got it! We got it all!\r\n                         \r\n


\r\n          Ron stands removing his Shirt revealing The Wire he is\r\n          wearing. Master Patrolman Landers is in shock.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       You get it, Chief?\r\n                         \r\n          Sgt. Trapp appears taking the Beer from Landers\' hand turning\r\n          him around putting Handcuffs on him. Chief Bridges comes from\r\n          the back nearing Landers. The two lock eyes.\r\n                         \r\n


CHIEF BRIDGES\r\n                       Oh, I really, really get it. You\'re\r\n                       under arrest for Police Misconduct,\r\n                       Sexual Misconduct and Police\r\n                       Brutality.\r\n                         \r\n          Sgt. Trapp and the Chief usher Master Patrolman Landers, who\r\n          is babbling like a Fool out of The Bar reading him his\r\n          rights.\r\n                         \r\n          INT. INTELLIGENCE UNIT - CSPD - DAY\r\n                         \r\n          Ron, walking taller


\r\n          Ron, walking taller than usual, steps inside The Unit. Some\r\n          of his Colleagues notice and give him a Low-Key Ovation. At\r\n          his Desk is Flip, who is in Great Spirits.\r\n                         \r\n                                                  FLIP\r\n                       There he is... Man of the Minute.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       ... not an Hour?\r\n                         \r\n          Ron smiles, gives Fives all around.


Ron smiles, gives Fives all around. They all share a laugh.\r\n                                                   FLIP (CONT\'D)\r\n                        That Polaroid Stunt you pulled? When\r\n                        you threw your Arms around them, I\r\n                        swear to God I almost Shit myself!\r\n                         \r\n                                                   RON STALLWORTH\r\n                        Told you, Ron was born ready.\r\n                         \r\n


FLIP\r\n                        Born ready is Ron.\r\n                         \r\n          Sgt. Trapp steps out of his Office.\r\n                         \r\n                                    SGT. TRAPP\r\n                        There\'s The Crazy Son of a Bitch!!!\r\n                         \r\n          Trapp gives Ron a Bear Hug.\r\n                         \r\n                                    SGT. TRAPP (CONT\'D)\r\n


You did good.\r\n                         \r\n                                                   RON STALLWORTH\r\n                        Sarge. We did good.\r\n                         \r\n          Ron and Flip eyes meet, bonded.\r\n                         \r\n                                    SGT. TRAPP\r\n                        Chief wants to see you Guys.\r\n                         \r\n          Flip nudges Ron.\r\n                         \r\n


\r\n                                                   FLIP\r\n                        Hey... early promotion?\r\n                         \r\n          Ron smiles.\r\n                         \r\n          INT. OFFICE OF THE CHIEF OF POLICE - DAY\r\n                         \r\n          Ron, Flip, and Sgt. Trapp sit opposite Chief Bridges.\r\n                         \r\n                                                   CHIEF BRIDGES\r\n                        Again, I can\'t commend you enough for\r\n


I can\'t commend you enough for\r\n                        what you\'ve achieved. You know there\r\n                        was not a Single Cross Burning the\r\n                        entire time you were involved?\r\n                         \r\n                                                    RON STALLWORTH\r\n                        I\'m aware.\r\n                         \r\n                                                   CHIEF BRIDGES\r\n                        But all good things must come to an\r\n


end...\r\n                         \r\n          Sgt. Trapp shakes his head, resigned.\r\n                                                  RON STALLWORTH\r\n                       What does that mean?\r\n                         \r\n          Ron and Flip look at each other, stunned.\r\n                         \r\n                                                     CHIEF BRIDGES\r\n                       Budget Cuts.\r\n                         \r\n


FLIP\r\n                       Budget Cuts?\r\n                         \r\n                                                  CHIEF BRIDGES\r\n                       Inflation... I wish I had a choice.\r\n                       My hands are tied. Besides, it looks\r\n                       like there are no longer any tangible\r\n                       Threats...\r\n                         \r\n                                                  RON


RON STALLWORTH\r\n                       ...Sounds like we did too good a job.\r\n                         \r\n                                                  CHIEF BRIDGES\r\n                       Not a Bad Legacy to leave.\r\n                         \r\n          Bridges takes a deliberate pause. Then, THE Sucker Punch...\r\n                         \r\n                                   CHIEF BRIDGES (CONT\'D)\r\n                       And I need you, Ron Stallworth, to\r\n                       destroy all


destroy all Evidence of this\r\n                       Investigation.\r\n                         \r\n                                                     RON STALLWORTH\r\n                       Excuse me?\r\n                         \r\n                                                  FLIP\r\n                       This is total Horseshit.\r\n                         \r\n                                                  CHIEF BRIDGES\r\n                       We


We prefer that The Public never knew\r\n                       about this Investigation.\r\n                         \r\n          Ron and Flip are heated. Sgt. Trapp is silent but gutted.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       If they found out...\r\n                         \r\n                                                  CHIEF BRIDGES\r\n                       ...Cease all further contact with The\r\n


Ku Klux Klan. Effective immediately.\r\n                       That goes for Flip too. Ron\r\n                       Stallworth...\r\n                         \r\n                                                  RON STALLWORTH\r\n                       This is some Fucked up Bullshit.\r\n                                                  CHIEF BRIDGES\r\n                       Take a week off. Go on vacation with\r\n                       your Girlfriend. We\'ll hold down The\r\n                       Fort until you get


Fort until you get back. Get you\r\n                       another assignment...Narcotics.\r\n                         \r\n          Ron storms out.\r\n                         \r\n          INT. INTELLIGENCE UNIT - CSPD - DAY\r\n                         \r\n          Ron reflects as he feeds Investigation documents in a\r\n          Shredder. The documents shred into pieces. Just then, the\r\n          Undercover Phone Line rings on Ron\'s desk.\r\n                         \r\n          Ron stares at the Phone, still ringing. He looks at The\r\n          Documents in his hand, about to feed them into The Shredder.\r\n          Ron


The Shredder.\r\n          Ron stops. Throws The Documents in a Folder. Sweeps some\r\n          Folders into his Briefcase. Leaves as The Phone still rings.\r\n                         \r\n          EXT. COLORADO SPRINGS POLICE DEPARTMENT BUILDING - DAY\r\n                         \r\n          Ron is walking fast now, trying to make it out of The\r\n          Building with The Evidence but he remembers something.\r\n          He stops, turns back.\r\n                         \r\n          INT. INTELLIGENCE DIVISION - CSPD - DAY\r\n                         \r\n          Ron sits at his Desk, on The Undercover Phone Line. Flip,\r\n          Jimmy and Sgt. Trapp are


Jimmy and Sgt. Trapp are behind, both close enough to listen,\r\n          giggling.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       I\'m sorry we didn\'t get to spend more\r\n                       One-on-One time together.\r\n                         \r\n          INT. DEVIN DAVIS OFFICE - DAY\r\n                         \r\n          INTERCUT RON, FLIP, AND TRAPP WITH DEVIN DAVIS:\r\n                         \r\n


DEVIN DAVIS\r\n                       Well, that tragic event. I had just\r\n                       met those Fine Brothers in the cause.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Our Chapter is just shaken to the\r\n                       core. And poor Connie not only does\r\n                       she lose her Husband but she\'s facing\r\n                       a healthy Prison Sentence.\r\n                         \r\n


\r\n                                                  DEVIN DAVIS\r\n                       My God. And then there was that one\r\n                       Nigger Detective who threatened me.\r\n                                                  RON STALLWORTH\r\n                       Goddamn Coloreds sure know how to\r\n                       spoil a Celebration.\r\n                         \r\n          Flip and Jimmy snort. Ron holds in a Belly-Laugh.\r\n                         \r\n


DEVIN DAVIS\r\n                       Christ. You can say that again.\r\n                         \r\n          Ron cracks up into his Hand. Sgt. Trapp is wheezing-- his\r\n          Face Bright Pink. Flip is laughing hard in the background.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Can I ask you something? That Nigger\r\n                       Detective who gave you a hard time?\r\n                       Ever get his name?\r\n


\r\n                                                    DEVIN DAVIS\r\n                       No, I...\r\n                         \r\n                                                  RON STALLWORTH\r\n                       ...Are-uh you sure you don\'t know who\r\n                       he is? Are-uh you absolutely sure?\r\n                         \r\n          Davis looks at his Phone. Ron takes out his SMALL NOTE PAD\r\n          out revealing a list of Racial epitaphs he had written down\r\n          being on this


written down\r\n          being on this Investigation. He reads from it to Davis on the\r\n          phone.\r\n                         \r\n          ANGLE - SPLIT SCREEN\r\n                         \r\n          Ron Stallworth and Devin Davis.\r\n                         \r\n                                   RON STALLWORTH (CONT\'D)\r\n                       Cuz\' dat Niggah Coon, Gator Bait,\r\n                       Spade, Spook, Sambo, Spear Flippin\',\r\n                       Jungle Bunny, Mississippi Wind\r\n                       Chime...Detective is Ron Stallworth\r\n


is Ron Stallworth\r\n                       you Redneck, Racist Peckerwood Small\r\n                       Dick Motherfucker!!!\r\n                         \r\n          CLICK. Ron SLAM DUNKS THE RECEIVER LIKE SHAQ.\r\n                         \r\n          CLOSE - DEVIN DAVIS\r\n                         \r\n          Devin Davis\'s Jaw Drops.\r\n                         \r\n          INT. INTELLIGENCE DIVISION - CSPD - DAY\r\n                         \r\n          THE WHOLE OFFICE EXPLODES IN LAUGHTER. COPS ARE ROLLING ON\r\n          THE OFFICE FLOOR.\r\n          INT.


OFFICE FLOOR.\r\n          INT. RON\'S APARTMENT - KITCHEN - NIGHT\r\n                         \r\n          Folders of Evidence sit on The Kitchen Table in a stack in\r\n          front of Ron. He sips his Lipton Tea and removes from the\r\n                         FILES THE\r\n                         \r\n          CLOSE - POLAROID\r\n          Ron hugged up, between Devin Davis and Jesse Nayyar. He then\r\n          looks at The Klan Membership Card shifting in his hands, his\r\n          gaze fixated on the words.\r\n                         \r\n          CLOSE - Ron Stallworth\r\n          KKK Member in Good Standing\r\n


Member in Good Standing\r\n                         \r\n          Patrice comes up from behind.\r\n          CLOSE - PATRICE\r\n          She pulls out a small handgun from her pocketbook.\r\n                         \r\n          2 - SHOT - PATRICE AND RON\r\n                         \r\n                                   PATRICE (O.S.)\r\n                       Have you Resigned from The KKK?\r\n                         \r\n                                                     RON STALLWORTH\r\n                       Affirmative.\r\n


Affirmative.\r\n                         \r\n                                                  PATRICE\r\n                       Have you handed in your Resignation\r\n                       as a Undercover Detective for The\r\n                       Colorado Springs Police Department?\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Negative. Truth be told I\'ve always\r\n                       wanted to be a Cop...and I\'m still\r\n                       for The


for The Liberation for My People.\r\n                         \r\n                                                  PATRICE\r\n                       My Conscience won\'t let me Sleep with\r\n                       The Enemy.\r\n                         \r\n                                                  RON STALLWORTH\r\n                       Enemy? I\'m a Black Man that saved\r\n                       your life.\r\n                         \r\n


PATRICE\r\n                       You\'re absolutely right, and I Thank\r\n                       you for it.\r\n                         \r\n          Patrice Kisses Ron on the cheek. Good Bye. WE HEAR a KNOCK on\r\n          Ron\'s DOOR. Ron, who is startled, slowly rises. We HEAR\r\n          another KNOCK.\r\n                         \r\n          QUICK FLASHES - of a an OLD TIME KLAN RALLY. Ron moves\r\n          quietly to pull out his SERVICE REVOLVER from the COUNTER\r\n          DRAWER. WE HEAR ANOTHER KNOCK on the DOOR. Patrice stands\r\n          behind


Patrice stands\r\n          behind him.\r\n                         \r\n          QUICK FLASHES - BLACK BODY HANGING FROM A TREE (STRANGE\r\n          FRUIT) Ron slowly moves to the DOOR. Ron has his SERVICE\r\n          REVOLVER up and aimed ready to fire. Ron swings open the\r\n          DOOR.\r\n          ANGLE - HALLWAY\r\n                         \r\n          CU - RON\'S POV\r\n                         \r\n          WE TRACK DOWN THE EMPTY HALLWAY PANNING OUT THE WINDOW.\r\n                         \r\n          CLOSE - RON AND PATRICE\r\n                         \r\n          Looking in


\r\n          Looking in the distance: The Rolling Hills surrounding The\r\n          Neighborhood lead towards Pike\'s Peak, which sits on the\r\n          horizon like a King on A Throne.\r\n                         \r\n          WE SEE: Something Burning.\r\n                         \r\n          CLOSER-- WE SEE a CROSS, its Flames dancing, sending embers\r\n          into The BLACK, Colorado Sky.\r\n                         OMITTED\r\n                         \r\n          EXT. UVA CAMPUS - NIGHT\r\n                         \r\n          WE SEE FOOTAGE of NEO-NAZIS, ALT RIGHT, THE KLAN, NEO-\r\n


ALT RIGHT, THE KLAN, NEO-\r\n          CONFEDERATES AND WHITE NATIONALISTS MARCHING, HOLDING UP\r\n          THEIR TIKI TORCHES, CHANTING.\r\n                         \r\n                                                  AMERICAN TERRORISTS\r\n                       YOU WILL NOT REPLACE US!!!\r\n                       JEWS WILL NOT REPLACE US!!!\r\n                       BLOOD AND SOIL!!!\r\n                         \r\n                                                     CUT TO BLACK.\r\n                         \r\n


\r\n                                    FINI.\r\n\r\n\r\n\n\n\n\nBlacKkKlansman\nWriters : \xa0\xa0Charlie Wachtel\xa0\xa0David Rabinowitz\xa0\xa0Kevin Willmott\xa0\xa0Spike Lee\nGenres : \xa0\xa0Crime\xa0\xa0Drama\nUser Comments\n\n\n\n\n\r\nBack to IMSDb\n\n\n', lookup_str='', metadata={'source': 'https://imsdb.com/scripts/BlacKkKlansman.html'}, lookup_index=0)]


previous
Image captions
next
Markdown
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Images
 Contents
Using Unstructured
Retain Elements
Images#
This covers how to load images such as JPGs PNGs into a document format that we can use downstream.
Using Unstructured#
from langchain.document_loaders.image import UnstructuredImageLoader
loader = UnstructuredImageLoader("layout-parser-paper-fast.jpg")
data = loader.load()
data[0]


Document(page_content="LayoutParser: A Unified Toolkit for Deep\nLearning Based Document Image Analysis\n\n\n‘Zxjiang Shen' (F3}, Ruochen Zhang”, Melissa Dell*, Benjamin Charles Germain\nLeet, Jacob Carlson, and Weining LiF\n\n\nsugehen\n\nshangthrows, et\n\n“Abstract. Recent advanocs in document image analysis (DIA) have been\n‘pimarliy driven bythe application of neural networks dell roar\n{uteomer could be aly deployed in production and extended fo farther\n[nvetigtion. However, various factory ke lcely organize codebanee\nsnd sophisticated modal cnigurations compat the ey ree of\n‘erin! innovation by wide sence, Though there have been sng\n‘Hors to improve reuablty and simplify deep lees (DL) mode\n‘aon, sone of them ae optimized for challenge inthe demain of DIA,\nThis roprscte a major gap in the extng fol, sw DIA i eal to\nscademic research acon wie range of dpi in the social ssencee\n[rary for streamlining the sage of DL in DIA research and


streamlining the sage of DL in DIA research and appicn\n‘tons The core LayoutFaraer brary comes with a sch of simple and\nIntative interfaee or applying and eutomiing DI. odel fr Inyo de\npltfom for sharing both protrined modes an fal document dist\n{ation pipeline We demonutate that LayootPareer shea fr both\nlightweight and lrgeseledgtieation pipelines in eal-word uae ces\nThe leary pblely smal at Btspe://layost-pareergsthab So\n\n\n\n‘Keywords: Document Image Analysis» Deep Learning Layout Analysis\n‘Character Renguition - Open Serres dary « Tol\n\n\nIntroduction\n\n\n‘Deep Learning(DL)-based approaches are the state-of-the-art for a wide range of\ndoctiment image analysis (DIA) tea including document image clasiffeation [I]\n", lookup_str='', metadata={'source': 'layout-parser-paper-fast.jpg'}, lookup_index=0)


Retain Elements#
Under the hood, Unstructured creates different “elements” for different chunks of text. By default we combine those together, but you can easily keep that separation by specifying mode="elements".
loader = UnstructuredImageLoader("layout-parser-paper-fast.jpg", mode="elements")
data = loader.load()
data[0]
Document(page_content='LayoutParser: A Unified Toolkit for Deep\nLearning Based Document Image Analysis\n', lookup_str='', metadata={'source': 'layout-parser-paper-fast.jpg', 'filename': 'layout-parser-paper-fast.jpg', 'page_number': 1, 'category': 'Title'}, lookup_index=0)
previous
iFixit
next
Image captions
 Contents

Using Unstructured
Retain Elements
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Notion DB Loader
 Contents
Requirements
Setup
1. Create a Notion Table Database
2. Create a Notion Integration
3. Connect the Integration to the Database
4. Get the Database ID
Usage
Notion DB Loader#
NotionDBLoader is a Python class for loading content from a Notion database. It retrieves pages from the database, reads their content, and returns a list of Document objects.
Requirements#
A Notion Database
Notion Integration Token
Setup#
1. Create a Notion Table Database#
Create a new table database in Notion. You can add any column to the database and they will be treated as metadata. For example you can add the following columns:
Title: set Title as the default property.
Categories: A Multi-select property to store categories associated with the page.
Keywords: A Multi-select property to store keywords associated with the page.
Add your content to the body of each page in the database. The NotionDBLoader will extract the content and metadata from these pages.
2. Create a Notion Integration#
To create a Notion Integration, follow these steps:
Visit the (Notion Developers)[https://www.notion.com/my-integrations] page and log in with your Notion account.
Click on the “+ New integration” button.
Give your integration a name and choose the workspace where your database is located.
Select the require capabilities, this extension only need the Read content capability
Click the “Submit” button to create the integration.
Once the integration is created, you’ll be provided with an Integration Token (API key). Copy this token and keep it safe, as you’ll need it to use the NotionDBLoader.
3. Connect the Integration to the Database#
To connect your integration to the database, follow these steps:
Open your database in Notion.


To connect your integration to the database, follow these steps:
Open your database in Notion.
Click on the three-dot menu icon in the top right corner of the database view.
Click on the “+ New integration” button.
Find your integration, you may need to start typing its name in the search box.
Click on the “Connect” button to connect the integration to the database.
4. Get the Database ID#
To get the database ID, follow these steps:
Open your database in Notion.
Click on the three-dot menu icon in the top right corner of the database view.
Select “Copy link” from the menu to copy the database URL to your clipboard.
The database ID is the long string of alphanumeric characters found in the URL. It typically looks like this: https://www.notion.so/username/8935f9d140a04f95a872520c4f123456?v=…. In this example, the database ID is 8935f9d140a04f95a872520c4f123456.
With the database properly set up and the integration token and database ID in hand, you can now use the NotionDBLoader code to load content and metadata from your Notion database.
Usage#
NotionDBLoader is part of the langchain package’s document loaders. You can use it as follows:
from getpass import getpass
NOTION_TOKEN = getpass()
DATABASE_ID = getpass()
········
········
from langchain.document_loaders import NotionDBLoader
loader = NotionDBLoader(NOTION_TOKEN, DATABASE_ID)
docs = loader.load()
print(docs)
previous
Notion
next
Obsidian
 Contents

Requirements
Setup
1. Create a Notion Table Database
2. Create a Notion Integration


Requirements
Setup
1. Create a Notion Table Database
2. Create a Notion Integration
3. Connect the Integration to the Database
4. Get the Database ID
Usage
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
CoNLL-U
CoNLL-U#
This is an example of how to load a file in CoNLL-U format. The whole file is treated as one document. The example data (conllu.conllu) is based on one of the standard UD/CoNLL-U examples.
from langchain.document_loaders import CoNLLULoader
loader = CoNLLULoader("example_data/conllu.conllu")
document = loader.load()
document
previous
Document Loaders
next
Airbyte JSON
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Copy Paste
 Contents
Metadata
Copy Paste#
This notebook covers how to load a document object from something you just want to copy and paste. In this case, you don’t even need to use a DocumentLoader, but rather can just construct the Document directly.
from langchain.docstore.document import Document
text = "..... put the text you copy pasted here......"
doc = Document(page_content=text)
Metadata#
If you want to add metadata about the where you got this piece of text, you easily can with the metadata key.
metadata = {"source": "internet", "date": "Friday"}
doc = Document(page_content=text, metadata=metadata)
previous
Confluence
next
CSV Loader
 Contents

Metadata
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
CSV Loader
 Contents
Customizing the csv parsing and loading
Specify a column to be used identify the document source
CSV Loader#
Load csv files with a single row per document.
from langchain.document_loaders.csv_loader import CSVLoader
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv')
data = loader.load()
print(data)


[Document(page_content='Team: Nationals\n"Payroll (millions)": 81.34\n"Wins": 98', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 0}, lookup_index=0), Document(page_content='Team: Reds\n"Payroll (millions)": 82.20\n"Wins": 97', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 1}, lookup_index=0), Document(page_content='Team: Yankees\n"Payroll (millions)": 197.96\n"Wins": 95', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 2}, lookup_index=0), Document(page_content='Team: Giants\n"Payroll (millions)": 117.62\n"Wins": 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 3}, lookup_index=0), Document(page_content='Team: Braves\n"Payroll (millions)": 83.31\n"Wins": 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 4}, lookup_index=0), Document(page_content='Team: Athletics\n"Payroll (millions)": 55.37\n"Wins": 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 5}, lookup_index=0), Document(page_content='Team: Rangers\n"Payroll


lookup_index=0), Document(page_content='Team: Rangers\n"Payroll (millions)": 120.51\n"Wins": 93', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 6}, lookup_index=0), Document(page_content='Team: Orioles\n"Payroll (millions)": 81.43\n"Wins": 93', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 7}, lookup_index=0), Document(page_content='Team: Rays\n"Payroll (millions)": 64.17\n"Wins": 90', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 8}, lookup_index=0), Document(page_content='Team: Angels\n"Payroll (millions)": 154.49\n"Wins": 89', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 9}, lookup_index=0), Document(page_content='Team: Tigers\n"Payroll (millions)": 132.30\n"Wins": 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 10}, lookup_index=0), Document(page_content='Team: Cardinals\n"Payroll (millions)": 110.30\n"Wins": 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 11}, lookup_index=0), Document(page_content='Team:


'row': 11}, lookup_index=0), Document(page_content='Team: Dodgers\n"Payroll (millions)": 95.14\n"Wins": 86', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 12}, lookup_index=0), Document(page_content='Team: White Sox\n"Payroll (millions)": 96.92\n"Wins": 85', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 13}, lookup_index=0), Document(page_content='Team: Brewers\n"Payroll (millions)": 97.65\n"Wins": 83', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 14}, lookup_index=0), Document(page_content='Team: Phillies\n"Payroll (millions)": 174.54\n"Wins": 81', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 15}, lookup_index=0), Document(page_content='Team: Diamondbacks\n"Payroll (millions)": 74.28\n"Wins": 81', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 16}, lookup_index=0), Document(page_content='Team: Pirates\n"Payroll (millions)": 63.43\n"Wins": 79', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 17}, lookup_index=0),


'row': 17}, lookup_index=0), Document(page_content='Team: Padres\n"Payroll (millions)": 55.24\n"Wins": 76', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 18}, lookup_index=0), Document(page_content='Team: Mariners\n"Payroll (millions)": 81.97\n"Wins": 75', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 19}, lookup_index=0), Document(page_content='Team: Mets\n"Payroll (millions)": 93.35\n"Wins": 74', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 20}, lookup_index=0), Document(page_content='Team: Blue Jays\n"Payroll (millions)": 75.48\n"Wins": 73', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 21}, lookup_index=0), Document(page_content='Team: Royals\n"Payroll (millions)": 60.91\n"Wins": 72', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 22}, lookup_index=0), Document(page_content='Team: Marlins\n"Payroll (millions)": 118.07\n"Wins": 69', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 23}, lookup_index=0),


'row': 23}, lookup_index=0), Document(page_content='Team: Red Sox\n"Payroll (millions)": 173.18\n"Wins": 69', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 24}, lookup_index=0), Document(page_content='Team: Indians\n"Payroll (millions)": 78.43\n"Wins": 68', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 25}, lookup_index=0), Document(page_content='Team: Twins\n"Payroll (millions)": 94.08\n"Wins": 66', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 26}, lookup_index=0), Document(page_content='Team: Rockies\n"Payroll (millions)": 78.06\n"Wins": 64', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 27}, lookup_index=0), Document(page_content='Team: Cubs\n"Payroll (millions)": 88.19\n"Wins": 61', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 28}, lookup_index=0), Document(page_content='Team: Astros\n"Payroll (millions)": 60.65\n"Wins": 55', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 29}, lookup_index=0)]


Customizing the csv parsing and loading#
See the csv module documentation for more information of what csv args are supported.
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv', csv_args={
    'delimiter': ',',
    'quotechar': '"',
    'fieldnames': ['MLB Team', 'Payroll in millions', 'Wins']
})
data = loader.load()
print(data)


[Document(page_content='MLB Team: Team\nPayroll in millions: "Payroll (millions)"\nWins: "Wins"', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 0}, lookup_index=0), Document(page_content='MLB Team: Nationals\nPayroll in millions: 81.34\nWins: 98', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 1}, lookup_index=0), Document(page_content='MLB Team: Reds\nPayroll in millions: 82.20\nWins: 97', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 2}, lookup_index=0), Document(page_content='MLB Team: Yankees\nPayroll in millions: 197.96\nWins: 95', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 3}, lookup_index=0), Document(page_content='MLB Team: Giants\nPayroll in millions: 117.62\nWins: 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 4}, lookup_index=0), Document(page_content='MLB Team: Braves\nPayroll in millions: 83.31\nWins: 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row':


'./example_data/mlb_teams_2012.csv', 'row': 5}, lookup_index=0), Document(page_content='MLB Team: Athletics\nPayroll in millions: 55.37\nWins: 94', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 6}, lookup_index=0), Document(page_content='MLB Team: Rangers\nPayroll in millions: 120.51\nWins: 93', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 7}, lookup_index=0), Document(page_content='MLB Team: Orioles\nPayroll in millions: 81.43\nWins: 93', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 8}, lookup_index=0), Document(page_content='MLB Team: Rays\nPayroll in millions: 64.17\nWins: 90', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 9}, lookup_index=0), Document(page_content='MLB Team: Angels\nPayroll in millions: 154.49\nWins: 89', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 10}, lookup_index=0), Document(page_content='MLB Team: Tigers\nPayroll in millions: 132.30\nWins: 88', lookup_str='',


in millions: 132.30\nWins: 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 11}, lookup_index=0), Document(page_content='MLB Team: Cardinals\nPayroll in millions: 110.30\nWins: 88', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 12}, lookup_index=0), Document(page_content='MLB Team: Dodgers\nPayroll in millions: 95.14\nWins: 86', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 13}, lookup_index=0), Document(page_content='MLB Team: White Sox\nPayroll in millions: 96.92\nWins: 85', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 14}, lookup_index=0), Document(page_content='MLB Team: Brewers\nPayroll in millions: 97.65\nWins: 83', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 15}, lookup_index=0), Document(page_content='MLB Team: Phillies\nPayroll in millions: 174.54\nWins: 81', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 16}, lookup_index=0), Document(page_content='MLB Team:


16}, lookup_index=0), Document(page_content='MLB Team: Diamondbacks\nPayroll in millions: 74.28\nWins: 81', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 17}, lookup_index=0), Document(page_content='MLB Team: Pirates\nPayroll in millions: 63.43\nWins: 79', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 18}, lookup_index=0), Document(page_content='MLB Team: Padres\nPayroll in millions: 55.24\nWins: 76', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 19}, lookup_index=0), Document(page_content='MLB Team: Mariners\nPayroll in millions: 81.97\nWins: 75', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 20}, lookup_index=0), Document(page_content='MLB Team: Mets\nPayroll in millions: 93.35\nWins: 74', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 21}, lookup_index=0), Document(page_content='MLB Team: Blue Jays\nPayroll in millions: 75.48\nWins: 73', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv',


metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 22}, lookup_index=0), Document(page_content='MLB Team: Royals\nPayroll in millions: 60.91\nWins: 72', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 23}, lookup_index=0), Document(page_content='MLB Team: Marlins\nPayroll in millions: 118.07\nWins: 69', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 24}, lookup_index=0), Document(page_content='MLB Team: Red Sox\nPayroll in millions: 173.18\nWins: 69', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 25}, lookup_index=0), Document(page_content='MLB Team: Indians\nPayroll in millions: 78.43\nWins: 68', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 26}, lookup_index=0), Document(page_content='MLB Team: Twins\nPayroll in millions: 94.08\nWins: 66', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 27}, lookup_index=0), Document(page_content='MLB Team: Rockies\nPayroll in millions: 78.06\nWins: 64',


in millions: 78.06\nWins: 64', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 28}, lookup_index=0), Document(page_content='MLB Team: Cubs\nPayroll in millions: 88.19\nWins: 61', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 29}, lookup_index=0), Document(page_content='MLB Team: Astros\nPayroll in millions: 60.65\nWins: 55', lookup_str='', metadata={'source': './example_data/mlb_teams_2012.csv', 'row': 30}, lookup_index=0)]


Specify a column to be used identify the document source#
Use the source_column argument to specify a column to be set as the source for the document created from each row. Otherwise file_path will be used as the source for all documents created from the csv file.
This is useful when using documents loaded from CSV files for chains that answer questions using sources.
loader = CSVLoader(file_path='./example_data/mlb_teams_2012.csv', source_column="Team")
data = loader.load()
print(data)


[Document(page_content='Team: Nationals\n"Payroll (millions)": 81.34\n"Wins": 98', lookup_str='', metadata={'source': 'Nationals', 'row': 0}, lookup_index=0), Document(page_content='Team: Reds\n"Payroll (millions)": 82.20\n"Wins": 97', lookup_str='', metadata={'source': 'Reds', 'row': 1}, lookup_index=0), Document(page_content='Team: Yankees\n"Payroll (millions)": 197.96\n"Wins": 95', lookup_str='', metadata={'source': 'Yankees', 'row': 2}, lookup_index=0), Document(page_content='Team: Giants\n"Payroll (millions)": 117.62\n"Wins": 94', lookup_str='', metadata={'source': 'Giants', 'row': 3}, lookup_index=0), Document(page_content='Team: Braves\n"Payroll (millions)": 83.31\n"Wins": 94', lookup_str='', metadata={'source': 'Braves', 'row': 4}, lookup_index=0), Document(page_content='Team: Athletics\n"Payroll (millions)": 55.37\n"Wins": 94', lookup_str='', metadata={'source': 'Athletics', 'row': 5}, lookup_index=0), Document(page_content='Team: Rangers\n"Payroll (millions)": 120.51\n"Wins": 93', lookup_str='', metadata={'source': 'Rangers', 'row': 6}, lookup_index=0), Document(page_content='Team:


'row': 6}, lookup_index=0), Document(page_content='Team: Orioles\n"Payroll (millions)": 81.43\n"Wins": 93', lookup_str='', metadata={'source': 'Orioles', 'row': 7}, lookup_index=0), Document(page_content='Team: Rays\n"Payroll (millions)": 64.17\n"Wins": 90', lookup_str='', metadata={'source': 'Rays', 'row': 8}, lookup_index=0), Document(page_content='Team: Angels\n"Payroll (millions)": 154.49\n"Wins": 89', lookup_str='', metadata={'source': 'Angels', 'row': 9}, lookup_index=0), Document(page_content='Team: Tigers\n"Payroll (millions)": 132.30\n"Wins": 88', lookup_str='', metadata={'source': 'Tigers', 'row': 10}, lookup_index=0), Document(page_content='Team: Cardinals\n"Payroll (millions)": 110.30\n"Wins": 88', lookup_str='', metadata={'source': 'Cardinals', 'row': 11}, lookup_index=0), Document(page_content='Team: Dodgers\n"Payroll (millions)": 95.14\n"Wins": 86', lookup_str='', metadata={'source': 'Dodgers', 'row': 12}, lookup_index=0), Document(page_content='Team: White Sox\n"Payroll (millions)": 96.92\n"Wins": 85', lookup_str='', metadata={'source': 'White Sox', 'row':


lookup_str='', metadata={'source': 'White Sox', 'row': 13}, lookup_index=0), Document(page_content='Team: Brewers\n"Payroll (millions)": 97.65\n"Wins": 83', lookup_str='', metadata={'source': 'Brewers', 'row': 14}, lookup_index=0), Document(page_content='Team: Phillies\n"Payroll (millions)": 174.54\n"Wins": 81', lookup_str='', metadata={'source': 'Phillies', 'row': 15}, lookup_index=0), Document(page_content='Team: Diamondbacks\n"Payroll (millions)": 74.28\n"Wins": 81', lookup_str='', metadata={'source': 'Diamondbacks', 'row': 16}, lookup_index=0), Document(page_content='Team: Pirates\n"Payroll (millions)": 63.43\n"Wins": 79', lookup_str='', metadata={'source': 'Pirates', 'row': 17}, lookup_index=0), Document(page_content='Team: Padres\n"Payroll (millions)": 55.24\n"Wins": 76', lookup_str='', metadata={'source': 'Padres', 'row': 18}, lookup_index=0), Document(page_content='Team: Mariners\n"Payroll (millions)": 81.97\n"Wins": 75', lookup_str='', metadata={'source': 'Mariners', 'row': 19}, lookup_index=0), Document(page_content='Team: Mets\n"Payroll (millions)": 93.35\n"Wins": 74', lookup_str='',


(millions)": 93.35\n"Wins": 74', lookup_str='', metadata={'source': 'Mets', 'row': 20}, lookup_index=0), Document(page_content='Team: Blue Jays\n"Payroll (millions)": 75.48\n"Wins": 73', lookup_str='', metadata={'source': 'Blue Jays', 'row': 21}, lookup_index=0), Document(page_content='Team: Royals\n"Payroll (millions)": 60.91\n"Wins": 72', lookup_str='', metadata={'source': 'Royals', 'row': 22}, lookup_index=0), Document(page_content='Team: Marlins\n"Payroll (millions)": 118.07\n"Wins": 69', lookup_str='', metadata={'source': 'Marlins', 'row': 23}, lookup_index=0), Document(page_content='Team: Red Sox\n"Payroll (millions)": 173.18\n"Wins": 69', lookup_str='', metadata={'source': 'Red Sox', 'row': 24}, lookup_index=0), Document(page_content='Team: Indians\n"Payroll (millions)": 78.43\n"Wins": 68', lookup_str='', metadata={'source': 'Indians', 'row': 25}, lookup_index=0), Document(page_content='Team: Twins\n"Payroll (millions)": 94.08\n"Wins": 66', lookup_str='', metadata={'source': 'Twins', 'row': 26}, lookup_index=0), Document(page_content='Team: Rockies\n"Payroll


lookup_index=0), Document(page_content='Team: Rockies\n"Payroll (millions)": 78.06\n"Wins": 64', lookup_str='', metadata={'source': 'Rockies', 'row': 27}, lookup_index=0), Document(page_content='Team: Cubs\n"Payroll (millions)": 88.19\n"Wins": 61', lookup_str='', metadata={'source': 'Cubs', 'row': 28}, lookup_index=0), Document(page_content='Team: Astros\n"Payroll (millions)": 60.65\n"Wins": 55', lookup_str='', metadata={'source': 'Astros', 'row': 29}, lookup_index=0)]


previous
Copy Paste
next
DataFrame Loader
 Contents

Customizing the csv parsing and loading
Specify a column to be used identify the document source
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Word Documents
 Contents
Retain Elements
Word Documents#
This covers how to load Word documents into a document format that we can use downstream.
from langchain.document_loaders import UnstructuredWordDocumentLoader
loader = UnstructuredWordDocumentLoader("example_data/fake.docx")
data = loader.load()
data
[Document(page_content='Lorem ipsum dolor sit amet.', lookup_str='', metadata={'source': 'fake.docx'}, lookup_index=0)]
Retain Elements#
Under the hood, Unstructured creates different “elements” for different chunks of text. By default we combine those together, but you can easily keep that separation by specifying mode="elements".
loader = UnstructuredWordDocumentLoader("example_data/fake.docx", mode="elements")
data = loader.load()
data[0]
Document(page_content='Lorem ipsum dolor sit amet.', lookup_str='', metadata={'source': 'fake.docx', 'filename': 'fake.docx', 'category': 'Title'}, lookup_index=0)
previous
WhatsApp Chat
next
YouTube
 Contents

Retain Elements
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Google Drive
 Contents
Prerequisites
🧑 Instructions for ingesting your Google Docs data
Google Drive#
This notebook covers how to load documents from Google Drive. Currently, only Google Docs are supported.
Prerequisites#
Create a Google Cloud project or use an existing project
Enable the Google Drive API
Authorize credentials for desktop app
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
🧑 Instructions for ingesting your Google Docs data#
By default, the GoogleDriveLoader expects the credentials.json file to be ~/.credentials/credentials.json, but this is configurable using the credentials_path keyword argument. Same thing with token.json - token_path. Note that token.json will be created automatically the first time you use the loader.
GoogleDriveLoader can load from a list of Google Docs document ids or a folder id. You can obtain your folder and document id from the URL:
Folder: https://drive.google.com/drive/u/0/folders/1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5 -> folder id is "1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5"
Document: https://docs.google.com/document/d/1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw/edit -> document id is "1bfaMQ18_i56204VaQDVeAFpqEijJTgvurupdEDiaUQw"
from langchain.document_loaders import GoogleDriveLoader
loader = GoogleDriveLoader(
    folder_id="1yucgL9WGgWZdM1TOuKkeghlPizuzMYb5",


# Optional: configure whether to recursively fetch files from subfolders. Defaults to False.
    recursive=False
)
docs = loader.load()
previous
GitBook
next
Gutenberg
 Contents

Prerequisites
🧑 Instructions for ingesting your Google Docs data
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
BigQuery Loader
 Contents
Basic Usage
Specifying Which Columns are Content vs Metadata
Adding Source to Metadata
BigQuery Loader#
Load a BigQuery query with one document per row.
from langchain.document_loaders import BigQueryLoader
BASE_QUERY = '''
SELECT
  id,
  dna_sequence,
  organism
FROM (
  SELECT
    ARRAY (
    SELECT
      AS STRUCT 1 AS id, "ATTCGA" AS dna_sequence, "Lokiarchaeum sp. (strain GC14_75)." AS organism
    UNION ALL
    SELECT
      AS STRUCT 2 AS id, "AGGCGA" AS dna_sequence, "Heimdallarchaeota archaeon (strain LC_2)." AS organism
    UNION ALL
    SELECT
      AS STRUCT 3 AS id, "TCCGGA" AS dna_sequence, "Acidianus hospitalis (strain W1)." AS organism) AS new_array),
  UNNEST(new_array)
'''
Basic Usage#
loader = BigQueryLoader(BASE_QUERY)
data = loader.load()
print(data)
[Document(page_content='id: 1\ndna_sequence: ATTCGA\norganism: Lokiarchaeum sp. (strain GC14_75).', lookup_str='', metadata={}, lookup_index=0), Document(page_content='id: 2\ndna_sequence: AGGCGA\norganism: Heimdallarchaeota archaeon (strain LC_2).', lookup_str='', metadata={}, lookup_index=0), Document(page_content='id: 3\ndna_sequence: TCCGGA\norganism: Acidianus hospitalis (strain W1).', lookup_str='', metadata={}, lookup_index=0)]
Specifying Which Columns are Content vs Metadata#


Specifying Which Columns are Content vs Metadata#
loader = BigQueryLoader(BASE_QUERY, page_content_columns=["dna_sequence", "organism"], metadata_columns=["id"])
data = loader.load()
print(data)
[Document(page_content='dna_sequence: ATTCGA\norganism: Lokiarchaeum sp. (strain GC14_75).', lookup_str='', metadata={'id': 1}, lookup_index=0), Document(page_content='dna_sequence: AGGCGA\norganism: Heimdallarchaeota archaeon (strain LC_2).', lookup_str='', metadata={'id': 2}, lookup_index=0), Document(page_content='dna_sequence: TCCGGA\norganism: Acidianus hospitalis (strain W1).', lookup_str='', metadata={'id': 3}, lookup_index=0)]
Adding Source to Metadata#
# Note that the `id` column is being returned twice, with one instance aliased as `source`
ALIASED_QUERY = '''
SELECT
  id,
  dna_sequence,
  organism,
  id as source
FROM (
  SELECT
    ARRAY (
    SELECT
      AS STRUCT 1 AS id, "ATTCGA" AS dna_sequence, "Lokiarchaeum sp. (strain GC14_75)." AS organism
    UNION ALL
    SELECT
      AS STRUCT 2 AS id, "AGGCGA" AS dna_sequence, "Heimdallarchaeota archaeon (strain LC_2)." AS organism
    UNION ALL
    SELECT
      AS STRUCT 3 AS id, "TCCGGA" AS dna_sequence, "Acidianus hospitalis (strain W1)." AS organism) AS new_array),
  UNNEST(new_array)
'''
loader = BigQueryLoader(ALIASED_QUERY, metadata_columns=["source"])
data = loader.load()


data = loader.load()
print(data)
[Document(page_content='id: 1\ndna_sequence: ATTCGA\norganism: Lokiarchaeum sp. (strain GC14_75).\nsource: 1', lookup_str='', metadata={'source': 1}, lookup_index=0), Document(page_content='id: 2\ndna_sequence: AGGCGA\norganism: Heimdallarchaeota archaeon (strain LC_2).\nsource: 2', lookup_str='', metadata={'source': 2}, lookup_index=0), Document(page_content='id: 3\ndna_sequence: TCCGGA\norganism: Acidianus hospitalis (strain W1).\nsource: 3', lookup_str='', metadata={'source': 3}, lookup_index=0)]
previous
Azure Blob Storage File
next
Bilibili
 Contents

Basic Usage
Specifying Which Columns are Content vs Metadata
Adding Source to Metadata
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Notebook
Notebook#
This notebook covers how to load data from an .ipynb notebook into a format suitable by LangChain.
from langchain.document_loaders import NotebookLoader
loader = NotebookLoader("example_data/notebook.ipynb", include_outputs=True, max_output_length=20, remove_newline=True)
NotebookLoader.load() loads the .ipynb notebook file into a Document object.
Parameters:
include_outputs (bool): whether to include cell outputs in the resulting document (default is False).
max_output_length (int): the maximum number of characters to include from each cell output (default is 10).
remove_newline (bool): whether to remove newline characters from the cell sources and outputs (default is False).
traceback (bool): whether to include full traceback (default is False).
loader.load()


traceback (bool): whether to include full traceback (default is False).
loader.load()
[Document(page_content='\'markdown\' cell: \'[\'# Notebook\', \'\', \'This notebook covers how to load data from an .ipynb notebook into a format suitable by LangChain.\']\'\n\n \'code\' cell: \'[\'from langchain.document_loaders import NotebookLoader\']\'\n\n \'code\' cell: \'[\'loader = NotebookLoader("example_data/notebook.ipynb")\']\'\n\n \'markdown\' cell: \'[\'`NotebookLoader.load()` loads the `.ipynb` notebook file into a `Document` object.\', \'\', \'**Parameters**:\', \'\', \'* `include_outputs` (bool): whether to include cell outputs in the resulting document (default is False).\', \'* `max_output_length` (int): the maximum number of characters to include from each cell output (default is 10).\', \'* `remove_newline` (bool): whether to remove newline characters from the cell sources and outputs (default is False).\', \'* `traceback` (bool): whether to include full traceback (default is False).\']\'\n\n \'code\' cell: \'[\'loader.load(include_outputs=True, max_output_length=20, remove_newline=True)\']\'\n\n', lookup_str='', metadata={'source': 'example_data/notebook.ipynb'}, lookup_index=0)]
previous
Markdown
next
Notion
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
Slack (Local Exported Zipfile)
 Contents
🧑 Instructions for ingesting your own dataset
Slack (Local Exported Zipfile)#
This notebook covers how to load documents from a Zipfile generated from a Slack export.
In order to get this Slack export, follow these instructions:
🧑 Instructions for ingesting your own dataset#
Export your Slack data. You can do this by going to your Workspace Management page and clicking the Import/Export option ({your_slack_domain}.slack.com/services/export). Then, choose the right date range and click Start export. Slack will send you an email and a DM when the export is ready.
The download will produce a .zip file in your Downloads folder (or wherever your downloads can be found, depending on your OS configuration).
Copy the path to the .zip file, and assign it as LOCAL_ZIPFILE below.
from langchain.document_loaders import SlackDirectoryLoader
# Optionally set your Slack URL. This will give you proper URLs in the docs sources.
SLACK_WORKSPACE_URL = "https://xxx.slack.com"
LOCAL_ZIPFILE = "" # Paste the local paty to your Slack zip file here.
loader = SlackDirectoryLoader(LOCAL_ZIPFILE, SLACK_WORKSPACE_URL)
docs = loader.load()
docs
previous
Sitemap Loader
next
Subtitle Files
 Contents

🧑 Instructions for ingesting your own dataset
By Harrison Chase

      © Copyright 2023, Harrison Chase.

  Last updated on Apr 28, 2023.


.ipynb
.pdf
iFixit
 Contents
Searching iFixit using /suggest
iFixit#
iFixit is the largest, open repair community on the web. The site contains nearly 100k repair manuals, 200k Questions & Answers on 42k devices, and all the data is licensed under CC-BY-NC-SA 3.0.
This loader will allow you to download the text of a repair guide, text of Q&A’s and wikis from devices on iFixit using their open APIs.  It’s incredibly useful for context related to technical documents and answers to questions about devices in the corpus of data on iFixit.
from langchain.document_loaders import IFixitLoader
loader = IFixitLoader("https://www.ifixit.com/Teardown/Banana+Teardown/811")
data = loader.load()
data


data = loader.load()
data
[Document(page_content="# Banana Teardown\nIn this teardown, we open a banana to see what's inside.  Yellow and delicious, but most importantly, yellow.\n\n\n###Tools Required:\n\n - Fingers\n\n - Teeth\n\n - Thumbs\n\n\n###Parts Required:\n\n - None\n\n\n## Step 1\nTake one banana from the bunch.\nDon't squeeze too hard!\n\n\n## Step 2\nHold the banana in your left hand and grip the stem between your right thumb and forefinger.\n\n\n## Step 3\nPull the stem downward until the peel splits.\n\n\n## Step 4\nInsert your thumbs into the split of the peel and pull the two sides apart.\nExpose the top of the banana.  It may be slightly squished from pulling on the stem, but this will not affect the flavor.\n\n\n## Step 5\nPull open the peel, starting from your original split, and opening it along the length of the banana.\n\n\n## Step 6\nRemove fruit from peel.\n\n\n## Step 7\nEat and enjoy!\nThis is where you'll need your teeth.\nDo not choke on banana!\n", lookup_str='', metadata={'source': 'https://www.ifixit.com/Teardown/Banana+Teardown/811', 'title': 'Banana Teardown'}, lookup_index=0)]
loader = IFixitLoader("https://www.ifixit.com/Answers/View/318583/My+iPhone+6+is+typing+and+opening+apps+by+itself")
data = loader.load()
data


[Document(page_content='# My iPhone 6 is typing and opening apps by itself\nmy iphone 6 is typing and opening apps by itself. How do i fix this. I just bought it last week.\nI restored as manufactures cleaned up the screen\nthe problem continues\n\n## 27 Answers\n\nFilter by: \n\nMost Helpful\nNewest\nOldest\n\n### Accepted Answer\nHi,\nWhere did you buy it? If you bought it from Apple or from an official retailer like Carphone warehouse etc. Then you\'ll have a year warranty and can get it replaced free.\nIf you bought it second hand, from a third part repair shop or online, then it may still have warranty, unless it is refurbished and has been repaired elsewhere.\nIf this is the case, it may be the screen that needs replacing to solve your issue.\nEither way, wherever you got it, it\'s best to return it and get a refund or a replacement device. :-)\n\n\n\n### Most Helpful Answer\nI had the same issues, screen freezing, opening apps by itself,


same issues, screen freezing, opening apps by itself, selecting the screens and typing on it\'s own. I first suspected aliens and then ghosts and then hackers.\niPhone 6 is weak physically and tend to bend on pressure. And my phone had no case or cover.\nI took the phone to apple stores and they said sensors need to be replaced and possibly screen replacement as well. My phone is just 17 months old.\nHere is what I did two days ago and since then it is working like a charm..\nHold the phone in portrait (as if watching a movie). Twist it very very gently. do it few times.Rest the phone for 10 mins (put it on a flat surface). You can now notice those self typing things gone and screen getting stabilized.\nThen, reset the hardware (hold the power and home button till the screen goes off and comes back with apple logo). release the buttons when you see this.\nThen, connect to your laptop and log in to iTunes and reset your phone completely. (please


to iTunes and reset your phone completely. (please take a back-up first).\nAnd your phone should be good to use again.\nWhat really happened here for me is that the sensors might have stuck to the screen and with mild twisting, they got disengaged/released.\nI posted this in Apple Community and the moderators deleted it, for the best reasons known to them.\nInstead of throwing away your phone (or selling cheaply), try this and you could be saving your phone.\nLet me know how it goes.\n\n\n\n### Other Answer\nIt was the charging cord! I bought a gas station braided cord and it was the culprit. Once I plugged my OEM cord into the phone the GHOSTS went away.\n\n\n\n### Other Answer\nI\'ve same issue that I just get resolved.  I first tried to restore it from iCloud back, however it was not a software issue or any virus issue, so after restore same problem continues. Then I get my phone to local area iphone repairing lab, and they detected


to local area iphone repairing lab, and they detected that it is an LCD issue. LCD get out of order without any reason (It was neither hit or nor slipped, but LCD get out of order all and sudden, while using it) it started opening things at random. I get LCD replaced with new one, that cost me $80.00 in total  ($70.00 LCD charges + $10.00 as labor charges to fix it). iPhone is back to perfect mode now.  It was iphone 6s. Thanks.\n\n\n\n### Other Answer\nI was having the same issue with my 6 plus, I took it to a repair shop, they opened the phone, disconnected the three ribbons the screen has, blew up and cleaned the connectors and connected the screen again and it solved the issue… it’s hardware, not software.\n\n\n\n### Other Answer\nHey.\nJust had this problem now. As it turns out, you just need to plug in your phone. I use a case and when I took it off I noticed that there was a lot


took it off I noticed that there was a lot of dust and dirt around the areas that the case didn\'t cover. I shined a light in my ports and noticed they were filled with dust. Tomorrow I plan on using pressurized air to clean it out and the problem should be solved.  If you plug in your phone and unplug it and it stops the issue, I recommend cleaning your phone thoroughly.\n\n\n\n### Other Answer\nI simply changed the power supply and problem was gone. The block that plugs in the wall not the sub cord. The cord was fine but not the block.\n\n\n\n### Other Answer\nSomeone ask!  I purchased my iPhone 6s Plus for 1000 from at&t.  Before I touched it, I purchased a otter defender case.  I read where at&t said touch desease was due to dropping!  Bullshit!!  I am 56 I have never dropped it!! Looks brand new!  Never dropped or abused any way!  I have my original charger.  I am going to


I have my original charger.  I am going to clean it and try everyone’s advice.  It really sucks!  I had 40,000,000 on my heart of Vegas slots!  I play every day.  I would be spinning and my fingers were no where max buttons and it would light up and switch to max.  It did it 3 times before I caught it light up by its self.  It sucks. Hope I can fix it!!!!\n\n\n\n### Other Answer\nNo answer, but same problem with iPhone 6 plus--random, self-generated jumping amongst apps and typing on its own--plus freezing regularly (aha--maybe that\'s what the "plus" in "6 plus" refers to?).  An Apple Genius recommended upgrading to iOS 11.3.1 from 11.2.2, to see if that fixed the trouble.  If it didn\'t, Apple will sell me a new phone for $168!  Of couese the OS upgrade didn\'t fix the problem.  Thanks for helping me figure out that it\'s most likely a hardware problem--which the


that it\'s most likely a hardware problem--which the "genius" probably knows too.\nI\'m getting ready to go Android.\n\n\n\n### Other Answer\nI experienced similar ghost touches.  Two weeks ago, I changed my iPhone 6 Plus shell (I had forced the phone into it because it’s pretty tight), and also put a new glass screen protector (the edges of the protector don’t stick to the screen, weird, so I brushed pressure on the edges at times to see if they may smooth out one day miraculously).  I’m not sure if I accidentally bend the phone when I installed the shell,  or, if I got a defective glass protector that messes up the touch sensor. Well, yesterday was the worse day, keeps dropping calls and ghost pressing keys for me when I was on a call.  I got fed up, so I removed the screen protector, and so far problems have not reoccurred yet. I’m crossing my fingers that problems indeed solved.\n\n\n\n### Other Answer\nthank you so much


solved.\n\n\n\n### Other Answer\nthank you so much for this post! i was struggling doing the reset because i cannot type userids and passwords correctly because the iphone 6 plus i have kept on typing letters incorrectly. I have been doing it for a day until i come across this article. Very helpful! God bless you!!\n\n\n\n### Other Answer\nI just turned it off, and turned it back on.\n\n\n\n### Other Answer\nMy problem has not gone away completely but its better now i changed my charger and turned off prediction ....,,,now it rarely happens\n\n\n\n### Other Answer\nI tried all of the above. I then turned off my home cleaned it with isopropyl alcohol 90%. Then I baked it in my oven on warm for an hour and a half over foil. Took it out and set it cool completely on the glass top stove. Then I turned on and it worked.\n\n\n\n### Other Answer\nI think at& t should man up and fix your phone for free!  You pay