Set the working directory

setwd("~/Documents/University Lessons/Year 4 Sem 1/FIT3152 Data Analytics/Assignment 3")

Library Package for The Assignment

As the text analysis is conducted in this taks, hence the library packages in relevance with the subject are worth the application.

#install.packages("tm")
#install.packages("slam")
#install.packages("SnowballC")
#install.packages("proxy")
library(tm)
## Loading required package: NLP
library(slam)
library(SnowballC)
library(proxy)
## 
## Attaching package: 'proxy'
## The following objects are masked from 'package:stats':
## 
##     as.dist, dist
## The following object is masked from 'package:base':
## 
##     as.matrix

Question 2: Corpus construction

Specified file access

As a corpus is formally defined as the collection of all documents, then it needs a series of documents that have connections with topics I am interested in. In my own case study, I obtain all resources from the movie-review-oriented platforms that discuss my subject interest (“Marvel”), but here only some areas are chosen as my once-in-a-lifetime Marvel favorite scopes encompassing Iron Man, Captain America, Thor, and Avengers. The action is actually a part of my aspiration memorized since high school.

Moving on to the required activity, there are some steps importantly playing key role for its performance. Initially, I copied each text from some platforms for the analysis. As there are 4 chosen primary topics, then I decided to copy every 5 topic-based documents to the notepad (the Windows-based text app). Therefore, my hand is supposed to hold 20 documents in total.

corpusName = file.path(".", "Marvel", "txt")
corpusName
## [1] "./Marvel/txt"

List file directories

As I want to make sure I have already created 20 documents, I need to double check firstly to ensure I have satisfied the condition of the instruction (each topic needs to have 5 documents; 20 in total)

# List all the file names
list.files(corpusName)
##  [1] "Avengers01.txt"       "Avengers02.txt"       "Avengers03.txt"      
##  [4] "Avengers04.txt"       "Avengers05.txt"       "CaptainAmerica01.txt"
##  [7] "CaptainAmerica02.txt" "CaptainAmerica03.txt" "CaptainAmerica04.txt"
## [10] "CaptainAmerica05.txt" "IronMan01.txt"        "IronMan02.txt"       
## [13] "IronMan03.txt"        "IronMan04.txt"        "IronMan05.txt"       
## [16] "Thor01.txt"           "Thor02.txt"           "Thor03.txt"          
## [19] "Thor04.txt"           "Thor05.txt"
# count how many files are in the directory
sapply(corpusName,function(dir){length(list.files(dir,pattern='txt'))})
## ./Marvel/txt 
##           20

Create a corpus

marvelDocuments = Corpus(DirSource((corpusName)))
summary(marvelDocuments)
##                      Length Class             Mode
## Avengers01.txt       2      PlainTextDocument list
## Avengers02.txt       2      PlainTextDocument list
## Avengers03.txt       2      PlainTextDocument list
## Avengers04.txt       2      PlainTextDocument list
## Avengers05.txt       2      PlainTextDocument list
## CaptainAmerica01.txt 2      PlainTextDocument list
## CaptainAmerica02.txt 2      PlainTextDocument list
## CaptainAmerica03.txt 2      PlainTextDocument list
## CaptainAmerica04.txt 2      PlainTextDocument list
## CaptainAmerica05.txt 2      PlainTextDocument list
## IronMan01.txt        2      PlainTextDocument list
## IronMan02.txt        2      PlainTextDocument list
## IronMan03.txt        2      PlainTextDocument list
## IronMan04.txt        2      PlainTextDocument list
## IronMan05.txt        2      PlainTextDocument list
## Thor01.txt           2      PlainTextDocument list
## Thor02.txt           2      PlainTextDocument list
## Thor03.txt           2      PlainTextDocument list
## Thor04.txt           2      PlainTextDocument list
## Thor05.txt           2      PlainTextDocument list

Question 3: Create Document-Term Matrix

Looking at each text

