August 2024 all critiques evaluation
British Airways (BA) is the UK’s flag provider airline and one of many world’s main premium airways. It was established in 1974 by the British authorities to handle 4 nationalized airways and two regional airways. BA is the second largest UK-based provider by fleet dimension and passengers carried, and is a founding member of the Oneworld airline alliance.
BA is predicated at London Heathrow, the world’s busiest worldwide airport, and flies to greater than 200 locations in 80 international locations. The airline has a fleet of greater than 280 plane, together with the A380 and 787, and carries greater than 40 million prospects a 12 months. BA is a part of Worldwide Airways Group (IAG), which additionally contains different airways and non-airline companies.
In 2019, BA introduced plans to repaint considered one of its Boeing 747s right into a retrojet BOAC livery to rejoice the airline’s one hundredth anniversary. The livery matches the scheme used on these plane between 1964 and 1974
import requests
from bs4 import BeautifulSoup
import pandas as pdbase_url = "https://www.airlinequality.com/airline-reviews/british-airways"
pages = 10
page_size = 100
critiques = []
# for i in vary(1, pages + 1):
for i in vary(1, pages + 1):
print(f"Scraping web page {i}")
# Create URL to gather hyperlinks from paginated knowledge
url = f"{base_url}/web page/{i}/?sortby=post_datepercent3ADesc&pagesize={page_size}"
# Gather HTML knowledge from this web page
response = requests.get(url)
# Parse content material
content material = response.content material
parsed_content = BeautifulSoup(content material, 'html.parser')
for para in parsed_content.find_all("div", {"class": "text_content"}):
critiques.append(para.get_text())
print(f" ---> {len(critiques)} whole critiques")
df = pd.DataFrame()
df["reviews"] = critiques
df.head()
df.to_csv("knowledge/BA_reviews.csv")
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
import requestscritiques = []
#create an empty listing to gather score stars
stars = []
#create an empty listing to gather date
date = []
#create an empty listing to gather nation the reviewer is from
nation = []
for i in vary(1, 36):
web page = requests.get(f"https://www.airlinequality.com/airline-reviews/british-airways/web page/{i}/?sortby=post_datepercent3ADesc&pagesize=100")
soup = BeautifulSoup(web page.content material, "html5")
for merchandise in soup.find_all("div", class_="text_content"):
critiques.append(merchandise.textual content)
for merchandise in soup.find_all("div", class_ = "rating-10"):
attempt:
stars.append(merchandise.span.textual content)
besides:
print(f"Error on web page {i}")
stars.append("None")
#date
for merchandise in soup.find_all("time"):
date.append(merchandise.textual content)
#nation
for merchandise in soup.find_all("h3"):
nation.append(merchandise.span.next_sibling.textual content.strip(" ()"))
import nltk
from nltk.corpus import stopwords
# Begin with one assessment:
critiques = " ".be part of(df.corpus)
plt.determine(figsize=(20,10))stopwords = set(stopwords.phrases('english'))
# Create and generate a phrase cloud picture:
wordcloud = WordCloud(top=600,width=600,max_font_size=100, max_words=500, stopwords=stopwords).generate(critiques)
# Show the generated picture:
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.present()
import nltk
from nltk.corpus import stopwords
critiques = " ".be part of(df.corpus)
plt.determine(figsize=(20,10))stopwords = set(stopwords.phrases('english'))
stopwords.replace(["ba","flight", "british","airway", "airline","plane", "told","also","passenger"
"london", "heathrow", "aircraft", "could","even", "would"])
# Create and generate a phrase cloud picture:
wordcloud = WordCloud(top=500,width=500,max_font_size=100, max_words=300, stopwords=stopwords).generate(critiques)
# Show the generated picture:
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.present()
you possibly can see the code file right here