How do I remove "\\r" characters from text in python? - python

I have the following job description text:
Why settle for an ordinary sales career, when you can put more life in your career with us? Colonial Life has an immediate opening for SALES REPRESENTATIVES to join our growing team.\\r\\rWe are a leader in worksite marketing. We work with employers and their employees to provide benefit solutions in one neat package: benefits communication, enrollment, and personal insurance products.\\r\\rSkills/backgrounds associated with success are:\\r\\r Experience attaining challenging sales goals.\\r Ability to identify and prioritize sales opportunities.\\r Effective verbal and written communication skills, and\xa0ability to successfully engage all levels of customer base.\\r Self-motivation and drive; willing to invest time in developing client relationships. \\r\\r\\rCareer Opportunities:\\r\\r\\r Prospect, market and deliver benefit communications and enrollment solutions to decision makers.\\r Present voluntary product solutions to employees. \\r\\r\\r\\rWe provide the tools, training and support to help you succeed. With Colonial Life, you can:\\r\xa0 \\r\\r Achieve more than just sales – enjoy being a benefits counselor.\\r Work with a sound company that’s had a solid history of integrity and growth for more than 70 years.\\r Enjoy strong earnings potential, even in your first year, plus competitive bonuses and incentives. Average first-year income for our top new benefit counselors hit $105,000 last year. \\r Grow and refine your skills through our proven phone prospecting system and structured sales training program.\\r Enjoy a flexible work schedule.\\r Earn what you’re worth, help people, and have fun doing it! \\r\\r'
I'm trying to:
a) get rid of all the "\r", "\r\r" or "\r\r\r" characters in the main text
b) print it in sentences so it's more readable
How do I do both a) and b)?
I have tried re.sub(r'[^ \w\.]', '', sentence) for a) and it removed the "\" but not the "r" so I ended up with something like that:
'Why settle for an ordinary sales career when you can put more life in your career with us Colonial Life has an immediate opening for SALES REPRESENTATIVES to join our growing team.rrWe are a leader in worksite marketing. We work with employers and their employees to provide benefit solutions in one neat package benefits communication enrollment and personal insurance products.rrSkillsbackgrounds associated with success arerr ...

Related

How to extract specific paragraph in a text file and save it in csv file using python?