sapply(marvelDocuments, function(i) writeLines(as.character(i)))
## It’s official: May 2012 will forever be known as Joss Whedon month. Not content with co-writing and producing the best film of the year so far, the berserk horror romp ‘The Cabin in the Woods’, he’s now scripted and directed its biggest. And if ‘Avengers Assemble’ doesn’t feel quite as irreducibly Whedon-esque as ‘Cabin’, it retains enough of his trademark off-kilter wit and attention to character to set it high above your average multiplex crowd-pleaser.
## 
## For those unfamiliar with the Marvel canon, the Avengers comics unite superheroes from across the company’s roster, in this case - deep breath - Iron Man (Robert Downey Jr), Thor (Chris Hemsworth), Captain America (Chris Evans), The Incredible Hulk (Mark Ruffalo) and lesser-known caped crusaders Black Widow (Scarlett Johansson) and Hawkeye (Jeremy Renner). Brought together by Nick Fury (Samuel L Jackson) and his SHIELD organisation, these six ass-kicking egomaniacs are tasked with taking on Loki (Tom Hiddleston), who plans to flood the world with evil skeleton monsters from outer space.
## 
## It’s not rare to see a blockbuster skimp on plot, but that tendency is taken to new extremes here: the story is just a bare frame on which Whedon hangs his characters and action sequences. This can lead to problems when we realise that, Loki aside, we don’t know who the bad guys are, where they come from or what they want.
## 
## But that - and a handful of dodgy CGI effects - is the only major fault with ‘Avengers Assemble’. This is as close as cinema gets to a fairground ride: it’s shiny, noisy and exhilarating. Whedon directs with a sledgehammer, bashing the audience, Hulk-like, with action piled upon action, explosion after explosion. And if it can, at times, seem a little busy, the cumulative effect is thrilling.
## 
## But it’s no surprise that Whedon’s true strength is as a writer. Marshalling six heroes - and at least as many other key speaking roles - he delineates characters beautifully, keeping the macho-bullshit quotient high (Downey Jr and Hemsworth are good value in this department) while also allowing for a few quieter, sweeter touches, most of them courtesy of Ruffalo’s battered and defensive Hulk.
## 
## And in another break from the blockbuster norm, he manages to get the villain spot on, handing Hiddleston a gift of a role as Loki, and one of the most memorably nasty insults in recent screen history.
## 
## ‘Avengers Assemble’ may not be the Joss Whedon movie everyone remembers in 2012, but it does offer this hugely talented writer-director - too long confined to TV and the web - the opportunity (and the budget) to show what he’s capable of.
## They’re back. The chummy Marvel superheroes assemble once again to fight evil. In this case it’s Ultron, a vicious technological villain hell-bent on ridding earth of human life. There is little in this film that is new, but that doesn’t matter. The characters are still entertaining, the action scenes thrilling and near orgasmic, and the human relationships touching.
## 
## The crew, who nearly all have had movies on their own, are far more entertaining as a group: Tony Stark, aka Iron Man (Robert Downey, Jr.), Captain America (Chris Evans), Thor (Chris Hemsworth), Natasha/Black Widow (Scarlet Johansson), Dr. Banner aka The Incredible Hulk (Mark Ruffalo) and Clint/Hawkeye (Jeremy Renner) the archer. Ultron (voiced by James Spader) is an Artificial Intelligence demon, ironically an offshoot of Stark’s work. This fiend can be embodied in warrior robots that form a battalion of metal killers whose purpose is to fight the Avengers. Ultron’s ultimate goal is to annihilate the world.
## 
## There was something so fresh and novel about the first Avengers movie. Imagine if Batman, Superman, Aquaman, Wonder Woman and Flash had mobilized into one army? The first film had that kind of comic book hero nirvana. This sequel lacks that kind of spontaneity, but it eventually gels. The know-it-all Stark character and his alter ego Iron Man are much more congestible paired with others who have their own egos. Captain America seems to be the conscience of the group. But in this episode, Hawkeye steps out from a supporting role and is the father figure. He also displays a sense of humor that is catchy. Thor, also usually in the shadow of Iron Man, is on his own mission. Black Widow and The Hulk court and cultivate a romance that is engagingly flirtatious. You almost wonder if they will mate and have little Widow Hulks.
## 
## The screenplay by writer director Joss Whedon is serviceable. You can decipher what is going on and who is after whom. There are enough layers of discovery to pique interests, but the plotting is not so complicated a casual viewer can’t keep track of who needs to be killed, who is betraying a trust, who will rise to the occasion and where the storyline must go if mankind is to survive. There are necessary bumps along the road and some second-guessing. “Every time someone tries to win a war before it starts, innocent people die,” says Captain America.
## 
## Supporting actors Sam Jackson, Don Cheadle and Anthony Mackie wait in the wings and make entrances when necessary. Of the main cast, Renner seems to steal the movie. Aaron Taylor-Jackson as the speedy Quicksilver and Elizabeth Olsen as his twin sister Scarlet Witch, who has the powers of telekinesis and telepathy and messes with people’s minds, are decent add-on villains/heroes, but not all that exciting.
## 
## The technical team is up to snuff for the most part. Director of photography Ben Davis (Marvel’s “Guardians of the Galaxy”) production designer Charles Wood (Marvel’s “Guardians of the Galaxy”) and visual effects supervisor Christopher Townsend (Marvel’s “Iron Man 3”) make what you see on the screen an eyeful. Costume designer Alexandra Byrne (“Elizabeth: The Golden Age”), uses her thread wisely. Stunt coordinator Greg Powell (“Skyfall”) gets the fists to fly in the right directions. The editors, Jeffrey Ford and Lisa Lassek make 141 minutes flash by faster than Quicksilver.
## 
## If there is a flaw in this movie, it is that the casting seems dated in this day and age. Most of the A-team cast is male; all are white. The actors who are people of color are regulated to lesser, supporting roles. Viewers get a hint that the next Avengers sequel may feature the bench-warming B-team taking center stage to play the big game. That would be a welcome and modern way to move forward.
## 
## Action junkies, who thought they would have a long break between Fast & Furious 7 and the next adrenaline-pumping movie, can relax. They will get their fill of fight scenes. The most amazing is Iron Man against an out-of-control The Hulk. They tear up a city during their brotherly spat. The finale leads to a barrage of death, destruction, peril and rescues worthy of this franchise. You will leave the theater wanting more. And in a couple of years The Avengers will return, after basking in the glow of this sure to be monster hit, to fight the good fight.
## First, a bit of prophecy spoken by an evil mastermind in 2004’s ‘The Incredibles’: ‘And when everyone’s super… no one will be.’ Welcome to that endgame achieved: Marvel’s ‘Avengers: Infinity War’ - an overstuffed sausage of summer entertainment - is the ‘Ocean’s Thirteen’ of spandexed heroism, if you can imagine a version of that movie with two times as many Brad Pitts and no poker dealers. Combining the casts of 'The Avengers’, ‘Black Panther’, ‘Doctor Strange’ and ‘Guardians of the Galaxy’ may have sounded like genius alchemy to studio scientists who think of filmgoing as one-stop shopping. But in practice, it results in a stream of in-fighting for alpha-dog dominance, everyone trying to make what amounts to a cameo stick. ‘There’s an ant man and a spider-man?’ asks Mark Ruffalo’s exasperated Bruce Banner - and that’s before you’ve made him Hulk-angry.
## 
## Aptly titled, the nearly three-hour ‘Infinity War’ pours on the action - some of it grandly operatic, some of it breezy and fun - but mainly, it’s about a big purple goon on a bling quest. Genocidal Thanos (Josh Brolin, ready to grumble) hopes to collect six Infinity Stones for his Pandora bracelet and thereby enact a purge of ‘half of humanity’. Helpfully, the script does this for him: Depopulated New York City streets and the near-abstract grasslands of fictional Wakanda are perfect settings for battles with zero collateral damage-and zero human emotional stakes. In their place, we get showdowns over tactics: Asgardian bro (Chris Hemsworth) versus Star-Lordian bro (Chris Pratt); arrogant billionaire (Robert Downey Jr.) versus arrogant dark-arts beardo (Benedict Cumberbatch). When Peter Dinklage shows up as a lumbering giant with a smeltery, it feels like the movie has suddenly been whisked away by Terry Gilliam (if only).
## 
## It’s hard to give sibling co-directors Joe and Anthony Russo (makers of the thornier 'Captain America' films) any credit - or blame, really - for steering a product that’s been so corporately fine-tuned. They toggle dutifully between million-dollar quips and Wrestlemania smackdowns, and when they find room for a vista of galactic stillness, it’s not out of any inspired vision so much as the need for air. You’ll cheer the arrival of your favorite characters (my biggest whoo-hoo came with ‘Black Panther’’s ever-furious warrior woman Okoye, played by Danai Gurira). Yet the final moments ‘Infinity War’ are disquieting: Suddenly, a film that, mathematically speaking, has only been about addition learns how to divide. Inevitably, some of these Avengers are going to be swept into the dustbin, and many of them are. No spoilers here, but all it takes is a peek at forthcoming sequels to know that death is temporary. Only franchise-building is infinite.
## Arriving with the momentum that only 21 previous global blockbusters can provide, ‘Avengers: Endgame’ is the multiplex-rattling and curiously emotional culmination of the Marvel Cinematic Universe - at least until the next chapter. You know it’s going to be long (three hours, but there’s no need to sit out the end credits this time); you know it’s going to be high-level homework for even the most advanced fan. But what you don’t know is how deeply invested you may be in these 11 years of movies, a compendium of destruction and heroism that altered our culture but also reflected it, sometimes weightlessly, at other times grandly. ‘Endgame’ often pays tribute to itself, which makes it as fascinating as it is self-serious. It taps into a live wire of doomy tragedy and phoenix-like rebirth that comics do so well.
## 
## Working from an intricate screenplay by Christopher Markus and Stephen McFeely that sometimes finds a calm within the storm, the film begins (after a brief cold open for all you Hawkeye fans) just as the whole MCU did: with Robert Downey Jr’s neurotic Tony Stark grappling with his responsibilities. Downey is the actor upon which the franchise was launched in 2008’s whiz-bang ‘Iron Man’, and there’s a symmetry to giving him the floor during ‘Endgame’s downbeat early stretch - when it's an operatic grief drama in which half the world’s living creatures have blown away in clouds of dust. Cities are now ghost towns, dating is apparently a disaster and even the Hulk (Mark Ruffalo) is graying at the temples. Pay a visit to purple Malthusian universe-wrecker Thanos (Josh Brolin) and you'll find it frustratingly unsatisfying: ‘I am inevitable,’ he intones.
## 
## It’s radical for a film this huge to focus on survivors’ guilt. Between ‘Endgame’s World Trade Center-like monuments to the ‘vanished’ and our main characters' constant teary monologuing, you’ll wonder if co-directors Joe and Anthony Russo, franchise stalwarts, aren’t pointing the finger at those who would put their faith in superheroes alone (i.e., the fans themselves). Thankfully, Paul Rudd’s Ant-Man shows up at Avengers HQ with a plan to use quantum mechanics - you don’t need to know the details - and it basically allows for a cosmic do-over, along with the laughs we've come to expect from Marvel. Separate squads will go back in time to 2012’s besieged New York City, to Asgard and elsewhere, and re-collect Thanos’s killer bling, the infinity stones.
## 
## Shrewdly, ‘Endgame’ becomes a nostalgic greatest hits (complete with extra tracks), allowing for the reintroduction of some fun supporting players who make the most of their cameos, including Robert Redford, Tilda Swinton and, as Thor’s mother Frigga, Rene Russo, who advises her newly beer-gutted son to be himself and, also, eat a salad.
## 
## There’s too much of everything here, including an overlong battle that plays like an endless touch-football game, but at least the movie acknowledges its own unwieldiness. ‘You took everything from me,’ Elizabeth Olson’s Scarlet Witch hisses at Thanos, who replies, speaking for us all, ‘I don’t even know who you are.’ It’s almost a shame that, just as the MCU’s multiyear Avengers experiment has found its dramatic footing - dialing down the snark and adding cathartic contributions like Alan Silvestri’s Morricone-esque orchestral score - it’s over. ‘Endgame’ is square enough to conclude with a slow dance, but that also means its heart was, by and large, in the right place. Maybe we’ll miss being exhausted by these movies.
## It's a film that future generations will still be gushing about, much like previous generations did with such classics as Star Wars and Indiana Jones. It may not be perfect, but The Avengers lives up to its promise and delivers quite a punch. I feel The Avenger struggles as most superhero movies do with finding a way to naturally introduce its characters in a way that doesn't seem forced or formulaic. They do a decent job for what it is, but there are certain times you will feel the campiness of older works coming on as you view the film, and truly you just have to sit through it to get to the action that eventually will be at hand. Besides that though, there isn't many flaws. The acting is rather good, Samuel L. Jackson may take a line too seriously or too, but it's all in good fun. Again Tom Hiddleston as Loki is a major standout, and I also enjoyed the return of Robert Downey Jr.'s Iron Man and Chris Hemsworth Thor- as well as an improved performance by Chris Evans as Captain America and a great performance from replacement Hulk actor Mark Ruffalo. The action scenes are exciting and tense, there is some camera angles here and there that can be a bit annoying, but for the most part it is rather clear and not awfully tedious action- as many films of this type could be. In the end, despite its campiness and formulaic actions- The Avengers is an incredibly fun time. It takes pride in its stories and characters and makes the most out of an experience that could have easily been phoned in. Its a film that will live on for some time, and one I’m rather glad I got to experience first hand.
## It feels fair to say that when ‘Captain America’ was first announced, no one outside of the 50 states was expecting anything special. As the film’s subtitle alleges, the Captain may be ‘The First Avenger’ but he’s still a patriotic prat in tights whose main powers, much like the real-world superpower that spawned him, seem to be excessive arrogance and blunt force. So respect is due to Joe Johnston and his screenwriters for not only fashioning a nifty, highly entertaining slice of pulpy comic-book action, but for making this most divisive of costumed crusaders universally relatable.
## 
## The film’s period setting helps: by taking the character back to his mid-’40s roots and pitting him against history’s most hissable villains, the Nazis, the filmmakers have neatly sidestepped questions of American imperialism. They even take a few witty potshots at patriotic fervour in a terrific mid-film musical sequence, as our genetically buffed-up, weed-turned-warrior hero, Steve Rogers (Chris Evans), traverses the country selling war bonds and bopping a comedy Adolf on the nose to the delight of baying crowds.
## 
## But, with this sticking point out of the way, the film has other problems to contend with: the action scenes are inventive and well constructed but can feel somewhat slight; the characters are well sketched but far too plentiful; and the 3D effects are blurry and confusing - if you can catch this in 2D, you probably should. Most damagingly of all, ‘Captain America’, like ‘Iron Man 2’ and ‘Thor’ before it, is hamstrung by its commitment to the upcoming Marvel superhero ensemble movie, ‘The Avengers’, leading to a deeply unsatisfying non-sequitur ending. The result is pacy and punchy, but not quite a knockout.
## With his biceps and righteousness pumped to the max, Chris Evans’s superhero Captain America is an enjoyable square peg in the round hole of the sleek Marvel universe. That continues in this involving sequel to 2011’s WW2-set ‘Captain America: The First Avenger’, placing the character in an unusually shady political landscape.
## 
## We’re in present-day Washington, DC, a faintly utopian place where glass buildings gleam and Steve Rogers (Evans) can befriend former army supersoldier Sam (Anthony Mackie) during a pleasant morning’s jog. But it’s also the site of a massive military build-up: three huge ‘helicarriers’ are stored under the city’s river, primed to pry into people’s privacy a bit too impressively. Surveillance anxieties in a spandex-clad comic-book blockbuster?
## 
## Just as you’re savouring the hint of an ethically compromised, eye-patched Nick Fury (Samuel L Jackson), along comes the film’s secret weapon. Robert Redford plays against lefty type as an ominous high-ranking official thrilled by his new toys. Too quickly to generate proper suspense (yet causing plenty of giddy disbelief), ‘The Winter Soldier’ nods to ’70s classics ‘The Parallax View’ and ‘Three Days of the Condor’. It results in a vertiginous, turned-over action epic where US senators whisper allegiance to terrorist organisation Hydra and good guys are on the run.
## 
## The Marvel faithful will turn up for the action scenes, and the directors, brothers Anthony and Joe Russo, add an uncommon sharpness to sequences of urban warfare - ‘Heat’-grade bullet volleys have a real ping to them. But unlike the magically well-balanced ‘The Avengers’ (2012), there’s a touch of character bloat here: the title actually alludes to a vicious steel-armed threat (Sebastian Stan) who never quite develops into a distinct opponent. Scarlett Johansson doesn’t have a hard time commanding attention as Black Widow, though you’d think she would have earned a more complex role by now. Still, this instalment delivers a heavy and welcome dose of paranoia, administered between fleetly paced smackdowns.
## Marvel's latest superhero epic sees Captain America pitched against Iron Man - and the result is an enjoyable feast of action, humour and ideas
## 
## Does any of this sound familiar? Two iconic heroes duking it out over two-and-a-half epic hours… Angsty agonising over the collateral damage that ensues… Cameos from multiple costumed crusaders, just to make sure we’re suitably hyped for the next ten movies. But luckily, ‘Captain America: Civil War’ is packed to bursting with the one ingredient its rival superhero smackdown ‘Batman v Superman’ lacked: joy.
## 
## Which isn’t to say ‘Civil War’ is threat-free and happy-clappy. This is a film about the violent end of a friendship and the moral questions that come with free will, so it’s hardly a party. No, this is the kind of joy that comes with crafting characters people can relate to, with designing action scenes that spring and spin and bound off the screen, with picking just the right moment for a tension-breaking gag, a pause for reflection or a rousing speech. It's the joy of making a movie for and about people.
## 
## We find our heroes at a crossroads. The earth-shattering events of ‘Avengers: Age of Ultron’ have left the authorities - and many of the Avengers - questioning their role in world affairs. Enter William Hurt’s politician with an ultimatum: submit to UN oversight, or cease all crimefighting activities. Ridden with guilt, Tony Stark (Robert Downey Jr) agrees. But Steve Rogers (Chris Evans) isn’t sold, especially as the first order of business is to eliminate his childhood friend-turned-crazed assassin, Bucky Barnes (Sebastian Stan).
## 
## None of this is especially original - the ‘Watchmen’ comics covered similar ground three decades ago. But it’s rich pickings for character conflict, and that’s what ‘Civil War’ cares most about: not just between Cap and Iron Man, but between dimension-benders Scarlet Witch (Elizabeth Olsen) and Vision (Paul Bettany), between old friends Black Widow (Scarlett Johansson) and Hawkeye (Jeremy Renner), and between newcomer Black Panther (Chadwick Boseman) and basically everyone. But fear not, there’s also some light relief in the form of Ant-Man (Paul Rudd) and a nerdy teenage Spider-Man (Tom Holland).
## Well, for starters, Captain America is a major hunk. Major. Hunk. Need I repeat that? I remember reading a review of Thor where the writer was repeatedly saying how much of a hunk Thor was. For me, Chris Hemsworth (the actor who plays Thor) is absolutely no match for Chris Evans (the actor who plays Captain America) when it comes to hunkiness. Chris Hemsworth has a bit of a sneer about his face. Chris Evans has both the build of a strong man and the face of a good one. There's no beating that, really. But let us move on from superficialities and talk about the actual film.
## 
## I was a bit worried when I sat down to watch Captain America, to be honest. Watching it was definitely not something on my to-do list, and if it were up to me, I probably would have chosen another film (one of my friends was very excited as to how "craptastic" it would be). I had also watched Transformers: Dark of the Moon recently, and even though I was a major follower of the first two films, I was so bored that I actually wanted to sleep during the movie. I blame some of that on watching too many movies in the cinemas lately, and on the early start that morning. Anyhow, after the Transformers experience, I was hesitant to go back to the theatre, for fear of getting bored and tired again. But much to my surprise, I found Captain America rather engaging.
## 
## Captain America was beautifully shot with a 1940s feel. The costumes, the make-up, and the sets all played their part to make Captain America look more like a historical film than a superhero film. What I found particularly interesting about Captain America was that there was a rather large element of male makeover in the film. There are always countless movies where less-than-attractive girls are somehow made the most popular girls of their respective schools, but there are few (if any) movies where a guy gets the makeover instead. It was confounding to watch Chris Evans' transformation from skinny to yummy. Only afterwards did I realise that special effects are up to the standard nowadays where body doubles can play a significant part in the acting, only to have their heads replaced by that of the main actor.
## 
## What I loved about this film was that there was always something happening. It's a strange thing to say, but I'm sure you will know what I mean. For example, you would think that things would become less interesting once the all-important makeover takes place: but they don't. There's always something to do, there's always a new plan or a twist or turn, and there are always unanswered questions that are sometimes (and refreshingly) never answered. It is refreshing that this film glosses over some details, because it is a reminder that in life, nothing is ever shown to us quite that exactly or perfectly. We just need to work with what we've got.
## Even though it’s only 124 minutes, Captain America: The First Avenger feels like it’s two different movies. The first one - the origin story of Chris Evans as the titular hero - is really charming and fun. The movie draws you into its historical period even if the visuals aren’t fully convincing.
## 
## The second movie involves Captain America out in the field fighting against Hydra, and this section sucks. The film doesn’t have any interesting villains, and the sci-fi look of Hydra’s weapons - perhaps at least partially due to subpar visual effects - doesn’t work.
## 
## Pretty much everything is downhill after a pretty fun montage sequence of Captain America being used to sell war bonds. The action is unspectacular, and the film loses its primary appeal as it gets away from the character of Steve Rogers to deliver us this action.
## Playboy weapons magnate Tony Stark (Robert Downey Jr) is a greased amalgam of Howard Hughes, Hugh Hefner and C-3PO, complete with an enviable battery of glib banter and a goatee you could set your watch by. On a routine sales trip to the Middle East, his Humvee is ambushed by a terrorist cell and he is dragged away to a cave, where he is forced to reproduce one of his high-powered missiles with some scrap metal and a soldering iron.
## 
## Instead, Stark uses those materials to construct a suit of robotic body armour and flee from the extremists’ clutches. This channels his epiphany – perhaps long overdue – that profiteering from weapons is far from the Promethean zenith of overarching compassion he once thought it was. He returns a changed man and, with the help of his svelte assistant ‘Pepper’ (Gwyneth Paltrow) and best mate Jim Rhodes (Terrence Howard), builds a shiny suit of armour with which he plans to put an end to warfare for good.
## 
## All this liberal hand-wringing comes much to the chagrin of the sinisterly named Obadiah Stane (Jeff Bridges), Stark’s devious benefactor, who doesn’t shine to his peacenik jabbering one bit. Stane sports both a bald pate and a beard, a red flag combination in comic-book land if ever there was one.
## 
## Actor-turned-director Jon Favreau has proved with his past directorial efforts, including buddy comedy ‘Made’, Christmas film ‘Elf’ and kids’ fantasy ‘Zathura’, that he has a keen eye for character and can spin a decent yarn. Sadly, these two qualities are rarely apparent here, replaced instead by quick-fix one-liners and predictable set-piece gags. Like Iron Man’s suit, Favreau’s film feels like it has been meticulously assembled rather than lovingly formed. It’s little more than an elongated, episodic and sporadically charming introduction to the life of this mechanised millionaire superhero, light on both CGI and moral quandaries, and possessing neither the zip and sparkle of a ‘Spider-Man’ nor the brooding existential subtexts of ‘Batman Begins’.
## The ‘X-Men’, ‘Spider-Man’ and ‘Batman’ movies have proven that the second instalment is where a comic-book blockbuster series finds its feet: with all those pesky origin details out of the way, the filmmakers can focus on raising the stakes, deepening the characters and ramping up the action.
## 
## And for the first 45 minutes or so, this is where ‘Iron Man 2’ looks to be heading. Director Jon Favreau sets the stage for a titanic three-way conflagration as Tony Stark (Robert Downey Jr) is under investigation by the US government following the public revelation of his superhero persona, while his arch rival Justin Hammer (Sam Rockwell) is scrambling after his technology and mysterious, musclebound Russian physicist Ivan Vanko (Mickey Rourke) is up to unspecified no-good.
## 
## The dialogue crackles, the special effects pop and the onscreen action never flags, climaxing with an astonishing multi-car pileup at the Monaco Grand Prix, where Iron Man meets his nemesis Vanko, aka Whiplash, for the first time. So far, so excellent: Favreau builds on the solid foundations of the first movie, and success looks guaranteed. But slowly, imperceptibly, it all starts to fall apart during the remaining hour or so.
## 
## A major problem is the number of characters: Downey, Rockwell and Rourke are obviously all enjoying themselves enormously, but the same can’t be said for Don Cheadle as Stark’s redundant buddy-cum-sidekick Rhodes. Nor do the others seem to be having much fun: Gwyneth Paltrow is underused as Stark's assistant-cum-love interest Pepper Potts, while Scarlett Johanssen’s Natalie is slinky but pointless. The less said about a perfunctory appearance from Samuel L Jackson as some sort of shady inter-agency bigwig the better.
## 
## As the film plays out, it starts to look likely that all the rumours of reshoots and recuts weren’t just online rabble-rousing. Characters appear and vanish. Seemingly important plot details surface and are swept away. And this feels increasingly like a film which got lost in the edit. Whereas in the first act we jetted from Siberia to Washington to Monaco, the second half is mostly confined to a series of boardrooms, army bases and laboratories. A flat, studio-bound final showdown takes an age to arrive and is over in minutes.
## 
## ‘Iron Man 2’ is a lot of fun: it’s shiny, likeable and never boring. But it’s also wildly uneven and unnecessarily convoluted, leaving the viewer unsatisfied and hungry for something more substantial. Let’s hope a promised third instalment can fulfil the series’ undeniable potential.
## Calling ‘Iron Man 3’ a mixed bag doesn’t really do justice to the heady peaks and interminable troughs in this scrappy but overwhelmingly likeable superhero sequel. In the minus column, there’s the tedious, talky first act, the script’s uneasy attempts at psychological realism, Gwyneth Paltrow’s increasingly shrill and redundant Pepper Potts and Robert Downey Jr’s disastrously smarmy, David Gest-like facial furniture. But they’re balanced out by a handful of punchy one-liners courtesy of ‘Lethal Weapon’ scribe Shane Black, a loveable old-school, Joe Dante-ish small-town-USA central section, and a sprawling cast of reliable supporting players including Rebecca Hall, Guy Pearce, Miguel Ferrer and the great William Sadler. Towering above them all is Ben Kingsley as one of comic book cinema’s most astonishing and unlikely supervillains.
## 
## We find Tony Stark (Downey Jr) languishing in the doldrums, scarred by his experiences with the alien-battling Avengers and throwing himself into work at the expense of relationships and sleep. What’s worse, there’s a terrorist on the loose: mystery man the Mandarin (Kingsley), bent on global annihilation. After an ill-advised public throwdown followed by a helicopter attack on his plush seafront palace, Tony heads for Tennessee on the trail of a seemingly suicidal ex-soldier, and quickly learns that nothing here is at it seems…
## 
## Despite his unimpeachable screenwriting CV, this is only Black’s second film as a director (his first, 2005’s gloriously foul-mouthed crime thriller ‘Kiss Kiss Bang Bang’, also starred Downey Jr) and it shows. When he’s in his element Black delivers the goods in style, as in the scenes between Downey Jr and his temporary pre-pubescent sidekick, Harley (Ty Simpkins), or a hilarious mid-film switcheroo which may prove the summer season’s most jawdroppingly memorable moment. But he seems out of his depth during the larger set pieces: the action sequences are busy and confusing, especially the misjudged, threat-free climax.
## 
## The result is a film which never settles into a comfortable groove. It tries to be an angsty ‘Dark Knight’-style game changer, an ’80’s-throwback action romp, a nudge-wink pastiche and a CG-fuelled spectacular. It’s undeniably entertaining – and worth seeing for Kingsley alone – with the misfires never fully overshadowing the moments of glory. But in the wake of the triumph of ‘The Avengers’, ‘Iron Man 3’ still feels like something of a disappointment.
## Iron man was released in 2008. The film was written Mark Fergus and Hawk Ostby and directed by Jon Favreau. The box office hit stars Robert Downey Jr., Terrence Howard, Jeff Bridges, and Gwyneth Paltrow. The plot revolves around a genius billionaire playboy, Tony Stark, who is held captive inside of a cave in Afghanistan. To escape he creates a weaponized suit of armor to fight the forces of evil as an upcoming threat rises.
## 
## I love this film. By god I don’t think I know anyone who doesn’t. The film is 12 years old at the time that this article is published and wow, it still holds up. Everything from the sets, the CGI, the performances, even the story. The film is just great. This is definitely one of my Top 5 comic-book films of all time. I can’t get over how well the film takes it self seriously, but not too seriously. It understands the genre of movie it is. The film understands that it is supposed to be a fun action packed adventure with heart and that’s exactly what it is. Another great aspect that I love about this film is how real it is. Maybe I’m just fooling myself and being naive but the movie feels like the real world. It’s much more realistic than its other MCU counterparts, it’s almost hard to believe that this film takes place in the same universe as the others.
## 
## I was young when the movie was released. I remember sitting in the theater with my dad filled with excitement while I watched Iron Man take flight for the first time on the big screen. At that point I was more interested in the cool fight scenes and the suit. This isn’t the case anymore; now that I have rewatched the film again, I fully realized that it is a redemption story. The film is about a person who changes from a self-absorbed, egotistical businessman that doesn’t care about anyone other than himself, to a man that takes his first step towards becoming the savior of the universe.
## 
## Robert Downey Jr. makes the titular character nothing short of iconic. He’s charismatic as all hell and that’s what the audience loved to see from him. Watching his transformation from the beginning of the film to the end is like seeing two completely different people. I think that this speaks to how good of an actor RDJ really is. His transformation into the character is nothing short of seamless. His performance makes you leave the theater believing he is Iron Man Every line delivered has some form of substance to it even if it’s just playful banter. He brings life to the character and this film lays the foundation for the large imaginative universe of outlandish characters that it has in store for itself.
## 
## As far as villains go, I hate to say it but as much as I love Jeff Bridges, his villain was forgettable. Most people forget that he was even in the MCU. I personally didn’t feel like he gave his best. I felt that he was just walking through the film to get his paycheck at the end. Don’t get me wrong, he has his moments in the film, but none very memorable.
## 
## The movie is an all round good time and I highly recommend watching it as soon as possible if you have not done so (what are you waiting for? You’ve had 12 years). It’s a great starter movie for someone just starting to get into the genre and will definitely leave you thinking that there is only one true Iron man.
## Iron man was released in 2008. The film was written Mark Fergus and Hawk Ostby and directed by Jon Favreau. The box office hit stars Robert Downey Jr., Terrence Howard, Jeff Bridges, and Gwyneth Paltrow. The plot revolves around a genius billionaire playboy, Tony Stark, who is held captive inside of a cave in Afghanistan. To escape he creates a weaponized suit of armor to fight the forces of evil as an upcoming threat rises.
## 
## I love this film. By god I don’t think I know anyone who doesn’t. The film is 12 years old at the time that this article is published and wow, it still holds up. Everything from the sets, the CGI, the performances, even the story. The film is just great. This is definitely one of my Top 5 comic-book films of all time. I can’t get over how well the film takes it self seriously, but not too seriously. It understands the genre of movie it is. The film understands that it is supposed to be a fun action packed adventure with heart and that’s exactly what it is. Another great aspect that I love about this film is how real it is. Maybe I’m just fooling myself and being naive but the movie feels like the real world. It’s much more realistic than its other MCU counterparts, it’s almost hard to believe that this film takes place in the same universe as the others.
## 
## An almost unrecognisable Jeff Bridges serves the role of the villainous Obadiah Stane very well, and Terrence Howard does his best in limited screen time, which is sure to be different in future sequels (as if they wouldn’t!), since his character of Jim Rhodes dons an iron suit of his own and becomes War Machine. However, the casting of Gwyneth Paltrow as Pepper Potts is a glaring fault, for try as she might Paltrow lets off a regal vibe which goes against the films fun tone. She may be a great actress, but does not have the versatility or charisma to tackle such a light weight role, which would have been better suited for another actress. 
## 
## The various armour designs created by the magnificent Stan Winstone, along with the visual effects provided by George Lucas’s Industrial Light and Magic, are handled nicely by Favreau who desired a much more realistic and not too CGI heavy approach to his effects, which he has accomplished.
## 
## Several sequences demonstrate how well these effects look on screen: Stark’s often humorous experiments on his iron suit which feature Downey Jr. in all of his witty glory; a dogfight between Iron Man and two American fighter jets; and a spectacular but all to brief battle between Downey Jr.’s Iron Man and Bridges’ Iron Monger.
## 
## As the first film from the newly developed Marvel Studios, Iron Man is a well crafted comic adaptation that raises the bar in what was becoming a failing sub-genre.
## Is it 1987 again already? With its big hair, bulging biceps, blunt dialogue, swooning maidens, stoic heroes, shiny sets and even shinier armour, had ‘Thor’ been released a quarter of a century ago it would have had its own animated spinoff, tie-in shampoo and a range of articulated toys manufactured by Kenner. Even the basic set-up - an age-old interglactic conflict between musclebound lugs transfers to Earth and chaos ensues - feels eerily similar to the movie version of ‘Masters of the Universe’. The only thing missing is a cheeky animal sidekick.
## 
## Comic-book fans will angrily point out that this incarnation of the ancient Norse god was actually created by Marvel guru and cameo junkie Stan Lee back in the early ’60s, and that the film’s plot, which sees Thor (Chris Hemsworth) banished from Asgard by his dad Odin (Anthony Hopkins) in an effort to teach the wayward warrior a spot of humility, comes directly from the source. But it’s clear from the decor, the dialogue and the nod-and-wink execution that everyone involved knows exactly how outrageously outdated this all is, and they’re going to have a little fun with it while they can.
## 
## Not that ‘Thor’ is camp - this isn’t ‘Flash Gordon 2’, however much some of us might have enjoyed that. Like a number of recent comic-book blockbusters, it treads the line between telling an engaging story and recognising its silliness, though it does err sporadically on both sides. For every solid action set-piece or inventive digital effect, there’s a ludicrous costume choice or stupid sub-Shakespearian plot twist: pity poor Tom Hiddleston, whose role as hissable trickster Loki is little more than a daft horned helmet and a dismissive sneer.
## 
## The supporting cast fare better: while Hemsworth pouts, Hopkins barks and Natalie Portman simpers as forgettable love interest Jane Foster, it’s Stellan Skarsgaard and Kat Dennings, as Portman’s scientist sidekicks, who emerge with dignity relatively intact. Hackney’s own Idris Elba also does himself proud as taciturn gatekeeper Heimdall, but the less said about Thor’s roving pack of becoiffed back-up gods, the better.
## 
## But the big question which hangs over ‘Thor’, and one which is never satisfactorily explained, is why Kenneth Branagh? He’s never shown a penchant for action, and that isn’t remedied here: while the film’s many noisy punchups are perfectly serviceable, this is a largely anonymous piece of work, lacking any directorial stamp. And this apparent dispassion extends to the figures on screen, with precious little attention paid to character development.
## 
## But for anyone looking for a spot of mindless holiday fluff, ‘Thor’ remains an endearing throwback to simpler times: when men were men, gods were gods and heroes looked like bodybuilders who’d just raided the dress-up box. Just don’t expect to remember much about it afterwards.
## Some ingredients for making a ‘Thor’ sequel: one copy of ‘The Lord of the Rings’; one DVD of ‘Hellboy 2’; one complete set of ‘Masters of the Universe’ dolls; one footballers’ hairdressing manual from 1983; one ‘Idiot’s Guide to Norse Mythology’; and one retrospective rock album: ‘The Very Best of Yes’. This is a deeply silly, extremely noisy and sometimes impenetrable action movie that’s drowning in CGI, wild overacting and mullets. And it’s enormously entertaining.
## 
## We pick up the story shortly after events in 2012’s ‘The Avengers’: hissable horned villain Loki (Tom Hiddleston) languishes in Asgard’s deepest dungeon; bulging hero Thor (Chris Hemsworth) battles to reunite the Nine Realms; and Jane Foster (Natalie Portman) is in London studying dimensional anomalies and dating Richard (Chris O’Dowd). But it’s not long before an ancient enemy arises: this time it’s the dark elves, a gang of unpredictable intergalactic Tolkien re-enacters led by Christopher Eccleston in facepaint.
## 
## Most of what worked in 2011’s first ‘Thor’ works again: Hiddleston is campy and treacherous, Hemsworth is puppy-dog keen and there’s a nice line in knowing jokery clearly inspired by Joss Whedon’s script for ‘The Avengers’. But the first film’s shortcomings reappear too: the realm of Asgard looks like a gold-plated chocolate-box nightmare, Anthony Hopkins looks bored as uber-God Odin, and Thor’s gang of forgettable divine sidekicks do little but get in the way.
## 
## It’s when the action gets going that ‘The Dark World’ scores points over the original. This is a grander, pacier film crammed with sprawling prog-rock landscapes, masked elf armies and giant spaceships over Greenwich. And if the wormhole-hopping battle scenes do get a bit eye-frazzlingly and brain-bendingly convoluted, the best advice is just to buckle up and go with it.
## If you’ve been waiting for a superhero movie with the line, ‘Guys, we’re coming up on The Devil’s Anus’, we have very good news: Marvel’s ‘Thor: Ragnarok’ is that movie. Irreverent, helter-skelter, more colourful than an Oompa Loompa’s cheese dream and just a little off its Ragnarocker (in the best way), it has all the hallmarks of a franchise confident enough to throw the ball to the most singular filmmakers and let them run with it. 
## 
## Take a bow, then, director Taika Waititi. The New Zealander’s offbeat comic sensibility has somehow parlayed straight from indie gems like ‘What We Do in the Shadows’ and ‘Hunt for the Wilderpeople’ and on to a canvas a hundred times bigger. There are jokes galore, a headily ’80s vibe, one A-list cameo for the ages and a scene-stealing rock monster called Korg (mo-capped by Waititi himself, presumably on his day off). To crank up the giddiness levels even further, Jeff Goldblum pitches up as the hedonist Grandmaster, a kind of intergalactic Peter Stringfellow who presides over a gladiatorial arena on the glitz-sheened junk planet of Sakaar.
## 
## The story picks up two years after the events of ‘Age of Ultron’ with a lost and hammerless Thor (Chris Hemsworth, showing off his comedy chops) washing up on Sakaar, where the now perma-furious Hulk (Mark Ruffalo) is a gladiatorial hero. But it’s the Grandmaster’s unwitting match-up of the Avengers’ two waifs and strays that really stirs the plot. The pair are pitched first into screen-juddering combat, and then some tentative male bonding. There’s a lovely recurring gag about whether Thor prefers Hulk or his brainy alter ego Bruce Banner as this unusually bruising bromance takes shape. Somewhere amid the buddy-movie mayhem, and male insecurity, there’s also an Asgardian apocalypse – the titular ‘Ragnarok’ - to avert and Thor’s evil big sis Hela (Cate Blanchett, all hammy hauteur) to thwart. Tom Hiddleston’s fan favourite Loki is also back to add slippery charisma.
## 
## If ‘Ragnarok’ is the funniest Marvel movie to date - pipping ‘Guardians of the Galaxy’ and ‘Iron Man 3’ - it’s not without frustrations. The standard third act CG-fest feels leaden after the zip of what’s come before, it’s overlong and there’s arguably one too many super-powered MacGuffins (we’d have lost the Flame of Thingymajiggy). But they’re minor grumbles: in a world of portentous blockbusters getting ever darker, it’s a joy to see one throwing on the disco lights.
## Taika Waititi’s funny but uneven second Thor movie gets tantalisingly close to providing the MCU with its first straight-up comedy, before getting serious and losing its way. In standard Marvel house style, the Taika-ness - that wackadoodle energy, colour and quippiness that made Thor: Ragnarok such a ride - drains away in an over-busy middle stretch that re-ups on that old franchise preoccupation: a superbad who must be stopped from unleashing an(other) apocalypse.
## 
## Introduced by the Waititi-voiced rock warrior Korg (now rivalling Groot in the fan-favourite stakes), Chris Hemsworth’s mopey, dad-bodded Thor is soon beefing-up again to help Star-Lord (Chris Pratt) and his fellow Guardians defeat an army of furry space ferrets.
## 
## It’s a prelude to the main villain: Gorr the God Butcher, played by Christian Bale beneath layers of pale make-up that make him look like Voldemort rocking up for a Fury Road audition. As his name implies, he’s nursing a grudge against the galaxy’s entire pantheon of deities and has a certain Norse god with a blond mane and forearms like hams on his shit list.
## 
## There’s an ugly, murkily-framed action sequence in New Asgard - now part home to Asgardian refugees, part tourist attraction - that throws Thor’s old flame, Dr Jane Foster (Natalie Portman), back into the mix. She’s now the owner of Thor’s also-much-missed hammer, Mjolnir, and has newfound powers that are barely keeping a secret terminal illness at bay.
## 
## Cue some amusing scenes of neurotic hammer banter, ​​as Thor reassures his new hardware, Stormbreaker, that it’s all over between him and Mjolnir. ‘It’s you and me now, buddy,’ he vows.
## 
## The odd duff fight scene aside, Waititi is so good at this stuff, and he directs it all like a circus master eager to keep the entertainment coming. And it all works a treat for a good fifty percent of the relatively lean runtime, with some great cameos, a refreshingly pisstakey approach to mythology and an improv’y looseness that regularly delivers big laughs from all directions. For my money, Hemsworth is the best thing in the MCU and seeing him given free rein will never not be a joy.
## 
## There’s also a memorable clash between our Norse hero and his posse (this new Thor has a post-Avengers emotional need to form into teams) and Zeus, an orgy-loving waster played with camp gusto by Russell Crowe. Somewhere out in the galaxy Gorr has a bunch of Asgardian kids under lock and key (‘Team kids in a cage,’ as Thor is soon calling them), and Thor, Jane, and Korg are off to rescue them.
## 
## But all that loosey-goosey irreverence eventually dissipates in a hoop-jump of plot devices, like the Shadow Realm, the Gate of Eternity and the Yawning Chasm of Meh (okay, not the last one). And when the quartet touch down for a murky showdown on a black-and-white planet, there’s a real sense of a film losing sight of what’s making it fun in the first place.
## 
## It’s a shame because the final scene or two are as affecting as anything since The Snap, and there’s loads to enjoy in Love and Thunder, not least in its embrace of queerness - the quartet dash around the galaxy in a longboat powered by the rainbow Bifrost in what has to be an open goal for anyone planning their next Pride float - and a major effort to make Guns N’ Roses happen again. But after 29 MCU movies, is it time to mix up the formula? A bit more love and a bit less third-act thunder might be nice.
## Thor, the son of Odin, king of the Norse gods is about to inherit the throne from his aging father, but things go wrong the day he is crowned. When their enemy the Frost Giants show up in the palace against their treaty, Thor reacts with violence. His father then punishes Thor to life on Earth for his actions. His brother Loki on the other hand starts to stir the pot back home. This film was shot really well, but some scenes are shot on this angle and it’s not really explained why. It doesn’t really add or take away anything from the plot; it’s just very weird to see. The low-key romance that is between Jane and Thor is extremely cute and subtle enough that it doesn’t disrupt the main storyline. There are so many lines in this film that are extremely hilarious without trying to be funny; small subtle things are thrown in and it works so well. This film is so engrossing that the viewer just loses themselves in the story, the action and the fighting is enough to keep anyone invested, add in the sibling rivalry and the two different worlds and it’s a definite game winner. Learning of Thor and Loki’s backstory is fascinating to watch. The score made some of the scenes so much more heartbreaking than they really were. This film was so well done that it’s exciting to know there is another to look forward to.
## $Avengers01.txt
## NULL
## 
## $Avengers02.txt
## NULL
## 
## $Avengers03.txt
## NULL
## 
## $Avengers04.txt
## NULL
## 
## $Avengers05.txt
## NULL
## 
## $CaptainAmerica01.txt
## NULL
## 
## $CaptainAmerica02.txt
## NULL
## 
## $CaptainAmerica03.txt
## NULL
## 
## $CaptainAmerica04.txt
## NULL
## 
## $CaptainAmerica05.txt
## NULL
## 
## $IronMan01.txt
## NULL
## 
## $IronMan02.txt
## NULL
## 
## $IronMan03.txt
## NULL
## 
## $IronMan04.txt
## NULL
## 
## $IronMan05.txt
## NULL
## 
## $Thor01.txt
## NULL
## 
## $Thor02.txt
## NULL
## 
## $Thor03.txt
## NULL
## 
## $Thor04.txt
## NULL
## 
## $Thor05.txt
## NULL

Specific Text Transformation

Convert the abbreviation to the key word

toRDJ <- content_transformer(function(x, pattern) gsub(pattern, "RDJ", x))
marvelDocuments <- tm_map(marvelDocuments, toRDJ, "Robert Downey Jr.")

Hyphen, Quotes to space

toSpace <- content_transformer(function(x, pattern) gsub(pattern, " ", x))
marvelDocuments <- tm_map(marvelDocuments, toSpace, "-")

# Apply the transformation to replace left curly single quotes with spaces
marvelDocuments <- tm_map(marvelDocuments, toSpace, "‘")

# Apply the transformation to replace right curly single quotes with spaces
marvelDocuments <- tm_map(marvelDocuments, toSpace, "’")

Tokenization, stemming

# Tokenization
marvelDocuments <- tm_map(marvelDocuments, removeNumbers)
marvelDocuments <- tm_map(marvelDocuments, removePunctuation)
marvelDocuments <- tm_map(marvelDocuments, content_transformer(tolower))
# Filter words
marvelDocuments <- tm_map(marvelDocuments, removeWords, stopwords("english"))
marvelDocuments <- tm_map(marvelDocuments, stripWhitespace)
# Stem
marvelDocuments <- tm_map(marvelDocuments, stemDocument, language = "english")