I have a text file which contains the information about Title, Author, Abstract, DOI etc. I want to extract only the abstract and store it in a dataframe. I tried using below code, but I'm getting Author information and DOI, I only want the middle paragraph between Author information: and DOI:. How do I get that specific paragraph and store it in a dataframe
extracted_lines=[]
extract = False
for line in open("abstract.txt"):
if extract == False and "Author information:" in line.strip():
extract = True
if extract:
extracted_lines.append(line)
if "DOI:" in line.strip():
extract = False
print("".join(extracted_lines))
**Output**
Author information:
(1)Carol Davila University of Medicine and Pharmacy, 37, Dionisie Lupu St,
Bucharest, Romania 020021.
(2)National Institute of Public Health, 1-3 Doctor Leonte Anastasievici St,
Bucharest, Romania 050463.
Dark chocolate is not the most popular chocolate; the higher concentration in
antioxidants pays tribute to the increment in bitterness. The caloric density of
dark chocolate is potentially lower but has a large variability according to
recipes and ingredients. Nevertheless, in the last decade, the interest in dark
chocolate as a potential functional food has constantly increased. In this
review, we present the nutritional composition, factors influencing the
bioavailability, and health outcomes of dark chocolate intake. We have extracted
pro- and counter-arguments to illustrate these effects from both experimental
and clinical studies in an attempt to solve the dilemma. The antioxidative and
anti-inflammatory abilities, the cardiovascular and metabolic effects, and
influences on central neural functions were selected to substantiate the main
positive consequences. Beside the caloric density, we have included reports
placing responsibility on chocolate as a migraine trigger or as an inducer of
the gastroesophagial reflux in the negative effects section. Despite an
extensive literature review, there are not large enough studies specifically
dedicated to dark chocolate that took into consideration possible confounders on
the health-related effects. Therefore, a definite answer on our initial question
is, currently, not available.
DOI: 10.5740/jaoacint.19-0132
Author information:
(1)School of Food Science and Nutrition, Faculty of Maths and Physical Sciences,
University of Leeds, Leeds LS2 9JT, UK.
(2)School of Food Science and Nutrition, Faculty of Maths and Physical Sciences,
University of Leeds, Leeds LS2 9JT, UK. Electronic address:
g.williamson#leeds.ac.uk.
Dark chocolate contains many biologically active components, such as catechins,
procyanidins and theobromine from cocoa, together with added sucrose and lipids.
All of these can directly or indirectly affect the cardiovascular system by
multiple mechanisms. Intervention studies on healthy and
metabolically-dysfunctional volunteers have suggested that cocoa improves blood
pressure, platelet aggregation and endothelial function. The effect of chocolate
is more convoluted since the sucrose and lipid may transiently and negatively
impact on endothelial function, partly through insulin signalling and nitric
oxide bioavailability. However, few studies have attempted to dissect out the
role of the individual components and have not explored their possible
interactions. For intervention studies, the situation is complex since suitable
placebos are often not available, and some benefits may only be observed in
individuals showing mild metabolic dysfunction. For chocolate, the effects of
some of the components, such as sugar and epicatechin on FMD, may oppose each
other, or alternatively in some cases may act together, such as theobromine and
epicatechin. Although clearly cocoa provides some cardiovascular benefits
according to many human intervention studies, the exact components, their
interactions and molecular mechanisms are still under debate.
Copyright © 2015 Elsevier Inc. All rights reserved.
DOI: 10.1016/j.vph.2015.05.011
Expected Output
Index Abstract
0 Dark chocolate is not the most popular chocola...
1 Dark chocolate contains many biologically acti...
You can try:
retrieving the whole content of the file as a string
splitting on 'Author information:\n', to retrieve infos about every single paper
getting the index 1 of your papers, to retrieve the abstracts
Here's the code:
with open("abstract.txt") as f:
contents = f.read()
papers = [p for p in contents.split('Author information:\n')]
abstracts = [p.split("\n\n")[1] for p in papers[1:]
Does it work for you?

Big Bird Pegasus Summarization output is repeating itself

I am trying to use Big Bird Pegasus to summarize various long texts. The output is repeating the same concept in each sentence.
Here is my code using a news article I copied from NPR. The text is longer than the 4096 token limit, so it takes the first few thousand words from my input.
from transformers import BigBirdPegasusForConditionalGeneration, AutoTokenizer, AutoModelForSeq2SeqLM
model = BigBirdPegasusForConditionalGeneration.from_pretrained("google/bigbird-pegasus-large-arxiv")
tokenizer = AutoTokenizer.from_pretrained("google/bigbird-pegasus-large-arxiv")
src_text = '''
On a sleepy cul-de-sac amid the bucolic vineyards and grassy hills of California's Sonoma Valley, a $4 million house has become the epicenter of a summer-long spat between angry neighbors and a new venture capital-backed startup buying up homes around the nation. The company is called Pacaso. It says it's the fastest company in American history to achieve the "unicorn" status of a billion-dollar valuation — but its quarrels in wine country, one of the first regions where it's begun operations, foreshadow business troubles ahead.
Brad Day and his wife, Holly Kulak, were first introduced to Pacaso in May after a romantic sunset dinner in their yard. "And we just saw this drone, coming up and over our backyard," Day says. "And we're like, what is that?"
Pacaso denies directing or paying a drone operator to film the neighborhood. But its website does have drone photos of the house in question, located at 1405 Old Winery Court. It says it bought the photos after the fact.
Nonetheless, after the drone incident, Day and Kulak got suspicious about what was going on in their neighborhood. About a week later, their neighbors told them they were moving and selling their house to a limited liability corporation, or LLC. But they were super vague about it.
Day and Kulak began speaking with other residents on their cul-de-sac. One of them, Nancy Gardner, had learned from a friend in nearby Napa Valley about a new company called Pacaso that was buying houses in the area. The company was co-founded by a Napa resident, and it converts houses into LLCs. Pacaso then sells shares of these corporate houses to multiple investors. Gardner Googled Pacaso, and, sure enough, the house on their cul-de-sac was on its website. The company had named the house "Chardonnay" and was now selling investors the chance to buy a one-eighth share of it for $606,000.
Pacaso was founded in October 2020 by Austin Allison and Spencer Rascoff, two former executives at Zillow. The company is based in San Francisco, and as is typical of tech startups in the Silicon Valley area, its founders tell a lofty story about their business that's about more than just making money. The company says the motivation for the venture began when Allison and his wife, both based in Napa, bought a second home in Lake Tahoe. The night after they closed on the house, Allison says in a promotional video, he and his wife sat around a fire "thinking how appreciative we were to be second homeowners. And, from that moment, I've always been inspired about making the dream of second home ownership possible for more people."
To make second home ownership possible for more people — and, of course, make money — Pacaso uses a "fractional home ownership" model. They buy a house, lightly refurbish it, furnish it and then create an LLC for it. They then divvy up ownership of this corporatized house into eight fractions and sell those shares on their website.
If you buy a share in a house, you're able to stay in it 44 nights per year in increments that can't exceed 14 consecutive days per visit. You can also "gift" these stays to friends or family. Pacaso offers an app to handle the logistics of booking stays. It oversees management, maintenance and cleaning of the property. In exchange for all this, it charges 12% of the home's purchase price upfront and monthly fees going forward. If you buy a share in a house, you have to hold on to it for a year. After that, you can sell it and profit from any appreciation in the home's value (or be on the hook for any depreciation).
When Day, Kulak and their neighbors learned about Pacaso's business model, they were appalled. They saw the venture capital-backed company as invading their community and converting their neighbor's house into a revolving carousel of vacationers. They imagined endless parties, noise and cars overflowing their cul-de-sac. They worried those staying at "Chardonnay" would drive too fast and fail to heed local concerns about wildfires and droughts. But, most of all, they feared the Pacaso house and more like it would destroy their sense of community and turn their neighborhood into an "adult Disneyland."
The county, Day says, had designated their neighborhood an "exclusion zone," which bans Airbnb-style, short-term rentals to preserve the "residential character" of communities. But Pacaso argues that its clients are not short-term renters. They are co-owners of an LLC. This also means they don't have to pay the typical taxes on short-term rentals. Likewise, in the nearby town of St. Helena, Pacaso was trying to circumnavigate a city ban against timeshares with the same argument. Day says he and his neighbors saw Pacaso's newfangled business model as nothing more than a "glorified timeshare" with a legal strategy aimed at "skirting regulations that are designed to keep communities intact."
The cul-de-sac sprang into action. It formed an organization called Sonomans Together Opposing Pacaso, which, not coincidentally, has the acronym STOP. It contacted the county Board of Supervisors. It created an anti-Pacaso website and circulated an online petition. It flooded the local newspaper with op-eds and letters to the editor. It lobbied local real estate agents not to work with Pacaso. "It feels like we're waging a war by land, air and sea," Day says.
Protest signs festoon the neighborhood's lawns, fences and cars. They say things such as "Stop Pacaso" and "Not here, Pacaso!" Day's favorite sign reads, "The Pacaso house is the big one on the right with no soul."
The signs, of course, make the prospect of buying a share in the Pacaso house awkward, to say the least. Alfred Miller, however, bought a share in "Chardonnay" before ever seeing it in person. Miller is a risk management consultant based in Los Angeles. He believes in Pacaso's business model. And he likes wine and Sonoma's climate. As he researched "Chardonnay" online, he liked the modern architecture and pool, and he decided he'd buy a one-eighth share of the house. It wasn't until a couple weeks after he made the purchase that he first drove up to Sonoma and witnessed the spectacle around his new investment.
"So, imagine me as a new owner driving up, and I get to the corner of Old Winery Court," Miller says. "There's a full-on, professionally printed sign that says 'No Pacaso.' '' Miller then turned right onto Old Winery Court "and the more I drive into the neighborhood, the more signs I see. Brad Day has three vehicles in front of his house, and each vehicle has an anti-Pacaso sign on it. I pull into the driveway — there are two signs on each side of the property. I mean, it was not what I would call very welcoming."
As it did on Old Winery Court, controversy erupted in Napa after the company bought a home worth $1.13 million. That's about 35% higher than Napa's median home price. Pacaso insists it only buys luxury and ultra-luxury houses, and it therefore isn't competing with local middle-class families in the housing market. But this home, located two blocks from a high school, didn't quite fit its talking points. Some Napans were pissed. Pacaso says the house was the victim of trespassing and "illegal signage." Pacaso even claims it had to file a police report after a local wrote to the company and said, "I will burn down any home you buy in Napa. This is no joke."
Pacaso's CEO, who lives in Napa, saw firsthand how angry Napans were, and the company responded. In June, Pacaso agreed to sell the Napa home in a traditional manner "to a whole home buyer" rather than convert it into a corporation and sell it to multiple people. The company also pledged to beef up its "Owner Code Of Conduct" to include "decibel limits on all home sound systems," create a "local liaison" dedicated to assisting neighbors, not buy any homes in the area for under $2 million, and, for each house sold in Napa and Sonoma counties, donate $20,000 to a local nonprofit dedicated to affordable housing.
But while it has been trying to placate local communities with business reforms, Pacaso has waged a court battle with the town of St. Helena over whether its homes should be classified as timeshares. Pacaso is dead set against that classification. One reason might be that timeshares have a bad rap: While they're a popular way to go on vacations, their costs and associated fees tend to make them money losers rather than a profitable investment.
Potentially even more damaging to Pacaso's ambitions, however: Timeshares are banned in many vacation communities around the nation. Hence, Pacaso has strong reasons to insist its homes are not timeshares.
"Unlike a timeshare model, the co-owners that Pacaso serves collectively own real estate, not time," says Ellen Haberle, director of community and government relations for Pacaso.
St. Helena disagrees, declaring Pacaso homes are not allowed in the town because of a city ordinance against timesharing. "Simply calling them co-ownership arrangements does not change that fact," City Attorney Ethan Walsh said. In response to the ban, Pacaso sued the town in federal court. The lawsuit is still pending.
Pacaso says it plans to expand across North America and Europe. Given the company's billion-dollar valuation, investors seem to believe that many people will be attracted to its model of fractional second home ownership. But local residents will likely continue to fight the unicorn stampeding into their towns.
'''
device = 'cuda' if torch.cuda.is_available() else 'cpu'
batch = tokenizer(src_text, truncation=True, padding='longest', return_tensors="pt").to(device)
translated = model.generate(**batch)
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
Here is the output. It doesn't mention anything but the topic of fractional ownership. I repeated for another input text and got similar results - each sentence was a slight variation of each other.
tgt_text
['the notion of a fractional ownership in a real property was introduced in the 19th century.<n> fractional ownership in a real property was defined to be the fraction of the value of the property minus the cost of its construction.<n> the fractional ownership of a real property was defined to be the fraction of the value of the property minus the cost of its construction.<n> the fractional ownership of a home is defined to be the fraction of the value of the home minus the cost of its construction. <n> the notion of a fractional ownership in a real property was introduced in the 19th century.<n> the fractional ownership of a home is the fraction of the value of the home minus the cost of its construction.<n> the fractional ownership of a real property was defined to be the fraction of the value of the home minus the cost of its construction.<n> the fractional ownership of a home is the fraction of the value of the home minus the cost of its construction.<n> the fractional ownership of a real property was defined to be the fraction of the value of the home minus the cost of its construction.<n> the fractional ownership of a home was defined to be the fraction of the value of the home minus the cost of its construction.<n> the']
Have you tried to use no_repeat_ngram_size to generate the summarization? E.g.,
translated = model.generate(**batch, no_repeat_ngram_size=3)
This will generate following text:
the notion of a fractional ownership in a real property was introduced in the 19th century.<n> fractional ownership refers to a property that is more than one half of the value of the property. in recent years<n>, fractional ownership has been used to describe a variety of real
estate phenomena, such as the construction of bridges and tunnels, the development of canals and other drainages, as well as the movement of people and goods. here<n> we consider the fractional ownership
of a home, which can be thought of as the difference between the values of the two halves of the home.

Convert csv to Json to send to watson-personality insight API with Python

I am trying to convert a csv which contains some reviews that I've extracted. I need to convert to a Json as input to IBM watson personality insights.
The csv (WordFinal.csv) with the reviews is like this:
ID,Review,advice,con,date,employeeType,overallStar,position,pro,reviewLink,reviewNo,summary
3,ive been with amazon for 3 years before i finally resigned i started directly out of college as an area manager and promoted once a year to operation manager and was starting to get tapped for senior operations manager the progression at this company is unbelievable and growth potential is nearly limitless you get to work with a highly dedicated team that strives to raise the bar dont get me wrong you may come across individuals who also do the minimum and cut corners to get results but that is the case anywhere i was able to lead teams of up to 700 associates and indirectly oversee 1500 associates during the holiday season all at the age of 25 i was able to influence shift wide department wide building wide and even region wide procedures processes decisions for the company . my only con was the work life balance i was put on nights my entire time with amazon in order to continue to help the lower performing shifts and this would lead to having a daily schedule of wake up go straight to work usually forget to eat leave after 14 hours go to the gym eat maybe sleep wake up after 4 5 hours do it again based on location your leadership team s culture may vary drastically in california i had an extremely supportive senior and general manager team once i came to new jersey the senior team was pretty blind to their own operation super focused on creating reports continuous innovation projects in excel sheets versus just letting us go out there and do the actual improvements there was an extremely slow uptake on just do it recommendations and it was highly evident that this mentality was built into the department as well so again take it with a grain of salt ,"Cali - keep it up, you have culture nailedJersey - This is amazon, you can't raise the bar at amazon without actually being innovating and taking big steps to change things up.",my only con was the work life balance i was put on nights my entire time with amazon in order to continue to help the lower performing shifts and this would lead to having a daily schedule of wake up go straight to work usually forget to eat leave after 14 hours go to the gym eat maybe sleep wake up after 4 5 hours do it again based on location your leadership team s culture may vary drastically in california i had an extremely supportive senior and general manager team once i came to new jersey the senior team was pretty blind to their own operation super focused on creating reports continuous innovation projects in excel sheets versus just letting us go out there and do the actual improvements there was an extremely slow uptake on just do it recommendations and it was highly evident that this mentality was built into the department as well so again take it with a grain of salt ," Nov 9, 2017",Former Employee - Operations Manager,3,I worked at Amazon full-time (More than 3 years),ive been with amazon for 3 years before i finally resigned i started directly out of college as an area manager and promoted once a year to operation manager and was starting to get tapped for senior operations manager the progression at this company is unbelievable and growth potential is nearly limitless you get to work with a highly dedicated team that strives to raise the bar dont get me wrong you may come across individuals who also do the minimum and cut corners to get results but that is the case anywhere i was able to lead teams of up to 700 associates and indirectly oversee 1500 associates during the holiday season all at the age of 25 i was able to influence shift wide department wide building wide and even region wide procedures processes decisions for the company ,https://www.glassdoor.com/Reviews/Amazon-Reviews-E6036.htm/Reviews/Employee-Review-Amazon-RVW17818923.htm,empReview_17818923,Take it with a grain of salt
19, company is on an unstoppable growth trajectory amazons business model is incredible is riding a number of secular trends ecommerce cloud ai and the stock is a winner employees are making more money than expected leadership principles drive a high performance culture that focuses on customers it feels great to work on products that customers love you get to work on very difficult problems with smart people once you establish yourself as a high performer you have a high level of job security and internal mobility teams are constantly hiring and building really innovative things and you are encouraged to move around and explore teams tend to be lean and you will be asked to learn a lot quickly ownership is highly valued office environment is really desirable located in a great downtown seattle neighborhood many people walk to work bring dogs to the office and restaurants and bars are very accessible amazon veterans tend to be incredibly talented individuals and other companies realize it being successful at amazon is well respected in the industry . work life balance can be a challenge work demands are high and teams are often too lean you have to set your own boundaries even with kind managers overachievers will feel under water frugality as a core value goes overboard if amazon doesn t have to give it you it won t no perks no free food or drinks bad coffee unsubsidized cafeterias mediocre hardware for non technical people there doesn t seem to be a morale budget and you will have few official team outings compensation policies are not employee friendly 401k matching is subpar once your signing cash bonus is fully vested your entire compensation will be base salary and stock base salary is capped at 160k across the company stock vests twice a year if you re below a director so your compensation is very lumpy stock price appreciation is taken into consideration in your total compensation targets ie if the value of previously offered shares increases the company will count that as a raise and might not grant you additional stock bonuses despite strong performance ,None, work life balance can be a challenge work demands are high and teams are often too lean you have to set your own boundaries even with kind managers overachievers will feel under water frugality as a core value goes overboard if amazon doesn t have to give it you it won t no perks no free food or drinks bad coffee unsubsidized cafeterias mediocre hardware for non technical people there doesn t seem to be a morale budget and you will have few official team outings compensation policies are not employee friendly 401k matching is subpar once your signing cash bonus is fully vested your entire compensation will be base salary and stock base salary is capped at 160k across the company stock vests twice a year if you re below a director so your compensation is very lumpy stock price appreciation is taken into consideration in your total compensation targets ie if the value of previously offered shares increases the company will count that as a raise and might not grant you additional stock bonuses despite strong performance ," Oct 29, 2016",Current Employee - Product Manager,4,I have been working at Amazon full-time (More than 3 years), company is on an unstoppable growth trajectory amazons business model is incredible is riding a number of secular trends ecommerce cloud ai and the stock is a winner employees are making more money than expected leadership principles drive a high performance culture that focuses on customers it feels great to work on products that customers love you get to work on very difficult problems with smart people once you establish yourself as a high performer you have a high level of job security and internal mobility teams are constantly hiring and building really innovative things and you are encouraged to move around and explore teams tend to be lean and you will be asked to learn a lot quickly ownership is highly valued office environment is really desirable located in a great downtown seattle neighborhood many people walk to work bring dogs to the office and restaurants and bars are very accessible amazon veterans tend to be incredibly talented individuals and other companies realize it being successful at amazon is well respected in the industry ,https://www.glassdoor.com/Reviews/Amazon-Reviews-E6036.htm/Reviews/Employee-Review-Amazon-RVW12494284.htm,empReview_12494284,Incredible growth opportunity with downsides
The format accepted by IBM-Watson is as follows:
{
"contentItems": [
{
"content": "Wow, I liked #TheRock before, now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass",
"contenttype": "text/plain",
"created": 1447639154000,
"id": "666073008692314113",
"language": "en"
},
{
"content": ".#TheRock how did you Know to listen to your gut and Not go back to football? #Masterclass",
"contenttype": "text/plain",
"created": 1447638226000,
"id": "666069114889179136",
"language": "en"
},
{
"content": ".#TheRock moving back in with your parents so humbling. \" on the other side of your pain is something good if you can hold on\" #masterclass",
"contenttype": "text/plain",
"created": 1447638067000,
"id": "666068446325665792",
"language": "en"
}
]
}
I'm trying to generate the output as IBM-watson accept it, but I can't figure out how can i achieve such task. The code below:
import json, csv
csvfile = 'C:\\WordFinal.csv'
jsonfile = 'C:\\OutputJ.json'
fieldnames=['ID','summary']
data= {}
with open(csvfile) as cs:
#reader = csv.DictReader(cs)
reader = csv.DictReader(cs, fieldnames)
for row in reader:
csvid = row["ID"]
data[csvid] = row
with open(jsonfile, "w",encoding='utf8') as js:
js.write(json.dumps(data,indent=2))
And the output (I only need ID and summary columns from my csv - first and last column):
{
"ID": {
"ID": "ID",
"summary": "Review",
"null": [
"advice",
"con",
"date",
"employeeType",
"overallStar",
"position",
"pro",
"reviewLink",
"reviewNo",
"summary"
]
},
"3": {
"ID": "3",
"summary": "ive been with amazon for 3 years before i finally resigned i started directly out of college as an area manager and promoted once a year to operation manager and was starting to get tapped for senior operations manager the progression at this company is unbelievable and growth potential is nearly limitless you get to work with a highly dedicated team that strives to raise the bar dont get me wrong you may come across individuals who also do the minimum and cut corners to get results but that is the case anywhere i was able to lead teams of up to 700 associates and indirectly oversee 1500 associates during the holiday season all at the age of 25 i was able to influence shift wide department wide building wide and even region wide procedures processes decisions for the company . my only con was the work life balance i was put on nights my entire time with amazon in order to continue to help the lower performing shifts and this would lead to having a daily schedule of wake up go straight to work usually forget to eat leave after 14 hours go to the gym eat maybe sleep wake up after 4 5 hours do it again based on location your leadership team s culture may vary drastically in california i had an extremely supportive senior and general manager team once i came to new jersey the senior team was pretty blind to their own operation super focused on creating reports continuous innovation projects in excel sheets versus just letting us go out there and do the actual improvements there was an extremely slow uptake on just do it recommendations and it was highly evident that this mentality was built into the department as well so again take it with a grain of salt ",
"null": [
"Cali - keep it up, you have culture nailedJersey - This is amazon, you can't raise the bar at amazon without actually being innovating and taking big steps to change things up.",
"my only con was the work life balance i was put on nights my entire time with amazon in order to continue to help the lower performing shifts and this would lead to having a daily schedule of wake up go straight to work usually forget to eat leave after 14 hours go to the gym eat maybe sleep wake up after 4 5 hours do it again based on location your leadership team s culture may vary drastically in california i had an extremely supportive senior and general manager team once i came to new jersey the senior team was pretty blind to their own operation super focused on creating reports continuous innovation projects in excel sheets versus just letting us go out there and do the actual improvements there was an extremely slow uptake on just do it recommendations and it was highly evident that this mentality was built into the department as well so again take it with a grain of salt ",
" Nov 9, 2017",
"Former Employee - Operations Manager",
"3",
"I worked at Amazon full-time\u00c2\u00a0(More than 3 years)",
"ive been with amazon for 3 years before i finally resigned i started directly out of college as an area manager and promoted once a year to operation manager and was starting to get tapped for senior operations manager the progression at this company is unbelievable and growth potential is nearly limitless you get to work with a highly dedicated team that strives to raise the bar dont get me wrong you may come across individuals who also do the minimum and cut corners to get results but that is the case anywhere i was able to lead teams of up to 700 associates and indirectly oversee 1500 associates during the holiday season all at the age of 25 i was able to influence shift wide department wide building wide and even region wide procedures processes decisions for the company ",
"https://www.glassdoor.com/Reviews/Amazon-Reviews-E6036.htm/Reviews/Employee-Review-Amazon-RVW17818923.htm",
"empReview_17818923",
"Take it with a grain of salt"
]
},
"19": {
"ID": "19",
"summary": " company is on an unstoppable growth trajectory amazons business model is incredible is riding a number of secular trends ecommerce cloud ai and the stock is a winner employees are making more money than expected leadership principles drive a high performance culture that focuses on customers it feels great to work on products that customers love you get to work on very difficult problems with smart people once you establish yourself as a high performer you have a high level of job security and internal mobility teams are constantly hiring and building really innovative things and you are encouraged to move around and explore teams tend to be lean and you will be asked to learn a lot quickly ownership is highly valued office environment is really desirable located in a great downtown seattle neighborhood many people walk to work bring dogs to the office and restaurants and bars are very accessible amazon veterans tend to be incredibly talented individuals and other companies realize it being successful at amazon is well respected in the industry . work life balance can be a challenge work demands are high and teams are often too lean you have to set your own boundaries even with kind managers overachievers will feel under water frugality as a core value goes overboard if amazon doesn t have to give it you it won t no perks no free food or drinks bad coffee unsubsidized cafeterias mediocre hardware for non technical people there doesn t seem to be a morale budget and you will have few official team outings compensation policies are not employee friendly 401k matching is subpar once your signing cash bonus is fully vested your entire compensation will be base salary and stock base salary is capped at 160k across the company stock vests twice a year if you re below a director so your compensation is very lumpy stock price appreciation is taken into consideration in your total compensation targets ie if the value of previously offered shares increases the company will count that as a raise and might not grant you additional stock bonuses despite strong performance ",
"null": [
"None",
" work life balance can be a challenge work demands are high and teams are often too lean you have to set your own boundaries even with kind managers overachievers will feel under water frugality as a core value goes overboard if amazon doesn t have to give it you it won t no perks no free food or drinks bad coffee unsubsidized cafeterias mediocre hardware for non technical people there doesn t seem to be a morale budget and you will have few official team outings compensation policies are not employee friendly 401k matching is subpar once your signing cash bonus is fully vested your entire compensation will be base salary and stock base salary is capped at 160k across the company stock vests twice a year if you re below a director so your compensation is very lumpy stock price appreciation is taken into consideration in your total compensation targets ie if the value of previously offered shares increases the company will count that as a raise and might not grant you additional stock bonuses despite strong performance ",
" Oct 29, 2016",
"Current Employee - Product Manager",
"4",
"I have been working at Amazon full-time\u00c2\u00a0(More than 3 years)",
" company is on an unstoppable growth trajectory amazons business model is incredible is riding a number of secular trends ecommerce cloud ai and the stock is a winner employees are making more money than expected leadership principles drive a high performance culture that focuses on customers it feels great to work on products that customers love you get to work on very difficult problems with smart people once you establish yourself as a high performer you have a high level of job security and internal mobility teams are constantly hiring and building really innovative things and you are encouraged to move around and explore teams tend to be lean and you will be asked to learn a lot quickly ownership is highly valued office environment is really desirable located in a great downtown seattle neighborhood many people walk to work bring dogs to the office and restaurants and bars are very accessible amazon veterans tend to be incredibly talented individuals and other companies realize it being successful at amazon is well respected in the industry ",
"https://www.glassdoor.com/Reviews/Amazon-Reviews-E6036.htm/Reviews/Employee-Review-Amazon-RVW12494284.htm",
"empReview_12494284",
"Incredible growth opportunity with downsides"
]
}
}
Any idea how can I get the right format?
Don’t specify the field names. Pull out the ones you want from the full records:
with open(csvfile, "r", encoding="utf-8") as infile:
reader = csv.DictReader(infile)
with open(jsonfile, "w", encoding="utf-8") as outfile:
outfile.write(json.dumps([{"ID": row["ID"], "summary": row["summary"]} for row in reader], indent=2))
Gives:
[
{
"ID": "3",
"summary": "Take it with a grain of salt"
},
{
"ID": "19",
"summary": "Incredible growth opportunity with downsides"
}
]
If you dont need anything other than summary, just store only summary in data
with open(csvfile) as cs:
reader = csv.DictReader(cs, fieldnames)
first_row = next(reader) # skip reading the header line
for row in reader[:
csvid = row["ID"]
data[csvid] = row['summary'] # just store the summary
So I find pandas much easier to work with.
First start with creating a dataframe that has your csv information (assumption your file is in a good format).
import pandas as pd
df = pd.read_csv('WordFinal.csv')
Then you can iterate the dataframe.
records = []
for index, row in df.iterrows():
rec = {
row['ID']: {
'ID': row['ID'],
'summary': row['summary']
# ... etc
}
}
records.append(rec)
Your records object will contain the JSON code you can save.

spaCy sentence segmentation failing on quotes

I am parsing some news data with spaCy and am noticing a consistent failure regarding sentence segmentation where there is a quote. Has anyone else solved this issue?
Here is a reproducible example - note sentence 4 in the output below. spaCy fails to split at the start of the quote, and this is consistent through other news articles I'm working with.
Thanks a lot.
Example:
Raw data:
u'body': u'\n LONDON Nov 4 Britons hurt by lower incomes and rising food prices after the financial crisis have cut back on fruit and vegetables and turned instead to fatty, sugary, processed food, an academic study showed on Monday.Britain has seen food prices rise much more sharply than most other developed economies between 2005 and 2012, while wage growth has been low and unemployment has risen.The net effect has been that Britons are spending 8.5 percent less in real terms on food purchased at home than before the recession - with the trend even greater for pensioners and families with young children.The research is likely to be politically sensitive at a time when Britain\'s Conservative-led government is under pressure from the opposition Labour Party, over declining standards of living and sharply rising demand at food banks which hand out free food to the poorest Britons. People have economised by buying less food, measured in number of calories, but also on its quality, picking products that are less nutritious and higher in saturated fat and sugar."Various measures of nutritional quality declined over this period, with bigger decreases for pensioner households and households with young children," said the Institute for Fiscal Studies, an economics research body.OBESITY Families with children were prone to switching to more sugary food, while pensioners favoured food high in saturated fat, the study showed. Both groups often have lower incomes.While the economy is starting to show signs of growth after suffering the biggest hit to economic growth since records began during the 2008-09 recession, households\' disposable incomes are no higher than a decade ago. However, the IFS said a lower-quality diet was not an inevitable consequence of having less money, and that some households had been able to eat as healthily as before while spending less. More research was needed to see why this was not the case for other households, the researchers added.The study looked at data on more than 15,000 households\' shopping habits collected by market research company Kantar Worldpanel between 2005 and 2012.The figures do not include meals purchased or provided away from home, for example in restaurants or at schools, which in England provide free lunches for poorer pupils.The study was released alongside a piece of longer-term research from the IFS, which showed the English now consume 15-30 percent fewer calories than in 1980, despite higher obesity rates probably due to less physical activity.This contrasts with the United States, where calorie consumption has risen as well as obesity. The IFS said it was were researching further into trends in Britons\' physical activity over the period.',
Code to split:
from __future__ import unicode_literals
import spacy
nlp = spacy.load('en')
doc1 = nlp(article_to_json['body'].decode('utf-8'), parse=True)
for number, sent in enumerate(doc1.sents):
print number, sent, "\n"
Output:
0 LONDON Nov 4 Britons hurt by lower incomes and rising food
prices after the financial crisis have cut back on fruit and
vegetables and turned instead to fatty, sugary, processed food, an
academic study showed on Monday.
1 Britain has seen food prices rise much more sharply than most other
developed economies between 2005 and 2012, while wage growth has been
low and unemployment has risen.
2 The net effect has been that Britons are spending 8.5 percent less
in real terms on food purchased at home than before the recession -
with the trend even greater for pensioners and families with young
children.
3 The research is likely to be politically sensitive at a time when
Britain's Conservative-led government is under pressure from the
opposition Labour Party, over declining standards of living and
sharply rising demand at food banks which hand out free food to the
poorest Britons.
4 People have economised by buying less food, measured in number of calories, but also on its quality, picking products that are less
nutritious and higher in saturated fat and sugar."Various measures of
nutritional quality declined over this period, with bigger decreases
for pensioner households and households with young children," said the
Institute for Fiscal Studies, an economics research body.
5 OBESITY Families with children
were prone to switching to more sugary food, while pensioners favoured
food high in saturated fat, the study showed.
6 Both groups often have lower incomes.
7 While the economy is starting to show signs of growth after
suffering the biggest hit to economic growth since records began
during the 2008-09 recession, households' disposable incomes are no
higher than a decade ago.
8 However, the IFS said a lower-quality diet was not an inevitable
consequence of having less money, and that some households had been
able to eat as healthily as before while spending less.
9 More research was needed to see why this was not the case for other
households, the researchers added.
10 The study looked at data on more than 15,000 households' shopping
habits collected by market research company Kantar Worldpanel between
2005 and 2012.The figures do not include meals purchased or provided
away from home, for example in restaurants or at schools, which in
England provide free lunches for poorer pupils.
11 The study was released alongside a piece of longer-term research
from the IFS, which showed the English now consume 15-30 percent fewer
calories than in 1980, despite higher obesity rates probably due to
less physical activity.
12 This contrasts with the United States, where calorie consumption
has risen as well as obesity.
13 The IFS said it was were researching further into trends in
Britons' physical activity over the period.
I googled the original news article to try to figure out why your data looks like it does (missing whitespace between sentences where I wouldn't expect it in a formal news article), and it looks like the original problem is that no whitespace is inserted between HTML paragraphs. If you can fix that problem with how the article is extracted from the original HTML (insert whitespace when you run into <p> or </p>), you won't have this problem with spacy or other tools.
The models available in standard tools will often be trained on news data and it's reasonable to expect them to work well for data like this, but they expect whitespace between sentences. Unless you retrain the models with data including missing whitespace between sentences (or preprocess your data as suggested in a comment), you're going have these kinds of problems.

Writing tuple output to a text file

Is it possible to write my output tuple to a text file? I am using following code to get text between two strings as write them to a text file:
def format_file(file, start, end):
f = open('C:\TEMP\Test.txt', 'r').read()
return tuple(x for x in ''.join(f.split(start)).replace('\n', '').split(end) if x != '')
print (format_file('XYZ', 'Q2 2016 Apple Inc Earnings Call - Final', 'Event Brief of Q1 2016 Apple Inc Earnings Call - Final'))
file = open('C:\TEMP\out.txt', 'w')
file.write(format_file('XYZ', 'Q2 2016 Apple Inc Earnings Call - Final', 'Event Brief of Q1 2016 Apple Inc Earnings Call - Final'))
But I keep getting following error:TypeError: write() argument must be str, not tuple.
When I try to return output as a string instead of a tuple I get a blank file. I would really appreciate any help on this one.
here is my input file text:
Q2 2016 Apple Inc Earnings Call - Final
OPERATOR: From Piper Jaffray, we'll hear from Gene Munster.
GENE MUNSTER, ANALYST, PIPER JAFFRAY & CO.: Good afternoon. Tim, can you talk a little bit about the iPhone ASP trends, and specifically you mentioned that the SE is going to impact, but how are you thinking about the aspirational market share that's out there, and your actual market share, and using price to close that gap? Is it just the SE or could there be other iPhone models that will be discounted, to try to be more aggressive in emerging markets?
And one for Luca. Can you talk a little bit about the services segment, in terms of what piece of the services is driving growth, and maybe a little bit about the profitability on a net basis versus the growth basis that you have referred to in the past. Thanks.
TIM COOK: I think the SE is attracting two types of customers. One is customers that wanted the latest technology, but wanted it in a more compact package. And we clearly see even more people than we thought in that category.
Secondly, it's attracting people aspire to own an iPhone, but couldn't quite stretch to the entry price of the iPhone, and we've established a new entry. I think both of these markets are very, very important to us, and we are really excited about where it can take us. I do think that we will be really happy with the new to iPhone customers that we see from here, because of the early returns we've had. We are currently supply constrained, but we'll be able to work our way out of this at some point. But it's great to see the overwhelming demand for it. I will let Luca comment on the ASPs.
LUCA MAESTRI: On the ASPs, Gene we mentioned that we were going to be down sequentially, and this is really the combination of two factors. So when we go from the March quarter to the June quarter, is the fact that we are having the SE entering the mix, and that obviously is going to have a downward pressure on ASP, and also this channel inventory reduction that we have talked about, obviously the channel inventory reduction will come from higher-end models, and that is also affecting the sequential trend on ASPs.
The question on services, when we look at our services business, obviously growing very well across the board. The biggest element, and the part of the services business that is growing very well, we mentioned 35%, is the App Store. It's interesting for us that our music business, which had been declining for a number of quarters, now that we have both a download model and a streaming model, we have now hit an inflection point, and we believe that this would be the bottom, and we can start growing from there over time.
We have many other services businesses that are doing very well, we have an iCloud business that is growing very quickly. Faster than the App Store, from a much lower base but I think it's important for us as we continue to develop these businesses. Tim have talked about Apple Pay. It doesn't provide a meaningful financial contribution at this point, but as we look at the amount of transactions that go into Apple Pay right now, and we think ahead for the long-term, that could be an interesting business for us, as well.
From a profitability standpoint, we have mentioned last time that when you look at it on a gross basis, so in terms of purchase value of these services, the profitability of the business is similar to Company average. Of course, when you met out the amount that is paid to developers, and you look at it, in terms of what is reported in our P&L, obviously that business has a profitability that is higher than Company average. We don't get into the specifics of specific products or services, but it is very clear it is significantly higher than Company average.
GENE MUNSTER: Thank you.
NANCY PAXTON: Thanks, Gene. Could we have the next question please?
OPERATOR: Katy Huberty with Morgan Stanley.
KATY HUBERTY, ANALYST, MORGAN STANLEY: Yes, thank you. First for Luca. This is the worst gross margin guide in a year and a half or so, and over the last couple of quarters, you have talked about number of tailwinds including component cost, the lower accounting deferrals that went into effect in September. You just mentioned the services margins are above corporate average. So the question is, are some of those tailwinds winding down? Or is a significant guide down in gross margin for the June quarter entirely related to volume and the 5 SE? And then I have a follow-up for Tim.
LUCA MAESTRI: Katy, clearly the commodity environment remains quite favorable, and we continue to expect cost improvements. The other dynamics that you have mentioned are still there, obviously what is different, and particularly as we look at it on a sequential basis coming out of the March quarter, we would have loss of leverage, and that obviously is going to have a negative impact on margins. The other factor that's important to keep in mind is this different mix of products.
Particularly when you look at iPhone, what I was mentioning to Gene earlier, I think we've got a couple of things that are affecting not only ASPs, but obviously, they also affects margins. And it's the fact that we have a channel inventory reduction at the top end of the range, and we've got the introduction of the iPhone SE at the entry level of the range. And so when you take into account those factors, those are the big elements that drive our guidance range right now.
KATY HUBERTY: Okay. Thank you. And that a question for Tim, appreciate the optimism around longer-term iPhone unit growth, but with developed market penetration in anywhere from 60% to 80%, the growth is going to have to come from new markets. You talked about India. Could you just spend a little bit more time on that market? What are some of the hurdles you have to overcome, for that to be a larger part of the business? When we expect Apple to have more distribution, and specifically your own stores in that country? Thanks.
TIM COOK: Katy, in the short term, let me just make a couple of comments on the developed markets, just to make sure this is clear. If you look at our installed base of iPhone today versus two years ago, it's increased by 80%. When you think about upgrade cycles, upgrade cycles would have varying rates on it. As I talked about on the comments, the iPhone 6s rate, upgrade rate is slightly higher than the iPhone 5s, but lower than the iPhone 6.
But the other multiplier in that equation is obviously the size of the installed base. The net of the idea is that I think there's still really, really good business in the developed markets, so I wouldn't want to write those off. It's our job to come up with great products that people desire, and also to continue to attract over Android switchers. With our worldwide share there's still quite a bit of room in the developed markets, as well.
From an India point of view, if you look at India, and each country has a different story a bit, but the things that have held not only us back, perhaps, but some others as well, is that the LTE rollout with India just really begins this year. So we will begin to see some really good networks coming on in India. That will unleash the power and capability of the iPhone, in a way that an older network, 2.5G or even some 3G networks, would not do. The infrastructure is one key one, and the second one is building the channel out.
Unlike the US as an example, where the carriers in the US sell the vast majority of phones that are sold in the United States, in India, the carriers in general sell virtually no phones, and it is out in retail, and retail is many, many different small shops. We've been in the process. It's not something we just started in the last few weeks.
We've been working in India now for a couple of years or more, but we've been working with great energy over the last 18 months or so, and I am encouraged by the results that we're beginning to see there, and believe there's a lot, lot more there. It is already the third largest smart phone market in the world, but because the smart phones that are working there are low-end, primarily because of the network and the economics, the market potential has not been as great there. I view India as where China was maybe 7 to 10 years ago from that point of view. I think there's a really great opportunity there.
NANCY PAXTON: Thank you, Katy. Could we have the next question please?
OPERATOR: We will go to Toni Sacconaghi with Bernstein.
TONI SACCONAGHI, ANALYST, BERNSTEIN: I have one, and then a follow-up, as well. My sense is that you talked about adjusting for the changes in channel inventory, that you are guiding for relatively normal sequential growth. And I think if you do the math it's probably the same or perhaps a touch worse in terms of iPhone unit growth sequentially, relative to normal seasonality between fiscal Q2 and Q3. I guess the question is, given that you should be entering new markets and you should see pronounced elasticity from the SE device, why wouldn't we be seeing something that was dramatically above normal seasonal, in terms of iPhone revenues and units for this quarter?
Maybe you could push back on me, but I can't help thinking that when Apple introduced the iPad Mini in a similar move, to move down market, there was great growth for one quarter, and the iPad never grew again and margins and ASPs went down. It looks like you are introducing the SE, and at least on a sequential basis, you not calling for any uplift, even adjusting for channel inventory, and ASPs I presume will go down and certainly it's impacting gross margins as you've guided to. Could you respond to, A, why you're not seeing the elasticity, and B, is the analogy with the iPad mini completely misplaced?
TIM COOK: Toni, it's Tim. Let me see if I can address your question. The channel inventory reduction that Luca referred to, the vast, vast majority of that is in iPhone. That would affect the unit compare that you maybe thinking about. The iPhone SE, we are thrilled with the response that we've seen on it.
It is clear that there is a demand there, even much beyond what we thought, and so that is really why we have the constraint that we have. Do I think it will be like the iPad Mini? No, I don't think so. I don't see that.
I think the tablet market in general, one of the challenges with the tablet market is that the replacement cycle is materially different than in the smart phone market. As you probably know, we haven't had an issue in customer satisfaction on the iPad. It is incredibly high, and we haven't had an issue with usage of the iPad. The usage is incredibly high.
But the consumer behavior there is you tend to hold on for very long period of time, before an upgrade. We continue to be very optimistic on the iPad business, and as I have said in my remarks, we believe we are going to have the best compare for iPad revenue this quarter that we have quite some time. We will report back in July on that one, but I think iPhone has a particularly different kind of cycle to it than the tablet market.
TONI SACCONAGHI: Okay, and if I could follow-up, Tim. You alluded to replacement cycles and differences between the iPad and the iPhone. My sense was, when you were going through the iPhone 6 cycle, was that you had commented that the upgrade cycle was not materially different. I think your characterization was that it accelerated a bit in the US, but international had grown to be a bigger part of your business, and replacement cycles there were typically a little bit longer. I'm wondering if it was only a modest difference between the 5s and the 6, how big a difference are we really seeing in terms of replacement cycles across the last three generations, and maybe you could help us, if the replacement cycle was flat this year relative to what you saw last year, how different would your results have been this quarter in the first half?
TIM COOK: There's a lot there. Let me just say I don't recall saying the things that you said I said about the upgrade cycle, so let me get that out of the way. Now let me describe without the specific numbers, the iPhone 6s upgrade cycle that we have measured for the first half of this year, so the first six months of our fiscal year to be precise, is slightly better than the rate that we saw with the iPhone 5s two years ago, but it's lower than the iPhone 6. I don't mean just a hair lower, it's a lot lower.
Without giving you exact numbers, if we would have the same rate on 6s that we did 6, there would -- it will be time for a huge party. It would be a huge difference. The great news from my point of view is, I think we are strategically positioned very well, because we have announced the SE, we are attracting customers that we previously didn't attract. That's really great, and this tough compare eventually isn't the benchmark. The install base is up 80% over the last two years, and so all of those I think bode well, and the switcher comments I made earlier, I wouldn't underestimate that, because that's very important for us in every geography. Thanks for the question.
NANCY PAXTON: Thanks, Toni. Can we have the next question please?
OPERATOR: From Cross Research Group, we'll hear from Shannon Cross.
SHANNON CROSS, ANALYST, CROSS RESEARCH: I have a couple of questions. One, Tim, can you talk a bit about what's going on in China? The greater China revenue I think was down 26%. You did talk about mainland China, but if you could talk about some of the trends you're seeing there, and how you think it's playing out, and maybe your thoughts on SE adoption within China as well.
TIM COOK: Shannon, thanks for the question. If you take greater China, we include Taiwan, Hong Kong, and mainland China in the greater China segment that you see reported on your data sheet. The vast majority of the weakness in the greater China region sits in Hong Kong, and our perspective on that is, it's a combination of the Hong Kong dollar being pegged to the US dollar, and therefore it carries the burden of the strength of the US dollar, and that has driven tourism, international shopping and trading down significantly compared to what it was in the year ago.
If you look at mainland China, which is one that I am personally very focused on, we are down 11% in mainland China, on a reported basis. On a constant currency basis, we are only down 7%, and the way that we really look at the health or underlying demand is look at sell-through, and if you look at there, we were down 5%. Keep in mind that is down 5% on comp a year ago that was up 81%.
As I back up from this and look at the larger picture, I think China is not weak, as has been talked about. I see China as -- may not have the wind at our backs that we once did, but it's a lot more stable than what I think is the common view of it. We remain really optimistic on China. We opened seven stores there during the quarter.
We are now at 35. We will open 5 more this quarter to achieve 40, which we had talked about before. And the LTE adoption continues to rise there, but it's got a long way ahead of it. And so we continue to be really optimistic about it, and just would ask folks to look underneath the numbers at the details in them before concluding anything. Thanks for the question.
SHANNON CROSS: Thanks. My second question is with regard to OpEx leverage, or thinking about when I look at the revenue, your revenue is below our expectations but OpEx is pretty much in line. So how are you thinking about potential for leverage, cost containment, maybe when macro is bad and revenue is under pressure, and how are you juggling that versus the required investment you need to go forward?
LUCA MAESTRI: It is Luca. Of course, we think about it. We think about it a lot, and so when you look at our results, for example, our OpEx for the quarter, for the March quarter was up 10%, which is the lowest rate that you have seen in years. And when you look within OpEx, you actually see two different dynamics. You see continued significant investments in research and development, because we really believe that's the future of the Company.
We continue to invest in initiatives and projects ahead of revenue. We had a much broader portfolio that we used to have. We do much more in-house technology development than we used to do a few years ago, which we think is a great investment for us to make. And so that parts we didn't need to protect, and we want to continue to invest in the business, right?
And then when you look at our SG&A portion of OpEx for the March quarter, it was actually down slightly. So obviously we think about it, and of course we look at our revenue trends, and we take measures accordingly. When you look at the guidance that we provided for the June quarter, that 10% year-over-year increase that I mentioned to you for the March quarter goes down to a range of 7% to 9% up, and again, the focus is on making investments in Road and continuing to run SG&A extremely tightly, and in a very disciplined way.
As you know, our E2R, expense to revenue ratio, is around 10%. It's something that we are very proud of, it's a number that is incredibly competitive in our industry, and we want to continue to keep it that way. At the same time, we don't want to under-invest in the business.
SHANNON CROSS: Thank you.
NANCY PAXTON: Thank you, Shannon. Could we have the next question please?
OPERATOR: From UBS we hear from Steve Milunovich.
STEVE MILUNOVICH, ANALYST, UBS: Tim, I first wanted to ask you about services and how do you view services? You've obviously highlighted it the last two quarters. Do you view it going forward as a primary driver of earnings, or do you view it, and you mentioned platforms in terms of your operating systems, which I would agree with. In that scenario I would argue it's more a supporter of the ecosystem, and a supporter of the hardware margins over time, and therefore somewhat subservient to hardware. It's great that it's growing, but longer-term, I would view its role as more creating an ecosystem that supports the high margins on the hardware, as opposed to independently driving earnings. How do you think about it?
TIM COOK: The most important thing for us, Steve, is that we want to have a great customer experience, so overwhelmingly, the thing that drives us are to embark on services that help that, and become a part of the ecosystem. The reality is that in doing so, we have developed a very large and profitable business in the services area, and so we felt last quarter and working up to that, that we should pull back the curtain so that people could -- our investors could see the services business, both in terms of the scale of it, and the growth of it. As we said earlier, the purchase value of the installed base services grew by 27% during the quarter, which was an acceleration over the previous quarter, and the value of it hit -- was just shy of $10 billion. It's huge, and we felt it was important to spell that out.
STEVE MILUNOVICH: Okay, and then going back to the upgrades of the installed base, you have clearly mentioned that you've pulled forward some demand, which makes sense, but there does seem to be a lengthening of the upgrade cycle, particularly in the US. AT&T and Verizon have talked about that. Investors I think perceive that maybe the marginal improvements on the phone might be less currently, and could be less going forward. At the same time, I think you just announced that you can get the upgrade program online, which I guess potentially could shorten it. Do you believe that upgrade cycles are currently lengthening, and can continue to do so?
TIM COOK: What we've seen is that it depends on what you compare it to. If you compare to the 5s, what we are seeing is the upgrade rate today is slightly higher, or that there are more people upgrading, if you will, in a similar time period, in terms of a rate, than the 5s. But if you compare to 6, you would clearly arrive at the opposite conclusion. I think it depends on people's reference points, and we thought it very important in this call to be very clear and transparent about what we're seeing. I think in retrospect, you could look at it and say, maybe the appropriate measure is more to the 5s, and I think everybody intuitively thought that the upgrades were accelerated with the 6, and in retrospect, when you look at the periods, they clearly were.
STEVE MILUNOVICH: Thank you.
NANCY PAXTON: Thanks, Steve. Could we have our next question, please?
OPERATOR: We will go to Rod Hall with JPMorgan.
ROD HALL, ANALYST, JPMORGAN: Yes, thanks for fitting me in. I wanted to start with a general, more general question. I guess, Tim, this one is aimed at you. As you think about where you thought things were going to head last quarter, when you reported to us, and how it's changed this quarter, obviously it's kind of a disappointing demand environment. Can you just help us understand what maybe the top two or three things are that have changed? And so as we walk away from this, we understand what the differences are, and what the direction of change is? Then I have a follow-up.
TIM COOK: I think you're probably indirectly asking about our trough comment, if you will, from last quarter. And when we made that, we did not contemplate or comprehend that we were going to make a $2 billion-plus reduction in channel inventory during this quarter. So if you factor that in and look at true customer demand, which is the way that we look at internally, I think you'll find a much more reasonable comparison.
ROD HALL: Okay, great. Thank you. And then for my follow-up, I wanted to ask you about the tax situation a little bit. Treasury obviously has made some rule changes, and I wonder, maybe if Luca, you could comment on what the impact to Apple from those is, if anything? and Tim, maybe more broadly how you see the tax situation for Apple looking forward? Thanks.
LUCA MAESTRI: Yes, Rod, these are new regulations, and we are in the processing of assessing them. Frankly from first read, we don't anticipate that they are going to have any material impact on our tax situation. Some of them relate to inversion transactions, obviously that's not an issue for us. Some of them are around internal debt financing, which is not something that we use, so we don't expect any issue there.
As you know, we are the largest US taxpayer by a wide margin, and we already pay full US tax on all the profits from the sales that we make in the United States, so we don't expect them to have any impact on us on tax reform. I will let Tim continue to provide more color, but we've been strong advocates for comprehensive corporate tax reform in this country. We continue to do that. We think a reform of the tax code would have significant benefits for the entire US economy, and we remain optimistic that we are going to get to a point where we can see that tax reform enacted. At that point in time, of course, we would have much more flexibility around optimizing our capital structure, and around providing more return of capital to our investors.
TIM COOK: The only thing I would add, Rod, is I think there are a growing number of people in both parties that would like to see comprehensive reform, and so I'm optimistic that it will occur. It's just a matter of when and that's difficult to say. But I think most people do recognize that it is in the US's interest to do this.
ROD HALL: Great, thanks.
NANCY PAXTON: Thank you, Rod. A replay of today's call will be available for two weeks as a podcast on the iTunes Store, as webcast on Apple.com/investor and via telephone. And the numbers for the telephone replay are 888-203-1112, or 719-457-0820, and please enter confirmation code 7495552. These replays will be available by approximately 5:00 PM Pacific time today.
Members of the press with additional questions can contact Kristin Huguet at 408-974-2414, and financial analysts can contact Joan Hoover or me with additional questions. Joan is at 408-974-4570, and I am at 408-974-5420. Thanks again for joining us.
OPERATOR: Ladies and gentlemen, that does conclude today's presentation. We do thank everyone for your participation.
[Thomson Financial reserves the right to make changes to documents, content, or other information on this web site without obligation to notify any person of such changes.
In the conference calls upon which Event Transcripts are based, companies may make projections or other forward-looking statements regarding a variety of items. Such forward-looking statements are based upon current expectations and involve risks and uncertainties. Actual results may differ materially from those stated in any forward-looking statement based on a number of important factors and risks, which are more specifically identified in the companies' most recent SEC filings. Although the companies may indicate and believe that the assumptions underlying the forward-looking statements are reasonable, any of the assumptions could prove inaccurate or incorrect and, therefore, there can be no assurance that the results contemplated in the forward-looking statements will be realized.
THE INFORMATION CONTAINED IN EVENT TRANSCRIPTS IS A TEXTUAL REPRESENTATION OF THE APPLICABLE COMPANY'S CONFERENCE CALL AND WHILE EFFORTS ARE MADE TO PROVIDE AN ACCURATE TRANSCRIPTION, THERE MAY BE MATERIAL ERRORS, OMISSIONS, OR INACCURACIES IN THE REPORTING OF THE SUBSTANCE OF THE CONFERENCE CALLS. IN NO WAY DOES THOMSON FINANCIAL OR THE APPLICABLE COMPANY OR THE APPLICABLE COMPANY ASSUME ANY RESPONSIBILITY FOR ANY INVESTMENT OR OTHER DECISIONS MADE BASED UPON THE INFORMATION PROVIDED ON THIS WEB SITE OR IN ANY EVENT TRANSCRIPT. USERS ARE ADVISED TO REVIEW THE APPLICABLE COMPANY'S CONFERENCE CALL ITSELF AND THE APPLICABLE COMPANY'S SEC FILINGS BEFORE MAKING ANY INVESTMENT OR OTHER DECISIONS.]
LOAD-DATE: April 29, 2016
LANGUAGE: ENGLISH
TRANSCRIPT: 042616a5987433.733
PUBLICATION-TYPE: Transcript
Copyright 2016 CQ-Roll Call, Inc.
All Rights Reserved
Copyright 2016 CCBN, Inc.
4 of 9 DOCUMENTS
FD (Fair Disclosure) Wire
January 26, 2016 Tuesday
Event Brief of Q1 2016 Apple Inc Earnings Call - Final
and the output I am expecting is everthing between 'Q2 2016 Apple Inc Earnings Call - Final' and 'Event Brief of Q1 2016 Apple Inc Earnings Call - Final' in a text file.
Did your try converting your tuple into a string and writing to the file?
s = str('XYZ', 'Q2 2016 Apple Inc Earnings Call - Final', 'Event Brief of Q1 2016 Apple Inc Earnings Call - Final')
file.write(s)

Categories

Resources