Outcome after specific transformation, tokenization, and stemming

sapply(marvelDocuments, function(i) writeLines(as.character(i)))
## s offici may will forev known joss whedon month content co write produc best film year far berserk horror romp cabin wood s now script direct biggest aveng assembl doesn t feel quit irreduc whedon esqu cabin retain enough trademark kilter wit attent charact set high averag multiplex crowd pleaser unfamiliar marvel canon aveng comic unit superhero across compani s roster case deep breath iron man rdj thor chris hemsworth captain america chris evan incred hulk mark ruffalo lesser known cape crusad black widow scarlett johansson hawkey jeremi renner brought togeth nick furi samuel l jackson shield organis six ass kick egomaniac task take loki tom hiddleston plan flood world evil skeleton monster outer space s rare see blockbust skimp plot tendenc taken new extrem stori just bare frame whedon hang charact action sequenc can lead problem realis loki asid don t know bad guy come want hand dodgi cgi effect major fault aveng assembl close cinema get fairground ride s shini noisi exhilar whedon direct sledgehamm bash audienc hulk like action pile upon action explos explos can time seem littl busi cumul effect thrill s surpris whedon s true strength writer marshal six hero least mani key speak role delin charact beauti keep macho bullshit quotient high downey jr hemsworth good valu depart also allow quieter sweeter touch courtesi ruffalo s batter defens hulk anoth break blockbust norm manag get villain spot hand hiddleston gift role loki one memor nasti insult recent screen histori aveng assembl may joss whedon movi everyon rememb offer huge talent writer director long confin tv web opportun budget show s capable 
## re back chummi marvel superhero assembl fight evil case s ultron vicious technolog villain hell bent rid earth human life littl film new doesn t matter charact still entertain action scene thrill near orgasm human relationship touch crew near movi far entertain group toni stark aka iron man robert downey jr captain america chris evan thor chris hemsworth natashablack widow scarlet johansson dr banner aka incred hulk mark ruffalo clinthawkey jeremi renner archer ultron voic jame spader artifici intellig demon iron offshoot stark s work fiend can embodi warrior robot form battalion metal killer whose purpos fight aveng ultron s ultim goal annihil world someth fresh novel first aveng movi imagin batman superman aquaman wonder woman flash mobil one armi first film kind comic book hero nirvana sequel lack kind spontan eventu gel know stark charact alter ego iron man much congest pair other ego captain america seem conscienc group episod hawkey step support role father figur also display sens humor catchi thor also usual shadow iron man mission black widow hulk court cultiv romanc engag flirtati almost wonder will mate littl widow hulk screenplay writer director joss whedon servic can deciph go enough layer discoveri piqu interest plot complic casual viewer can t keep track need kill betray trust will rise occas storylin must go mankind surviv necessari bump along road second guess “everi time someon tri win war start innoc peopl die” say captain america support actor sam jackson don cheadl anthoni macki wait wing make entranc necessari main cast renner seem steal movi aaron taylor jackson speedi quicksilv elizabeth olsen twin sister scarlet witch power telekinesi telepathi mess peopl s mind decent add villainshero excit technic team snuff part director photographi ben davi marvel s “guardian galaxy” product design charl wood marvel s “guardian galaxy” visual effect supervisor christoph townsend marvel s “iron man ” make see screen eye costum design alexandra byrn “elizabeth golden age” use thread wise stunt coordin greg powel “skyfall” get fist fli right direct editor jeffrey ford lisa lassek make minut flash faster quicksilv flaw movi cast seem date day age team cast male white actor peopl color regul lesser support role viewer get hint next aveng sequel may featur bench warm b team take center stage play big game welcom modern way move forward action junki thought long break fast furious next adrenalin pump movi can relax will get fill fight scene amaz iron man control hulk tear citi brother spat final lead barrag death destruct peril rescu worthi franchis will leav theater want coupl year aveng will return bask glow sure monster hit fight  good fight
## first bit propheci spoken evil mastermind s incred everyon s super… one will welcom endgam achiev marvel s aveng infin war overstuf sausag summer entertain ocean s thirteen spandex heroism can imagin version movi two time mani brad pitt poker dealer combin cast aveng black panther doctor strang guardian galaxi may sound like genius alchemi studio scientist think filmgo one stop shop practic result stream fight alpha dog domin everyon tri make amount cameo stick s ant man spider man ask mark ruffalo s exasper bruce banner s ve made hulk angri apt titl near three hour infin war pour action grand operat breezi fun main s big purpl goon bling quest genocid thano josh brolin readi grumbl hope collect six infin stone pandora bracelet therebi enact purg half human help script depopul new york citi street near abstract grassland fiction wakanda perfect set battl zero collater damag zero human emot stake place get showdown tactic asgardian bro chris hemsworth versus star lordian bro chris pratt arrog billionair rdj versus arrog dark art beardo benedict cumberbatch peter dinklag show lumber giant smelteri feel like movi sudden whisk away terri gilliam s hard give sibl co director joe anthoni russo maker thornier captain america film credit blame realli steer product s corpor fine tune toggl duti million dollar quip wrestlemania smackdown find room vista galact still s inspir vision much need air ll cheer arriv favorit charact biggest whoo hoo came black panther s ever furious warrior woman okoy play danai gurira yet final moment infin war disquiet sudden film mathemat speak addit learn divid inevit aveng go swept dustbin mani spoiler take peek forthcom sequel know death temporari franchis building  infinit
## arriv momentum previous global blockbust can provid aveng endgam multiplex rattl curious emot culmin marvel cinemat univers least next chapter know s go long three hour s need sit end credit time know s go high level homework even advanc fan don t know deepli invest may year movi compendium destruct heroism alter cultur also reflect sometim weightless time grand endgam often pay tribut make fascin self serious tap live wire doomi tragedi phoenix like rebirth comic well work intric screenplay christoph markus stephen mcfeeli sometim find calm within storm film begin brief cold open hawkey fan just whole mcu rdjs neurot toni stark grappl respons downey actor upon franchis launch s whiz bang iron man s symmetri give floor endgam s downbeat earli stretch operat grief drama half world s live creatur blown away cloud dust citi now ghost town date appar disast even hulk mark ruffalo gray templ pay visit purpl malthusian univers wrecker thano josh brolin youll find frustrat unsatisfi inevit inton s radic film huge focus survivor guilt endgam s world trade center like monument vanish main charact constant teari monologu ll wonder co director joe anthoni russo franchis stalwart aren t point finger put faith superhero alon ie fan thank paul rudd s ant man show aveng hq plan use quantum mechan don t need know detail basic allow cosmic along laugh weve come expect marvel separ squad will go back time s besieg new york citi asgard elsewher re collect thano s killer bling infin stone shrewd endgam becom nostalg greatest hit complet extra track allow reintroduct fun support player make cameo includ robert redford tilda swinton thor s mother frigga rene russo advis newli beer gut son also eat salad s much everyth includ overlong battl play like endless touch footbal game least movi acknowledg unwieldi took everyth elizabeth olson s scarlet witch hiss thano repli speak us don t even know s almost shame just mcu s multiyear aveng experi found dramat foot dial snark ad cathart contribut like alan silvestri s morricon esqu orchestr score s endgam squar enough conclud slow danc also mean heart larg right place mayb ll miss exhaust   movi
## film futur generat will still gush much like previous generat classic star war indiana jone may perfect aveng live promis deliv quit punch feel aveng struggl superhero movi find way natur introduc charact way doesnt seem forc formula decent job certain time will feel campi older work come view film truli just sit get action eventu will hand besid though isnt mani flaw act rather good samuel l jackson may take line serious good fun tom hiddleston loki major standout also enjoy return rdjs iron man chris hemsworth thor well improv perform chris evan captain america great perform replac hulk actor mark ruffalo action scene excit tens camera angl can bit annoy part rather clear aw tedious action mani film type end despit campi formula action aveng incred fun time take pride stori charact make experi easili phone film will live time one m rather glad got experience first hand
## feel fair say captain america first announc one outsid state expect anyth special film s subtitl alleg captain may first aveng s still patriot prat tight whose main power much like real world superpow spawn seem excess arrog blunt forc respect due joe johnston screenwrit fashion nifti high entertain slice pulpi comic book action make divis costum crusad univers relat film s period set help take charact back mid s root pit histori s hissabl villain nazi filmmak neat sidestep question american imperi even take witti potshot patriot fervour terrif mid film music sequenc genet buf weed turn warrior hero steve roger chris evan travers countri sell war bond bop comedi adolf nose delight bay crowd stick point way film problem contend action scene invent well construct can feel somewhat slight charact well sketch far plenti d effect blurri confus can catch d probabl damag captain america like iron man thor hamstrung commit upcom marvel superhero ensembl movi aveng lead deepli unsatisfi non sequitur end result paci punchi quite  knockout
## bicep righteous pump max chris evan s superhero captain america enjoy squar peg round hole sleek marvel univers continu involv sequel s ww set captain america first aveng place charact unusu shadi polit landscap re present day washington dc faint utopian place glass build gleam steve roger evan can befriend former armi supersoldi sam anthoni macki pleasant morn s jog s also site massiv militari build three huge helicarri store citi s river prime pri peopl s privaci bit impress surveil anxieti spandex clad comic book blockbust just re savour hint ethic compromis eye patch nick furi samuel l jackson along come film s secret weapon robert redford play lefti type omin high rank offici thrill new toy quick generat proper suspens yet caus plenti giddi disbelief winter soldier nod s classic parallax view three day condor result vertigin turn action epic us senat whisper allegi terrorist organis hydra good guy run marvel faith will turn action scene director brother anthoni joe russo add uncommon sharp sequenc urban warfar heat grade bullet volley real ping unlik magic well balanc aveng s touch charact bloat titl actual allud vicious steel arm threat sebastian stan never quit develop distinct oppon scarlett johansson doesn t hard time command attent black widow though d think earn complex role now still instal deliv heavi welcom dose paranoia administ fleet paced smackdown
## marvel latest superhero epic see captain america pitch iron man result enjoy feast action humour idea sound familiar two icon hero duke two half epic hours… angsti agonis collater damag ensues… cameo multipl costum crusad just make sure re suitabl hype next ten movi luckili captain america civil war pack burst one ingredi rival superhero smackdown batman v superman lack joy isn t say civil war threat free happi clappi film violent end friendship moral question come free will s hard parti kind joy come craft charact peopl can relat design action scene spring spin bound screen pick just right moment tension break gag paus reflect rous speech joy make movi peopl find hero crossroad earth shatter event aveng age ultron left author mani aveng question role world affair enter william hurt s politician ultimatum submit un oversight ceas crimefight activ ridden guilt toni stark rdj agre steve roger chris evan isn t sold especi first order busi elimin childhood friend turn craze assassin bucki barn sebastian stan none especi origin watchmen comic cover similar ground three decad ago s rich pick charact conflict s civil war care just cap iron man dimens bender scarlet witch elizabeth olsen vision paul bettani old friend black widow scarlett johansson hawkey jeremi renner newcom black panther chadwick boseman basic everyon fear s also light relief form ant man paul rudd nerdi teenag spider man tom holland
## well starter captain america major hunk major hunk need repeat rememb read review thor writer repeat say much hunk thor chris hemsworth actor play thor absolut match chris evan actor play captain america come hunki chris hemsworth bit sneer face chris evan build strong man face good one there beat realli let us move superfici talk actual film bit worri sat watch captain america honest watch definit someth list probabl chosen anoth film one friend excit craptast also watch transform dark moon recent even though major follow first two film bore actual want sleep movi blame watch mani movi cinema late earli start morn anyhow transform experi hesit go back theatr fear get bore tire much surpris found captain america rather engag captain america beauti shot s feel costum make set play part make captain america look like histor film superhero film found particular interest captain america rather larg element male makeov film alway countless movi less attract girl somehow made popular girl respect school movi guy get makeov instead confound watch chris evan transform skinni yummi afterward realis special effect standard nowaday bodi doubl can play signific part act head replac main actor love film alway someth happen strang thing say im sure will know mean exampl think thing becom less interest import makeov take place dont there alway someth there alway new plan twist turn alway unansw question sometim refresh never answer refresh film gloss detail remind life noth ever shown us quit exact perfect just need work   weve got
## even though s minut captain america first aveng feel like s two differ movi first one origin stori chris evan titular hero realli charm fun movi draw histor period even visual aren t fulli convinc second movi involv captain america field fight hydra section suck film doesn t interest villain sci fi look hydra s weapon perhap least partial due subpar visual effect doesn t work pretti much everyth downhil pretti fun montag sequenc captain america use sell war bond action unspectacular film lose primari appeal get away charact steve roger deliver us  act
## playboy weapon magnat toni stark rdj greas amalgam howard hugh hugh hefner c po complet enviabl batteri glib banter goate set watch routin sale trip middl east humve ambush terrorist cell drag away cave forc reproduc one high power missil scrap metal solder iron instead stark use materi construct suit robot bodi armour flee extremist clutch channel epiphani – perhap long overdu – profit weapon far promethean zenith overarch compass thought return chang man help svelt assist pepper gwyneth paltrow best mate jim rhode terrenc howard build shini suit armour plan put end warfar good liber hand wring come much chagrin sinist name obadiah stane jeff bridg stark s devious benefactor doesn t shine peacenik jabber one bit stane sport bald pate beard red flag combin comic book land ever one actor turn director jon favreau prove past directori effort includ buddi comedi made christma film elf kid fantasi zathura keen eye charact can spin decent yarn sad two qualiti rare appar replac instead quick fix one liner predict set piec gag like iron man s suit favreau s film feel like meticul assembl rather love form s littl elong episod sporad charm introduct life mechanis millionair superhero light cgi moral quandari possess neither zip sparkl spider man brood existenti subtext batman begin
## x men spider man batman movi proven second instal comic book blockbust seri find feet peski origin detail way filmmak can focus rais stake deepen charact ramp action first minut iron man look head director jon favreau set stage titan three way conflagr toni stark rdj investig us govern follow public revel superhero persona arch rival justin hammer sam rockwel scrambl technolog mysteri musclebound russian physicist ivan vanko mickey rourk unspecifi good dialogu crackl special effect pop onscreen action never flag climax astonish multi car pileup monaco grand prix iron man meet nemesi vanko aka whiplash first time far excel favreau build solid foundat first movi success look guarante slowli impercept start fall apart remain hour major problem number charact downey rockwel rourk obvious enjoy enorm can t said don cheadl stark s redund buddi cum sidekick rhode other seem much fun gwyneth paltrow underus stark assist cum love interest pepper pott scarlett johanssen s natali slinki pointless less said perfunctori appear samuel l jackson sort shadi inter agenc bigwig better film play start look like rumour reshoot recut weren t just onlin rabbl rous charact appear vanish seem import plot detail surfac swept away feel increas like film got lost edit wherea first act jet siberia washington monaco second half most confin seri boardroom armi base laboratori flat studio bound final showdown take age arriv minut iron man lot fun s shini likeabl never bore s also wild uneven unnecessarili convolut leav viewer unsatisfi hungri someth substanti let s hope promis third instal can fulfil seri undeniable potenti
## call iron man mix bag doesn t realli justic headi peak intermin trough scrappi overwhelm likeabl superhero sequel minus column s tedious talki first act script s uneasi attempt psycholog realism gwyneth paltrow s increas shrill redund pepper pott rdjs disastr smarmi david gest like facial furnitur re balanc hand punchi one liner courtesi lethal weapon scribe shane black loveabl old school joe dant ish small town usa central section sprawl cast reliabl support player includ rebecca hall guy pearc miguel ferrer great william sadler tower ben kingsley one comic book cinema s astonish unlik supervillain find toni stark downey jr languish doldrum scar experi alien battl aveng throw work expens relationship sleep s wors s terrorist loos mysteri man mandarin kingsley bent global annihil ill advis public throwdown follow helicopt attack plush seafront palac toni head tennesse trail seem suicid ex soldier quick learn noth seems… despit unimpeach screenwrit cv black s second film director first s glorious foul mouth crime thriller kiss kiss bang bang also star downey jr show s element black deliv good style scene downey jr temporari pre pubesc sidekick harley ty simpkin hilari mid film switcheroo may prove summer season s jawdrop memor moment seem depth larger set piec action sequenc busi confus especi misjudg threat free climax result film never settl comfort groov tri angsti dark knight style game changer s throwback action romp nudg wink pastich cg fuell spectacular s undeni entertain – worth see kingsley alon – misfir never fulli overshadow moment glori wake triumph aveng iron man still feel like someth  disappoint
## iron man releas film written mark fergus hawk ostbi direct jon favreau box offic hit star rdj terrenc howard jeff bridg gwyneth paltrow plot revolv around genius billionair playboy toni stark held captiv insid cave afghanistan escap creat weapon suit armor fight forc evil upcom threat rise love film god don t think know anyon doesn t film year old time articl publish wow still hold everyth set cgi perform even stori film just great definit one top comic book film time can t get well film take self serious serious understand genr movi film understand suppos fun action pack adventur heart s exact anoth great aspect love film real mayb m just fool naiv movi feel like real world s much realist mcu counterpart s almost hard believ film take place univers other young movi releas rememb sit theater dad fill excit watch iron man take flight first time big screen point interest cool fight scene suit isn t case anymor now rewatch film fulli realiz redempt stori film person chang self absorb egotist businessman doesn t care anyon man take first step toward becom savior univers rdj make titular charact noth short icon s charismat hell s audienc love see watch transform begin film end like see two complet differ peopl think speak good actor rdj realli transform charact noth short seamless perform make leav theater believ iron man everi line deliv form substanc even s just play banter bring life charact film lay foundat larg imagin univers outlandish charact store far villain go hate say much love jeff bridg villain forgett peopl forget even mcu person didn t feel like gave best felt just walk film get paycheck end don t get wrong moment film none memor movi round good time high recommend watch soon possibl done wait ve year s great starter movi someon just start get genr will definit leav think one true iron man
## iron man releas film written mark fergus hawk ostbi direct jon favreau box offic hit star rdj terrenc howard jeff bridg gwyneth paltrow plot revolv around genius billionair playboy toni stark held captiv insid cave afghanistan escap creat weapon suit armor fight forc evil upcom threat rise love film god don t think know anyon doesn t film year old time articl publish wow still hold everyth set cgi perform even stori film just great definit one top comic book film time can t get well film take self serious serious understand genr movi film understand suppos fun action pack adventur heart s exact anoth great aspect love film real mayb m just fool naiv movi feel like real world s much realist mcu counterpart s almost hard believ film take place univers other almost unrecognis jeff bridg serv role villain obadiah stane well terrenc howard best limit screen time sure differ futur sequel wouldn t sinc charact jim rhode don iron suit becom war machin howev cast gwyneth paltrow pepper pott glare fault tri might paltrow let regal vibe goe film fun tone may great actress versatil charisma tackl light weight role better suit anoth actress various armour design creat magnific stan winston along visual effect provid georg luca s industri light magic handl nice favreau desir much realist cgi heavi approach effect accomplish sever sequenc demonstr well effect look screen stark s often humor experi iron suit featur downey jr witti glori dogfight iron man two american fighter jet spectacular brief battl downey jr s iron man bridg iron monger first film newli develop marvel studio iron man well craft comic adapt rais bar becom failing sub genr
## alreadi big hair bulg bicep blunt dialogu swoon maiden stoic hero shini set even shinier armour thor releas quarter centuri ago anim spinoff tie shampoo rang articul toy manufactur kenner even basic set age old interglact conflict musclebound lug transfer earth chao ensu feel eerili similar movi version master univers thing miss cheeki anim sidekick comic book fan will angrili point incarn ancient nors god actual creat marvel guru cameo junki stan lee back earli s film s plot see thor chris hemsworth banish asgard dad odin anthoni hopkin effort teach wayward warrior spot humil come direct sourc s clear decor dialogu nod wink execut everyon involv know exact outrag outdat re go littl fun can thor camp isn t flash gordon howev much us might enjoy like number recent comic book blockbust tread line tell engag stori recognis silli though err sporad side everi solid action set piec invent digit effect s ludicr costum choic stupid sub shakespearian plot twist piti poor tom hiddleston whose role hissabl trickster loki littl daft horn helmet dismiss sneer support cast fare better hemsworth pout hopkin bark natali portman simper forgett love interest jane foster s stellan skarsgaard kat den portman s scientist sidekick emerg digniti relat intact hackney s idri elba also proud taciturn gatekeep heimdal less said thor s rove pack becoif back god better big question hang thor one never satisfactorili explain kenneth branagh s never shown penchant action isn t remedi film s mani noisi punchup perfect servic larg anonym piec work lack directori stamp appar dispass extend figur screen precious littl attent paid charact develop anyon look spot mindless holiday fluff thor remain endear throwback simpler time men men god god hero look like bodybuild d just raid dress box just don t expect rememb much   afterward
## ingredi make thor sequel one copi lord ring one dvd hellboy one complet set master univers doll one footbal hairdress manual one idiot s guid nors mytholog one retrospect rock album best yes deepli silli extrem noisi sometim impenetr action movi s drown cgi wild overact mullet s enorm entertain pick stori short event s aveng hissabl horn villain loki tom hiddleston languish asgard s deepest dungeon bulg hero thor chris hemsworth battl reunit nine realm jane foster natali portman london studi dimension anomali date richard chris o dowd s long ancient enemi aris time s dark elv gang unpredict intergalact tolkien re enact led christoph eccleston facepaint work s first thor work hiddleston campi treacher hemsworth puppi dog keen s nice line know jokeri clear inspir joss whedon s script aveng first film s shortcom reappear realm asgard look like gold plate chocol box nightmar anthoni hopkin look bore uber god odin thor s gang forgett divin sidekick littl get way s action get go dark world score point origin grander pacier film cram sprawl prog rock landscap mask elf armi giant spaceship greenwich wormhol hop battl scene get bit eye frazzl brain bend convolut best advic just buckl   go  
## ve wait superhero movi line guy re come devil s anus good news marvel s thor ragnarok movi irrever helter skelter colour oompa loompa s chees dream just littl ragnarock best way hallmark franchis confid enough throw ball singular filmmak let run take bow director taika waititi new zealand s offbeat comic sensibl somehow parlay straight indi gem like shadow hunt wilderpeopl canva hundr time bigger joke galor headili s vibe one list cameo age scene steal rock monster call korg mo cap waititi presum day crank giddi level even jeff goldblum pitch hedonist grandmast kind intergalact peter stringfellow presid gladiatori arena glitz sheen junk planet sakaar stori pick two year event age ultron lost hammerless thor chris hemsworth show comedi chop wash sakaar now perma furious hulk mark ruffalo gladiatori hero s grandmast s unwit match aveng two waif stray realli stir plot pair pitch first screen judder combat tentat male bond s love recur gag whether thor prefer hulk braini alter ego bruce banner unusu bruis bromanc take shape somewher amid buddi movi mayhem male insecur s also asgardian apocalyps – titular ragnarok avert thor s evil big sis hela cate blanchett hammi hauteur thwart tom hiddleston s fan favourit loki also back add slipperi charisma ragnarok funniest marvel movi date pip guardian galaxi iron man s without frustrat standard third act cg fest feel leaden zip s come s overlong s arguabl one mani super power macguffin d lost flame thingymajiggi re minor grumbl world portent blockbust get ever darker s joy see one throw  disco light
## taika waititi s funni uneven second thor movi get tantalis close provid mcu first straight comedi get serious lose way standard marvel hous style taika ness wackadoodl energi colour quippi made thor ragnarok ride drain away busi middl stretch re up old franchis preoccup superbad must stop unleash anoth apocalyps introduc waititi voic rock warrior korg now rival groot fan favourit stake chris hemsworth s mopey dad bod thor soon beef help star lord chris pratt fellow guardian defeat armi furri space ferret s prelud main villain gorr god butcher play christian bale beneath layer pale make make look like voldemort rock furi road audit name impli s nurs grudg galaxi s entir pantheon deiti certain nors god blond mane forearm like ham shit list s ugli murkili frame action sequenc new asgard now part home asgardian refuge part tourist attract throw thor s old flame dr jane foster natali portman back mix s now owner thor s also much miss hammer mjolnir newfound power bare keep secret termin ill bay cue amus scene neurot hammer banter ​​ thor reassur new hardwar stormbreak s mjolnir s now buddi vow odd duff fight scene asid waititi good stuff direct like circus master eager keep entertain come work treat good fifti percent relat lean runtim great cameo refresh pisstakey approach mytholog improv y loos regular deliv big laugh direct money hemsworth best thing mcu see given free rein will never joy s also memor clash nors hero poss new thor post aveng emot need form team zeus orgi love waster play camp gusto russel crow somewher galaxi gorr bunch asgardian kid lock key team kid cage thor soon call thor jane korg rescu loosey goosey irrever eventu dissip hoop jump plot devic like shadow realm gate etern yawn chasm meh okay last one quartet touch murki showdown black white planet s real sens film lose sight s make fun first place s shame final scene two affect anyth sinc snap s load enjoy love thunder least embrac queer quartet dash around galaxi longboat power rainbow bifrost open goal anyon plan next pride float major effort make gun n rose happen mcu movi time mix formula bit love bit less third act thunder might  nic
## thor son odin king nors god inherit throne age father thing go wrong day crown enemi frost giant show palac treati thor react violenc father punish thor life earth action brother loki hand start stir pot back home film shot realli well scene shot angl s realli explain doesn t realli add take away anyth plot s just weird see low key romanc jane thor extrem cute subtl enough doesn t disrupt main storylin mani line film extrem hilari without tri funni small subtl thing thrown work well film engross viewer just lose stori action fight enough keep anyon invest add sibl rivalri two differ world s definit game winner learn thor loki s backstori fascin watch score made scene much heartbreak realli film well done s excit know anoth look forward 
## $Avengers01.txt
## NULL
## 
## $Avengers02.txt
## NULL
## 
## $Avengers03.txt
## NULL
## 
## $Avengers04.txt
## NULL
## 
## $Avengers05.txt
## NULL
## 
## $CaptainAmerica01.txt
## NULL
## 
## $CaptainAmerica02.txt
## NULL
## 
## $CaptainAmerica03.txt
## NULL
## 
## $CaptainAmerica04.txt
## NULL
## 
## $CaptainAmerica05.txt
## NULL
## 
## $IronMan01.txt
## NULL
## 
## $IronMan02.txt
## NULL
## 
## $IronMan03.txt
## NULL
## 
## $IronMan04.txt
## NULL
## 
## $IronMan05.txt
## NULL
## 
## $Thor01.txt
## NULL
## 
## $Thor02.txt
## NULL
## 
## $Thor03.txt
## NULL
## 
## $Thor04.txt
## NULL
## 
## $Thor05.txt
## NULL

Create Document Term Matrix

marvel.dtm <- DocumentTermMatrix(marvelDocuments)
inspect(marvel.dtm[1:20, 1:4])
## <<DocumentTermMatrix (documents: 20, terms: 4)>>
## Non-/sparse entries: 31/49
## Sparsity           : 61%
## Maximal term length: 6
## Weighting          : term frequency (tf)
## Sample             :
##                       Terms
## Docs                   across action allow also
##   Avengers01.txt            1      3     1    1
##   Avengers02.txt            0      2     0    2
##   Avengers04.txt            0      0     2    3
##   Avengers05.txt            0      4     0    1
##   CaptainAmerica02.txt      0      2     0    1
##   CaptainAmerica03.txt      0      2     0    1
##   IronMan02.txt             0      2     0    1
##   IronMan03.txt             0      2     0    1
##   Thor01.txt                0      2     0    1
##   Thor04.txt                0      1     0    2

Term frequencies

marvel_word_frequencies <- colSums(as.matrix(marvel.dtm))
length(marvel_word_frequencies)
## [1] 2063

The total of different unique tokens is 2063

The order of frequencies of each word

# reorder them in ascending way
ord = order(marvel_word_frequencies)
print("The lowest frequency")
## [1] "The lowest frequency"
marvel_word_frequencies[head(ord)]
## across    ass averag    bad   bash batter 
##      1      1      1      1      1      1
print("The highest frequency")
## [1] "The highest frequency"
marvel_word_frequencies[tail(ord)]
## aveng  like   man  thor  movi  film 
##    30    30    35    37    38    69

Visualize the number of words

marvel_word_frequencies = as.data.frame(as.table(marvel_word_frequencies))
n_marvel_word_frequencies <- marvel_word_frequencies[order(-marvel_word_frequencies$Freq),]
n_marvel_word_frequencies = n_marvel_word_frequencies[1:100,]

show the word the mostly common

print(n_marvel_word_frequencies$Var1)
##   [1] film       movi       thor       man        action     aveng     
##   [7] like       iron       one        charact    first      captain   
##  [13] chris      just       america    time       can        get       
##  [19] make       take       will       much       also       marvel    
##  [25] feel       comic      set        scene      stark      hemsworth 
##  [31] know       even       well       love       good       superhero 
##  [37] fun        come       doesn      hulk       play       two       
##  [43] black      don        effect     evan       hero       world     
##  [49] war        work       look       director   mani       may       
##  [55] new        plot       see        seem       stori      book      
##  [61] fight      realli     univers    watch      god        downey    
##  [67] littl      loki       now        rdj        role       villain   
##  [73] actor      back       toni       way        bit        great     
##  [79] never      suit       best       direct     mark       screen    
##  [85] whedon     peopl      still      place      mcu        anoth     
##  [91] blockbust  hiddleston high       major      ruffalo    sequenc   
##  [97] year       age        anthoni    big       
## 2063 Levels: across action allow also america anoth asid ass assembl ... winner

Remove sparse terms

As the DTM should contain exactly-or-approximately 20 tokens, the action of removing sparse terms needs to be called ensuring that the document-term matrix does not contain any errors during the later process of clustering. To reach the approximation, creativity of choosing the percentage of sparse terms removed is experimented for the input of the second parameter of the function for the specified purpose. It would take possible

First Experiment

In my first experiment

# Check the dimensions of the document-term matrix
dim(marvel.dtm)
## [1]   20 2063
# Remove the sparse terms by 50%
marvel.dtms <- removeSparseTerms(marvel.dtm, 0.5)
marvel.dtms <- as.matrix(marvel.dtms)
marvel.dtms <- as.data.frame(marvel.dtms)
dim(marvel.dtms)
## [1] 20 26

Second experiment

dim(marvel.dtm)
## [1]   20 2063
marvel.dtms2 <- removeSparseTerms(marvel.dtm, 0.6)
marvel.dtms2 <- as.matrix(marvel.dtms2)
dim(marvel.dtms2)
## [1] 20 44

Third Experiment

dim(marvel.dtm)
## [1]   20 2063
marvel.dtms3 <- removeSparseTerms(marvel.dtm, 0.4)
marvel.dtms3 <- as.matrix(marvel.dtms3)
dim(marvel.dtms3)
## [1] 20 16

This is my document term matrix with 26 tokens after removing any sparse terms

marvel.dtms
write.csv(marvel.dtms, "marvel_dtms.csv")

Calculate the distance using cosine similarity

cosine_similarity_table <- as.data.frame(as.matrix(proxy::dist(marvel.dtms, method = "cosine")))
print(cosine_similarity_table)
##                      Avengers01.txt Avengers02.txt Avengers03.txt
## Avengers01.txt            0.0000000      0.2692019      0.2111894
## Avengers02.txt            0.2692019      0.0000000      0.2847609
## Avengers03.txt            0.2111894      0.2847609      0.0000000
## Avengers04.txt            0.3720142      0.3710947      0.3277231
## Avengers05.txt            0.1985810      0.3240591      0.2505753
## CaptainAmerica01.txt      0.2680749      0.3805848      0.2109546
## CaptainAmerica02.txt      0.1904762      0.3774682      0.4083920
## CaptainAmerica03.txt      0.2662006      0.2254033      0.3798263
## CaptainAmerica04.txt      0.5479164      0.4983091      0.3377274
## CaptainAmerica05.txt      0.4564172      0.4663216      0.2398830
## IronMan01.txt             0.5773230      0.5612844      0.3911605
## IronMan02.txt             0.4226497      0.3280430      0.3981950
## IronMan03.txt             0.4362705      0.4315075      0.3114696
## IronMan04.txt             0.5291111      0.4972472      0.3826029
## IronMan05.txt             0.5968379      0.4557527      0.4732818
## Thor01.txt                0.4755333      0.5971539      0.5471609
## Thor02.txt                0.4461987      0.5777343      0.3766977
## Thor03.txt                0.4882337      0.3741517      0.4311687
## Thor04.txt                0.5973024      0.5545871      0.5879107
## Thor05.txt                0.6942117      0.7296295      0.7587909
##                      Avengers04.txt Avengers05.txt CaptainAmerica01.txt
## Avengers01.txt            0.3720142      0.1985810            0.2680749
## Avengers02.txt            0.3710947      0.3240591            0.3805848
## Avengers03.txt            0.3277231      0.2505753            0.2109546
## Avengers04.txt            0.0000000      0.3911939            0.4331124
## Avengers05.txt            0.3911939      0.0000000            0.2582619
## CaptainAmerica01.txt      0.4331124      0.2582619            0.0000000
## CaptainAmerica02.txt      0.4168703      0.3019899            0.3412675
## CaptainAmerica03.txt      0.3746074      0.3739786            0.3913024
## CaptainAmerica04.txt      0.5640075      0.3951788            0.3271877
## CaptainAmerica05.txt      0.5577806      0.4366095            0.2910824
## IronMan01.txt             0.5672253      0.6108988            0.3974051
## IronMan02.txt             0.4302506      0.4738659            0.2534471
## IronMan03.txt             0.4347193      0.4076511            0.2360101
## IronMan04.txt             0.4365497      0.3315255            0.2697033
## IronMan05.txt             0.4778161      0.4117724            0.3114696
## Thor01.txt                0.4792589      0.4805579            0.4335319
## Thor02.txt                0.6819091      0.4940164            0.4878862
## Thor03.txt                0.4302774      0.5706167            0.5073777
## Thor04.txt                0.5181451      0.5922973            0.5650528
## Thor05.txt                0.7119539      0.5019656            0.4777670
##                      CaptainAmerica02.txt CaptainAmerica03.txt
## Avengers01.txt                  0.1904762            0.2662006
## Avengers02.txt                  0.3774682            0.2254033
## Avengers03.txt                  0.4083920            0.3798263
## Avengers04.txt                  0.4168703            0.3746074
## Avengers05.txt                  0.3019899            0.3739786
## CaptainAmerica01.txt            0.3412675            0.3913024
## CaptainAmerica02.txt            0.0000000            0.2924077
## CaptainAmerica03.txt            0.2924077            0.0000000
## CaptainAmerica04.txt            0.6770832            0.5853267
## CaptainAmerica05.txt            0.5923129            0.5104645
## IronMan01.txt                   0.7519070            0.4943041
## IronMan02.txt                   0.4845087            0.2737270
## IronMan03.txt                   0.5090097            0.3394714
## IronMan04.txt                   0.6086532            0.4746889
## IronMan05.txt                   0.6598320            0.4730348
## Thor01.txt                      0.5322324            0.6255481
## Thor02.txt                      0.6353016            0.6134443
## Thor03.txt                      0.6510684            0.4708387
## Thor04.txt                      0.7061396            0.7484263
## Thor05.txt                      0.6942117            0.7008170
##                      CaptainAmerica04.txt CaptainAmerica05.txt IronMan01.txt
## Avengers01.txt                  0.5479164            0.4564172     0.5773230
## Avengers02.txt                  0.4983091            0.4663216     0.5612844
## Avengers03.txt                  0.3377274            0.2398830     0.3911605
## Avengers04.txt                  0.5640075            0.5577806     0.5672253
## Avengers05.txt                  0.3951788            0.4366095     0.6108988
## CaptainAmerica01.txt            0.3271877            0.2910824     0.3974051
## CaptainAmerica02.txt            0.6770832            0.5923129     0.7519070
## CaptainAmerica03.txt            0.5853267            0.5104645     0.4943041
## CaptainAmerica04.txt            0.0000000            0.2795207     0.5513649
## CaptainAmerica05.txt            0.2795207            0.0000000     0.6281158
## IronMan01.txt                   0.5513649            0.6281158     0.0000000
## IronMan02.txt                   0.5805187            0.4222533     0.3952233
## IronMan03.txt                   0.5190680            0.4621684     0.2420633
## IronMan04.txt                   0.2362171            0.3462462     0.4842894
## IronMan05.txt                   0.3336010            0.5031725     0.3873670
## Thor01.txt                      0.4232635            0.6248986     0.5897227
## Thor02.txt                      0.4046211            0.4323019     0.4995722
## Thor03.txt                      0.4636628            0.4689150     0.6049957
## Thor04.txt                      0.4833632            0.5933955     0.8109878
## Thor05.txt                      0.4009519            0.7091128     0.8229841
##                      IronMan02.txt IronMan03.txt IronMan04.txt IronMan05.txt
## Avengers01.txt           0.4226497     0.4362705     0.5291111     0.5968379
## Avengers02.txt           0.3280430     0.4315075     0.4972472     0.4557527
## Avengers03.txt           0.3981950     0.3114696     0.3826029     0.4732818
## Avengers04.txt           0.4302506     0.4347193     0.4365497     0.4778161
## Avengers05.txt           0.4738659     0.4076511     0.3315255     0.4117724
## CaptainAmerica01.txt     0.2534471     0.2360101     0.2697033     0.3114696
## CaptainAmerica02.txt     0.4845087     0.5090097     0.6086532     0.6598320
## CaptainAmerica03.txt     0.2737270     0.3394714     0.4746889     0.4730348
## CaptainAmerica04.txt     0.5805187     0.5190680     0.2362171     0.3336010
## CaptainAmerica05.txt     0.4222533     0.4621684     0.3462462     0.5031725
## IronMan01.txt            0.3952233     0.2420633     0.4842894     0.3873670
## IronMan02.txt            0.0000000     0.2913166     0.3662541     0.3453463
## IronMan03.txt            0.2913166     0.0000000     0.4022079     0.3168022
## IronMan04.txt            0.3662541     0.4022079     0.0000000     0.1009642
## IronMan05.txt            0.3453463     0.3168022     0.1009642     0.0000000
## Thor01.txt               0.6071771     0.6264974     0.5738086     0.6174701
## Thor02.txt               0.7309527     0.4738632     0.6047060     0.6855137
## Thor03.txt               0.5970885     0.5913653     0.6269765     0.6799621
## Thor04.txt               0.7360838     0.6758095     0.7338451     0.8214672
## Thor05.txt               0.7646040     0.6496755     0.4551642     0.5145761
##                      Thor01.txt Thor02.txt Thor03.txt Thor04.txt Thor05.txt
## Avengers01.txt        0.4755333  0.4461987  0.4882337  0.5973024  0.6942117
## Avengers02.txt        0.5971539  0.5777343  0.3741517  0.5545871  0.7296295
## Avengers03.txt        0.5471609  0.3766977  0.4311687  0.5879107  0.7587909
## Avengers04.txt        0.4792589  0.6819091  0.4302774  0.5181451  0.7119539
## Avengers05.txt        0.4805579  0.4940164  0.5706167  0.5922973  0.5019656
## CaptainAmerica01.txt  0.4335319  0.4878862  0.5073777  0.5650528  0.4777670
## CaptainAmerica02.txt  0.5322324  0.6353016  0.6510684  0.7061396  0.6942117
## CaptainAmerica03.txt  0.6255481  0.6134443  0.4708387  0.7484263  0.7008170
## CaptainAmerica04.txt  0.4232635  0.4046211  0.4636628  0.4833632  0.4009519
## CaptainAmerica05.txt  0.6248986  0.4323019  0.4689150  0.5933955  0.7091128
## IronMan01.txt         0.5897227  0.4995722  0.6049957  0.8109878  0.8229841
## IronMan02.txt         0.6071771  0.7309527  0.5970885  0.7360838  0.7646040
## IronMan03.txt         0.6264974  0.4738632  0.5913653  0.6758095  0.6496755
## IronMan04.txt         0.5738086  0.6047060  0.6269765  0.7338451  0.4551642
## IronMan05.txt         0.6174701  0.6855137  0.6799621  0.8214672  0.5145761
## Thor01.txt            0.0000000  0.4089518  0.3906495  0.2418962  0.2718073
## Thor02.txt            0.4089518  0.0000000  0.3269636  0.3331618  0.4795710
## Thor03.txt            0.3906495  0.3269636  0.0000000  0.2769230  0.5684610
## Thor04.txt            0.2418962  0.3331618  0.2769230  0.0000000  0.3243928
## Thor05.txt            0.2718073  0.4795710  0.5684610  0.3243928  0.0000000
write.csv(cosine_similarity_table, "marvel_documents_cosine_similarity_table.csv")
maximum_cosine_similarity <- max(cosine_similarity_table)
maximum_cosine_similarity
## [1] 0.8229841

The highest the cosine similarity between two documents, the closer the distance between two is. Therefore, the documents very close to each other according to the maximum cosine similarity value are IronMan01 and Thor05.

Clustering

set.seed(9999)
dismatrix = proxy::dist(marvel.dtms, method = "cosine")
fit1 = hclust(dismatrix, method = "ward.D")
plot(fit1, hang = -1, main = "Abstracts Cosine Distance")

Library Package for Optimum K Clustering

#install.packages(factoextra)
library(factoextra)
## Loading required package: ggplot2
## 
## Attaching package: 'ggplot2'
## The following object is masked from 'package:NLP':
## 
##     annotate
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
#install.packages(purrr)
library(purrr)

Calculate the optimum k using the silhouette score

The silhouette score is one of the most popular optimum-k calculation approaches as it measures the quality of each k. Assess the performance of each object within the cluster

# silhouette calculation
library(cluster)

marvel_dtms_selected <- scale(marvel.dtms[, 1:20])

# gives the optimum number of clusters
i_silhouette_score <- function(k){
  km = kmeans(marvel_dtms_selected, k, nstart = 20)
  # silhouette score shows all of the rows representing the cluster, neighbour, and silhouette_width
  # overall silhouette score
  silhouette_score = silhouette(km$cluster, dist(marvel_dtms_selected))
  # average the silhouette scores, higher the score the better the clustering
  mean(silhouette_score[, 3])
}

k = 2:10
avg_sil = sapply(k, i_silhouette_score)
plot(k, avg_sil, type = 'b', xlab = 'Number of Clusters', ylab = 'Average Silhouette Scores')

df = data.frame(k, avg_sil)
df[which.max(df[, df$avg_sil])]

Looking at the plot, the silhouette score recommends 2 clusters

Using a single function for the silhouette score

fviz_nbclust(marvel_dtms_selected, kmeans, method = "silhouette")

Calculate the optimum k using the elbow method

Calculates the sum of squares within the group (clustering) for different number of clusters (k). The best optimum can be found by choosing the first wss that will start to diminish based on the y axis (base point of total within sum of square)

# Load necessary libraries
library(purrr)  # for the map_dbl function
library(stats)  # for the kmeans function

# Ensure your data is correctly loaded and prepared
# Assuming marvel_dtms_selected is already loaded and is a suitable dataframe or matrix

# Define the function to calculate within-clustering sum of squares
wss <- function(k){
  kmeans(marvel_dtms_selected, k, nstart = 20)$tot.withinss
}

# Set the seed for reproducibility
set.seed(9999)

# Compute and plot wss for k = 2 to k = 10
k_values <- 2:10

# Extract within-clustering sum of squares for 2 - 10 clusters
wss_values <- map_dbl(k_values, wss)

# Plot the results
plot(k_values, wss_values, type = 'b', xlab = 'Number of Clusters', ylab = 'Total within-clusters sum of squares')

fviz_nbclust(marvel_dtms_selected, kmeans, method = "wss") + geom_vline(xintercept = 4, linetype = 2)

Calculate the number of Optimum-K using Gap Statistic

Compares the intra-cluster varation (the difference of the distance between the point of one cluster and the another data point from other cluster) for different value of k and computes the expected value under the null reference distribution (i.e. the distribution with no clustering)

set.seed(9999)
gap_stat = clusGap(marvel_dtms_selected, FUN = kmeans, nstart = 20, K.max = 10, B = 50)
print(gap_stat, method = "firstmax")
## Clustering Gap statistic ["clusGap"] from call:
## clusGap(x = marvel_dtms_selected, FUNcluster = kmeans, K.max = 10, B = 50, nstart = 20)
## B=50 simulated reference sets, k = 1..10; spaceH0="scaledPCA"
##  --> Number of clusters (method 'firstmax'): 1
##           logW   E.logW        gap     SE.sim
##  [1,] 3.375496 3.525702 0.15020588 0.04008004
##  [2,] 3.259355 3.347063 0.08770832 0.03876930
##  [3,] 3.139677 3.211681 0.07200397 0.04000430
##  [4,] 3.031851 3.092971 0.06112056 0.04188715
##  [5,] 2.931189 2.982828 0.05163876 0.04423482
##  [6,] 2.822612 2.874445 0.05183298 0.04786806
##  [7,] 2.724259 2.766237 0.04197739 0.05023548
##  [8,] 2.616161 2.654921 0.03876060 0.05271512
##  [9,] 2.496290 2.540601 0.04431015 0.05312470
## [10,] 2.376980 2.419830 0.04284982 0.05518595
fviz_gap_stat(gap_stat)

From this, it is really hard to tell which optimum number of clusters I should use based on three recommendations, but two methods (elbow method and silhouette method) support 4 as the optimum k, this means I am going to use optimum k = 4

Calculate the accuracy of the DTM’s clustering

# Create the vector of Marvel topic labels following the order of the corpus
marvel_topics <- c("Avengers","Avengers","Avengers","Avengers","Avengers", "CaptainAmerica", "CaptainAmerica","CaptainAmerica","CaptainAmerica","CaptainAmerica","IronMan", "IronMan", "IronMan", "IronMan", "IronMan", 
                 "Thor", "Thor", "Thor", "Thor", "Thor")
# using the cluster object "fit" create the required number of clusters. This will be a vector of cluster numbers
marvel_groups = cutree(fit1, k = 4)
# make a table of topic labels vs cluster numbers
marvel_clusters <- table(GroupNames = marvel_topics, Clusters = marvel_groups)
marvel_clusters
##                 Clusters
## GroupNames       1 2 3 4
##   Avengers       5 0 0 0
##   CaptainAmerica 3 2 0 0
##   IronMan        1 2 2 0
##   Thor           0 0 0 5
correctly_classified <- sum(diag(marvel_clusters))
total_instances <- sum(marvel_clusters)
accuracy <- correctly_classified / total_instances
accuracy
## [1] 0.7

The accuracy of the clustering is 0.7 showing the clustering accuracy standard for the industry. This means 70% of the group is actually grouped correctly according to the actual group.

Identify the cluster of each document

marvel_groups
##       Avengers01.txt       Avengers02.txt       Avengers03.txt 
##                    1                    1                    1 
##       Avengers04.txt       Avengers05.txt CaptainAmerica01.txt 
##                    1                    1                    1 
## CaptainAmerica02.txt CaptainAmerica03.txt CaptainAmerica04.txt 
##                    1                    1                    2 
## CaptainAmerica05.txt        IronMan01.txt        IronMan02.txt 
##                    2                    3                    1 
##        IronMan03.txt        IronMan04.txt        IronMan05.txt 
##                    3                    2                    2 
##           Thor01.txt           Thor02.txt           Thor03.txt 
##                    4                    4                    4 
##           Thor04.txt           Thor05.txt 
##                    4                    4

Question 5: Network Analysis for Document

Library packages for network analysis

#install.packages(c("igraph", "igraphdata"))
library(igraph)
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:purrr':
## 
##     compose, simplify
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
library(igraphdata)

Create abstracts matrix

# start with the original document term matrix
dtmsx = as.matrix(marvel.dtms)
# convert to binary matrix
dtmsx = as.matrix((dtmsx > 0) + 0)
# multiply binary matrix by its transpose
ByAbsMatrix = dtmsx %*% t(dtmsx)
# make leading diagonal zero
diag(ByAbsMatrix) = 0

Binary Document Term Matrix

as.data.frame(dtmsx)

Abstract Network Data

as.data.frame(ByAbsMatrix)

Construct abstract network plot

ByAbs = graph_from_adjacency_matrix(ByAbsMatrix, mode = "undirected", weighted = TRUE)
plot(ByAbs)

Summary of the graph for Document

cat("Diameter of the graph \n")
## Diameter of the graph
diameter(ByAbs)
## [1] 13
cat("Average length of the graph \n")
## Average length of the graph
mean_distance(ByAbs)
## [1] 8.715789
cat("Number of vertices in the graph \n")
## Number of vertices in the graph
V(ByAbs)
## + 20/20 vertices, named, from 82e53a3:
##  [1] Avengers01.txt       Avengers02.txt       Avengers03.txt      
##  [4] Avengers04.txt       Avengers05.txt       CaptainAmerica01.txt
##  [7] CaptainAmerica02.txt CaptainAmerica03.txt CaptainAmerica04.txt
## [10] CaptainAmerica05.txt IronMan01.txt        IronMan02.txt       
## [13] IronMan03.txt        IronMan04.txt        IronMan05.txt       
## [16] Thor01.txt           Thor02.txt           Thor03.txt          
## [19] Thor04.txt           Thor05.txt
cat("Number of edges in the graph \n")
## Number of edges in the graph
E(ByAbs)
## + 190/190 edges from 82e53a3 (vertex names):
##  [1] Avengers01.txt--Avengers02.txt       Avengers01.txt--Avengers03.txt      
##  [3] Avengers01.txt--Avengers04.txt       Avengers01.txt--Avengers05.txt      
##  [5] Avengers01.txt--CaptainAmerica01.txt Avengers01.txt--CaptainAmerica02.txt
##  [7] Avengers01.txt--CaptainAmerica03.txt Avengers01.txt--CaptainAmerica04.txt
##  [9] Avengers01.txt--CaptainAmerica05.txt Avengers01.txt--IronMan01.txt       
## [11] Avengers01.txt--IronMan02.txt        Avengers01.txt--IronMan03.txt       
## [13] Avengers01.txt--IronMan04.txt        Avengers01.txt--IronMan05.txt       
## [15] Avengers01.txt--Thor01.txt           Avengers01.txt--Thor02.txt          
## [17] Avengers01.txt--Thor03.txt           Avengers01.txt--Thor04.txt          
## [19] Avengers01.txt--Thor05.txt           Avengers02.txt--Avengers03.txt      
## + ... omitted several edges
network_metrics_for_dtm <- data.frame(
  Closeness = closeness(ByAbs),
  Betweenness = betweenness(ByAbs),
  Degree = degree(ByAbs)
)
network_metrics_for_dtm
#View(network_metrics_for_dtm)
order(closeness(ByAbs), decreasing = T)
##  [1] 20 11 10 13  4  7  3  8 18 17 19 12  1  9 15 16  2  6 14  5
order(betweenness(ByAbs), decreasing = T)
##  [1] 20 11  1  2  3  4  5  6  7  8  9 10 12 13 14 15 16 17 18 19
order(degree(ByAbs), decreasing = T)
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20

Looking at the most important document, I believe in the Thor05.txt will be the most important, followed by the IronMan01. If choosing one, then the actual is Thor05.txt

Inspect connections of each document

hist(degree(ByAbs), breaks = 18, color = "grey")
## Warning in plot.window(xlim, ylim, "", ...): "color" is not a graphical
## parameter
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "color" is not a graphical parameter
## Warning in axis(1, ...): "color" is not a graphical parameter
## Warning in axis(2, at = yt, ...): "color" is not a graphical parameter

Looking at this, I can see that they are all highly correlated towards each other.

Improvement for Network Graph of Document

Plot and simplify the degree to ensure no duplicate edges are in the graph

ByAbs = simplify(ByAbs)
plot(ByAbs)

Improvement Network Graph with Categories and Highlights

# Define node categories
ByAbs = graph_from_adjacency_matrix(ByAbsMatrix, mode = "undirected", weighted = TRUE)
plot(ByAbs)

categories <- c("Avengers", "Avengers", "Avengers", "Avengers", "Avengers",
                "Captain America", "Captain America", "Captain America", "Captain America", "Captain America",
                "Iron Man", "Iron Man", "Iron Man", "Iron Man", "Iron Man",
                "Thor", "Thor", "Thor", "Thor", "Thor")

# Assign colors based on categories
colors <- c("Avengers" = "red", "Captain America" = "blue", "Iron Man" = "gold", "Thor" = "green")
node_colors <- colors[categories]

# Assign colors to nodes
V(ByAbs)$color <- node_colors

# Highlight specific nodes in yellow
V(ByAbs)[20]$color <- "yellow"
V(ByAbs)[11]$color <- "yellow"

# Plot the graph with colored nodes and highlighted nodes
plot(ByAbs, vertex.color = V(ByAbs)$color, main = "Improvement Network With Highlight")

Improvement for Network Graph Including The Colors and Shortest Path of the Important Nodes

set.seed(9999)
ByAbs = graph_from_adjacency_matrix(ByAbsMatrix, mode = "undirected", weighted = TRUE)
plot(ByAbs)

# Define node categories
categories <- c("Avengers", "Avengers", "Avengers", "Avengers", "Avengers",
                "Captain America", "Captain America", "Captain America", "Captain America", "Captain America",
                "Iron Man", "Iron Man", "Iron Man", "Iron Man", "Iron Man",
                "Thor", "Thor", "Thor", "Thor", "Thor")

# Assign colors based on categories
colors <- c("Avengers" = "red", "Captain America" = "blue", "Iron Man" = "gold", "Thor" = "green")
node_colors <- colors[categories]

# Assign colors to nodes
V(ByAbs)$color <- node_colors

# Highlight specific nodes in yellow
V(ByAbs)[20]$color <- "yellow"
V(ByAbs)[11]$color <- "yellow"

# Find the shortest path between two nodes
source_node <- 11  # Change this to your desired source node index
target_node <- 20  # Change this to your desired target node index
shortest_path <- shortest_paths(ByAbs, from = source_node, to = target_node, output = "vpath")$vpath[[1]]

# Highlight the shortest path
E(ByAbs)$color <- "gray"
E(ByAbs)$width <- 1
E(ByAbs, path = shortest_path)$color <- "blue"
E(ByAbs, path = shortest_path)$width <- 2
V(ByAbs)[shortest_path]$color <- "lightblue"
V(ByAbs)[shortest_path]$size <- 15

# Plot the graph with colored nodes, highlighted nodes, smaller node sizes, and the shortest path
plot(ByAbs, vertex.color = V(ByAbs)$color, edge.arrow.size = 0.5, vertex.size = 10, main = "Improvement Node")

# Add the legend
#legend("topright", legend = c("Avengers", "Captain America", "Iron Man", "Thor", "Important"),
       #col = c("red", "blue", "gold", "green", "lightblue"), pch = 19, cex = 0.8)

Improvement for Network Graph Including The Node Importance, Strength Connections

set.seed(9999)
ByAbs <- graph_from_adjacency_matrix(ByAbsMatrix, mode = "directed", weighted = TRUE)

# Define node categories
categories <- c("Avengers", "Avengers", "Avengers", "Avengers", "Avengers",
                "Captain America", "Captain America", "Captain America", "Captain America", "Captain America",
                "Iron Man", "Iron Man", "Iron Man", "Iron Man", "Iron Man",
                "Thor", "Thor", "Thor", "Thor", "Thor")

# Assign colors based on categories
colors <- c("Avengers" = "red", "Captain America" = "blue", "Iron Man" = "gold", "Thor" = "green")
node_colors <- colors[categories]

# Assign colors to nodes
V(ByAbs)$color <- node_colors

# Highlight specific nodes in yellow
V(ByAbs)[20]$color <- "yellow"
V(ByAbs)[11]$color <- "yellow"

# Highlight edge weights (strength of connections)
E(ByAbs)$width <- E(ByAbs)$weight / max(E(ByAbs)$weight) * 5

# Highlight node importance using degree centrality for size
V(ByAbs)$size <- degree(ByAbs) / max(degree(ByAbs)) * 30


# Plot the graph with enhanced features
plot(ByAbs, vertex.color = V(ByAbs)$color, edge.arrow.size = 0.5, vertex.size = 20, main = "Categorized Document Graph with Node Importance and Edge Weights")

Question 6: Network Analysis for Token

# start with original document term matrix
token_dtmsx = as.matrix(marvel.dtms)
# convert to binary matrix
token_dtmsx = as.matrix((token_dtmsx > 0) + 0)
# multiply transpose binary matrix by binary matrix
ByTokenMatrix = t(token_dtmsx) %*% token_dtmsx
# make leading diagonal zero
diag(ByTokenMatrix) = 0

Binary token matrix

as.data.frame(token_dtmsx)

Abstract tokens network data

as.data.frame(ByTokenMatrix)
ByAbs2 = graph_from_adjacency_matrix(ByTokenMatrix, mode = "undirected", weighted = TRUE)
plot(ByAbs2)

Summary of the graph

print("Diameter of the graph \n")
## [1] "Diameter of the graph \n"
diameter(ByAbs2)
## [1] 16
print("Average length of the graph \n")
## [1] "Average length of the graph \n"
mean_distance(ByAbs2)
## [1] 9.073846
print("Number of vertices in the graph \n")
## [1] "Number of vertices in the graph \n"
V(ByAbs2)
## + 26/26 vertices, named, from 1153194:
##  [1] action    also      aveng     can       charact   chris     comic    
##  [8] feel      film      get       iron      just      like      man      
## [15] marvel    movi      one       set       superhero take      thor     
## [22] time      will      first     much      scene
print("Number of edges in the graph \n")
## [1] "Number of edges in the graph \n"
E(ByAbs2)
## + 325/325 edges from 1153194 (vertex names):
##  [1] action--also      action--aveng     action--can       action--charact  
##  [5] action--chris     action--comic     action--feel      action--film     
##  [9] action--get       action--iron      action--just      action--like     
## [13] action--man       action--marvel    action--movi      action--one      
## [17] action--set       action--superhero action--take      action--thor     
## [21] action--time      action--will      action--first     action--much     
## [25] action--scene     also  --aveng     also  --can       also  --charact  
## [29] also  --chris     also  --comic     also  --feel      also  --film     
## [33] also  --get       also  --iron      also  --just      also  --like     
## [37] also  --man       also  --marvel    also  --movi      also  --one      
## + ... omitted several edges
# Calculate closeness, betweenness, and degree
closeness_values <- closeness(ByAbs2)
betweenness_values <- betweenness(ByAbs2)
degree_values <- degree(ByAbs2)

# Create a data frame to hold these values
network_metrics_for_token <- data.frame(
  Node = V(ByAbs2)$name,
  Closeness = closeness_values,
  Betweenness = betweenness_values,
  Degree = degree_values
)
network_metrics_for_token
order(closeness(ByAbs2), decreasing = T)
##  [1] 26 21 10 15 20 23 18 19  2 11 12  3  8  7  6 25 22 24  5  4 14  1 13 17 16
## [26]  9
order(betweenness(ByAbs2), decreasing = T)
##  [1] 26 10  1  2  3  4  5  6  7  8  9 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## [26] 25
order(degree(ByAbs2), decreasing = T)
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
## [26] 26

Looking at the closeness, betweeness, and degree in the token’s network graph, it can be seen that tokens 26 and 10 are the one with the highest closeness and betweenness.

Inspect the connections of each token

hist(degree(ByAbs2), breaks = 18, color = "grey")
## Warning in plot.window(xlim, ylim, "", ...): "color" is not a graphical
## parameter
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "color" is not a graphical parameter
## Warning in axis(1, ...): "color" is not a graphical parameter
## Warning in axis(2, at = yt, ...): "color" is not a graphical parameter

Plot and simplify the graph to remove any duplicates

ByAbs2 = simplify(ByAbs2)
plot(ByAbs2)

Improvement for Token’s Network Graph (Showing In and Out of Vertex)

set.seed(9999)
ByAbs2 = graph_from_adjacency_matrix(ByTokenMatrix, mode = "undirected", weighted = TRUE)

# Specify the vertex to highlight
vertex_to_highlight <- "superhero"

# Find the edges connected to the specified vertex
edges_to_highlight <- incident(ByAbs2, vertex_to_highlight, mode = "all")

# Define colors for edges
edge_colors <- rep("grey", ecount(ByAbs2))
edge_colors[edges_to_highlight] <- "red"

# Plot the graph
plot(ByAbs2, vertex.size = 20, vertex.label.cex = 0.8, edge.width = 1,
     edge.color = edge_colors, main = "Network Graph with Highlighted Edges")

### The graph with the shortest path and the color

set.seed(9999)
ByAbs2 = graph_from_adjacency_matrix(ByTokenMatrix, mode = "undirected", weighted = TRUE)

# Specify the start and end vertices
start_vertex <- "superhero"
end_vertex <- "action"

# Find the shortest path
shortest_path_result <- shortest_paths(ByAbs2, from = start_vertex, to = end_vertex, output = "both")

# Extract the vertices and edges in the shortest path
shortest_path_vertices <- unlist(shortest_path_result$vpath)
shortest_path_edges <- unlist(shortest_path_result$epath)

# Define colors for edges
edge_colors <- rep("grey", ecount(ByAbs2))
edge_colors[shortest_path_edges] <- "red"

# Define colors for vertices
vertex_colors <- rep("lightblue", vcount(ByAbs2))
vertex_colors[shortest_path_vertices] <- "red"


# Plot the graph
plot(ByAbs2, vertex.size = 20, vertex.label.cex = 0.8, edge.width = 1,
     edge.color = edge_colors, vertex.color = vertex_colors, main = "Network Graph with Shortest Path Highlighted")

###############################################################
set.seed(9999)
# Calculate degree centrality for node importance
ByAbs2 = graph_from_adjacency_matrix(ByTokenMatrix, mode = "directed", weighted = TRUE)

# Highlight specific nodes in yellow
V(ByAbs2)[26]$color <- "green"

# Highlight edge weights (strength of connections)
E(ByAbs2)$width <- E(ByAbs2)$weight / max(E(ByAbs2)$weight) * 5

# Highlight node importance using degree centrality for size
V(ByAbs2)$size <- degree(ByAbs2) / max(degree(ByAbs2)) * 30

# Plot the graph
plot(ByAbs2,  edge.arrow.size = 0.5, vertex.size = 20, main = "Improvement Network Graph")

Question 7: Bipartite Graph

Create a data with the transformation

dtmsa = as.data.frame(marvel.dtms)
# add row names
dtmsa$ABS <- rownames(dtmsa)
dtmsb <- data.frame()
for(i in 1:nrow(dtmsa)){
  for(j in 1:(ncol(dtmsa) - 1)){
    touse = cbind(dtmsa[i,j], dtmsa[i, ncol(dtmsa)], colnames(dtmsa[j]))
    dtmsb = rbind(dtmsb, touse)
  }
}
colnames(dtmsb) = c("weight", "abs", "token")
dtmsc = dtmsb[dtmsb$weight != 0, ] # delete 0 weights
# put the columns in order
dtmsc = dtmsc[, c(2,3,1)]
dtmsc

Create a bipartite network graph

g <- graph_from_data_frame(dtmsc, directed = FALSE)
bipartite_mapping(g)
## $res
## [1] TRUE
## 
## $type
##       Avengers01.txt       Avengers02.txt       Avengers03.txt 
##                FALSE                FALSE                FALSE 
##       Avengers04.txt       Avengers05.txt CaptainAmerica01.txt 
##                FALSE                FALSE                FALSE 
## CaptainAmerica02.txt CaptainAmerica03.txt CaptainAmerica04.txt 
##                FALSE                FALSE                FALSE 
## CaptainAmerica05.txt        IronMan01.txt        IronMan02.txt 
##                FALSE                FALSE                FALSE 
##        IronMan03.txt        IronMan04.txt        IronMan05.txt 
##                FALSE                FALSE                FALSE 
##           Thor01.txt           Thor02.txt           Thor03.txt 
##                FALSE                FALSE                FALSE 
##           Thor04.txt           Thor05.txt               action 
##                FALSE                FALSE                 TRUE 
##                 also                aveng                  can 
##                 TRUE                 TRUE                 TRUE 
##              charact                chris                comic 
##                 TRUE                 TRUE                 TRUE 
##                 feel                 film                  get 
##                 TRUE                 TRUE                 TRUE 
##                 iron                 just                 like 
##                 TRUE                 TRUE                 TRUE 
##                  man               marvel                 movi 
##                 TRUE                 TRUE                 TRUE 
##                  one                  set            superhero 
##                 TRUE                 TRUE                 TRUE 
##                 take                 thor                 time 
##                 TRUE                 TRUE                 TRUE 
##                 will                first                 much 
##                 TRUE                 TRUE                 TRUE 
##                scene 
##                 TRUE
V(g)$type <- bipartite_mapping(g)$type

V(g)$color <- ifelse(V(g)$type, "lightblue", "salmon")
V(g)$shape <- ifelse(V(g)$type, "circle", "square")
E(g)$color <- "lightgray"

plot(g, vertex.label.cex = 0.8, vertex.label.color = "black", layout = layout_with_graphopt)

Summary of Bipartite Graph

types <- V(g)$type                 ## getting each vertex `type` let's us sort easily
deg <- degree(g)
bet <- betweenness(g)
clos <- closeness(g)
eig <- eigen_centrality(g)$vector

cent_df <- data.frame(types, deg, bet, clos, eig)

cent_df[order(cent_df$type, decreasing = TRUE),] ## sort w/ `order` by `type`

Analyse only for document (simple similarity)

# install.packages(ade4)
library(ade4) 

bipartite_matrix <- as_biadjacency_matrix(g)  # Extract the matrix

document_match <- dist.binary(bipartite_matrix, method=2, upper=TRUE, diag = FALSE) # Method #2 is Simple Match
token_match <- dist.binary(t(bipartite_matrix), method=2, upper=TRUE, diag = FALSE) 

document_match <- as.matrix(document_match)   
token_match <- as.matrix(token_match)

matching_document <- ifelse(document_match>0.8, 1, 0)
matching_document
##                      Avengers01.txt Avengers02.txt Avengers03.txt
## Avengers01.txt                    0              0              0
## Avengers02.txt                    0              0              0
## Avengers03.txt                    0              0              0
## Avengers04.txt                    0              0              0
## Avengers05.txt                    0              0              0
## CaptainAmerica01.txt              0              0              0
## CaptainAmerica02.txt              0              0              0
## CaptainAmerica03.txt              0              0              0
## CaptainAmerica04.txt              0              0              0
## CaptainAmerica05.txt              0              0              0
## IronMan01.txt                     0              0              0
## IronMan02.txt                     0              0              0
## IronMan03.txt                     0              0              0
## IronMan04.txt                     0              0              0
## IronMan05.txt                     0              0              0
## Thor01.txt                        0              0              0
## Thor02.txt                        0              0              0
## Thor03.txt                        0              0              0
## Thor04.txt                        0              0              0
## Thor05.txt                        1              1              1
##                      Avengers04.txt Avengers05.txt CaptainAmerica01.txt
## Avengers01.txt                    0              0                    0
## Avengers02.txt                    0              0                    0
## Avengers03.txt                    0              0                    0
## Avengers04.txt                    0              0                    0
## Avengers05.txt                    0              0                    0
## CaptainAmerica01.txt              0              0                    0
## CaptainAmerica02.txt              0              0                    0
## CaptainAmerica03.txt              0              0                    0
## CaptainAmerica04.txt              0              0                    0
## CaptainAmerica05.txt              1              0                    0
## IronMan01.txt                     0              0                    0
## IronMan02.txt                     0              0                    0
## IronMan03.txt                     0              0                    0
## IronMan04.txt                     0              0                    0
## IronMan05.txt                     0              0                    0
## Thor01.txt                        0              0                    0
## Thor02.txt                        1              0                    0
## Thor03.txt                        0              0                    0
## Thor04.txt                        0              0                    0
## Thor05.txt                        0              0                    0
##                      CaptainAmerica02.txt CaptainAmerica03.txt
## Avengers01.txt                          0                    0
## Avengers02.txt                          0                    0
## Avengers03.txt                          0                    0
## Avengers04.txt                          0                    0
## Avengers05.txt                          0                    0
## CaptainAmerica01.txt                    0                    0
## CaptainAmerica02.txt                    0                    0
## CaptainAmerica03.txt                    0                    0
## CaptainAmerica04.txt                    0                    0
## CaptainAmerica05.txt                    0                    0
## IronMan01.txt                           0                    0
## IronMan02.txt                           0                    0
## IronMan03.txt                           0                    0
## IronMan04.txt                           0                    0
## IronMan05.txt                           0                    0
## Thor01.txt                              0                    0
## Thor02.txt                              0                    0
## Thor03.txt                              0                    0
## Thor04.txt                              0                    0
## Thor05.txt                              0                    1
##                      CaptainAmerica04.txt CaptainAmerica05.txt IronMan01.txt
## Avengers01.txt                          0                    0             0
## Avengers02.txt                          0                    0             0
## Avengers03.txt                          0                    0             0
## Avengers04.txt                          0                    1             0
## Avengers05.txt                          0                    0             0
## CaptainAmerica01.txt                    0                    0             0
## CaptainAmerica02.txt                    0                    0             0
## CaptainAmerica03.txt                    0                    0             0
## CaptainAmerica04.txt                    0                    0             0
## CaptainAmerica05.txt                    0                    0             0
## IronMan01.txt                           0                    0             0
## IronMan02.txt                           0                    0             0
## IronMan03.txt                           0                    0             0
## IronMan04.txt                           0                    0             0
## IronMan05.txt                           0                    0             0
## Thor01.txt                              0                    0             0
## Thor02.txt                              0                    0             1
## Thor03.txt                              0                    0             1
## Thor04.txt                              0                    0             1
## Thor05.txt                              0                    0             0
##                      IronMan02.txt IronMan03.txt IronMan04.txt IronMan05.txt
## Avengers01.txt                   0             0             0             0
## Avengers02.txt                   0             0             0             0
## Avengers03.txt                   0             0             0             0
## Avengers04.txt                   0             0             0             0
## Avengers05.txt                   0             0             0             0
## CaptainAmerica01.txt             0             0             0             0
## CaptainAmerica02.txt             0             0             0             0
## CaptainAmerica03.txt             0             0             0             0
## CaptainAmerica04.txt             0             0             0             0
## CaptainAmerica05.txt             0             0             0             0
## IronMan01.txt                    0             0             0             0
## IronMan02.txt                    0             0             0             0
## IronMan03.txt                    0             0             0             0
## IronMan04.txt                    0             0             0             0
## IronMan05.txt                    0             0             0             0
## Thor01.txt                       0             0             0             0
## Thor02.txt                       0             0             0             0
## Thor03.txt                       0             0             0             0
## Thor04.txt                       1             0             0             0
## Thor05.txt                       0             0             0             0
##                      Thor01.txt Thor02.txt Thor03.txt Thor04.txt Thor05.txt
## Avengers01.txt                0          0          0          0          1
## Avengers02.txt                0          0          0          0          1
## Avengers03.txt                0          0          0          0          1
## Avengers04.txt                0          1          0          0          0
## Avengers05.txt                0          0          0          0          0
## CaptainAmerica01.txt          0          0          0          0          0
## CaptainAmerica02.txt          0          0          0          0          0
## CaptainAmerica03.txt          0          0          0          0          1
## CaptainAmerica04.txt          0          0          0          0          0
## CaptainAmerica05.txt          0          0          0          0          0
## IronMan01.txt                 0          1          1          1          0
## IronMan02.txt                 0          0          0          1          0
## IronMan03.txt                 0          0          0          0          0
## IronMan04.txt                 0          0          0          0          0
## IronMan05.txt                 0          0          0          0          0
## Thor01.txt                    0          0          0          0          0
## Thor02.txt                    0          0          0          0          0
## Thor03.txt                    0          0          0          0          1
## Thor04.txt                    0          0          0          0          0
## Thor05.txt                    0          0          1          0          0
matching_token <- ifelse(token_match>0.8, 1, 0)
matching_token
##           action also aveng can charact chris comic feel film get iron just
## action         0    0     0   0       0     0     0    0    0   0    0    0
## also           0    0     0   0       0     0     0    0    0   0    0    0
## aveng          0    0     0   0       0     0     0    0    0   0    0    0
## can            0    0     0   0       0     0     0    0    0   0    0    0
## charact        0    0     0   0       0     0     0    0    0   0    0    0
## chris          0    0     0   0       0     0     0    0    0   0    1    0
## comic          0    0     0   0       0     0     0    0    0   1    0    0
## feel           0    0     0   0       0     0     0    0    0   0    0    0
## film           0    0     0   0       0     0     0    0    0   0    0    0
## get            0    0     0   0       0     0     1    0    0   0    0    0
## iron           0    0     0   0       0     1     0    0    0   0    0    0
## just           0    0     0   0       0     0     0    0    0   0    0    0
## like           0    0     0   0       0     0     0    0    0   0    0    0
## man            0    0     0   0       0     0     0    0    0   0    0    0
## marvel         0    0     0   0       0     0     0    0    0   0    0    0
## movi           0    0     0   0       0     0     0    0    0   0    0    0
## one            0    0     0   0       0     0     0    0    0   0    0    0
## set            0    0     1   0       0     0     0    0    0   0    0    0
## superhero      0    0     0   0       0     0     0    0    0   1    0    0
## take           0    0     0   0       0     0     0    0    0   0    0    0
## thor           0    0     0   0       1     0     0    0    0   0    0    0
## time           0    0     0   0       0     0     0    0    0   0    0    0
## will           0    0     0   0       0     0     0    0    0   0    0    0
## first          0    0     0   0       0     0     0    0    0   0    0    0
## much           0    0     1   0       0     0     0    0    0   0    0    0
## scene          0    0     0   1       1     0     0    1    0   0    0    0
##           like man marvel movi one set superhero take thor time will first much
## action       0   0      0    0   0   0         0    0    0    0    0     0    0
## also         0   0      0    0   0   0         0    0    0    0    0     0    0
## aveng        0   0      0    0   0   1         0    0    0    0    0     0    1
## can          0   0      0    0   0   0         0    0    0    0    0     0    0
## charact      0   0      0    0   0   0         0    0    1    0    0     0    0
## chris        0   0      0    0   0   0         0    0    0    0    0     0    0
## comic        0   0      0    0   0   0         0    0    0    0    0     0    0
## feel         0   0      0    0   0   0         0    0    0    0    0     0    0
## film         0   0      0    0   0   0         0    0    0    0    0     0    0
## get          0   0      0    0   0   0         1    0    0    0    0     0    0
## iron         0   0      0    0   0   0         0    0    0    0    0     0    0
## just         0   0      0    0   0   0         0    0    0    0    0     0    0
## like         0   0      0    0   0   0         0    0    0    0    0     0    0
## man          0   0      0    0   0   0         0    0    0    0    0     0    0
## marvel       0   0      0    0   0   0         0    0    0    0    0     0    0
## movi         0   0      0    0   0   0         0    0    0    0    0     0    0
## one          0   0      0    0   0   0         0    0    0    0    0     0    0
## set          0   0      0    0   0   0         0    0    1    0    0     0    0
## superhero    0   0      0    0   0   0         0    0    0    0    0     0    0
## take         0   0      0    0   0   0         0    0    0    0    0     0    0
## thor         0   0      0    0   0   1         0    0    0    0    0     1    0
## time         0   0      0    0   0   0         0    0    0    0    0     0    0
## will         0   0      0    0   0   0         0    0    0    0    0     0    0
## first        0   0      0    0   0   0         0    0    1    0    0     0    0
## much         0   0      0    0   0   0         0    0    0    0    0     0    0
## scene        1   0      0    0   0   1         0    0    0    0    0     0    1
##           scene
## action        0
## also          0
## aveng         0
## can           1
## charact       1
## chris         0
## comic         0
## feel          1
## film          0
## get           0
## iron          0
## just          0
## like          1
## man           0
## marvel        0
## movi          0
## one           0
## set           1
## superhero     0
## take          0
## thor          0
## time          0
## will          0
## first         0
## much          1
## scene         0
match_document <- graph_from_adjacency_matrix(matching_document, 
                                           mode = "undirected")
match_token <- graph_from_adjacency_matrix(matching_token, mode = "undirected")
plot(match_document)

plot(match_token)

Improvement of the bipartite graph

# Calculate degree centrality
degree_centrality <- degree(g)

# Identify communities using edge betweenness
communities <- cluster_edge_betweenness(g)
## Warning in cluster_edge_betweenness(g): At
## vendor/cigraph/src/community/edge_betweenness.c:498 : Membership vector will be
## selected based on the highest modularity score.
# Highlight node importance by size
V(g)$size <- degree_centrality

# Plot with node sizes representing degree centrality and its community
plot(communities, g, vertex.label.cex = 0.7, layout = layout_with_graphopt)