Recognizing people and places with Named Entity Recognition#

Sometimes instead of just words you're looking for real-life things - people, places, companies, objects with names. This is called named entity recognition (NER), and is a useful technique of extracting information from text.

Using NER with spaCy#

The natural language processing library spaCy has great NER support, allowing us to extract entities from any sort of text.

Before you use spaCy in a notebook, you need to load in a language model. We're going to be using en_core_web_sm, because it's nice and small and fast to import.

import pandas as pd
import spacy
import requests
from bs4 import BeautifulSoup

nlp = spacy.load("en_core_web_sm")

pd.set_option("display.max_rows", 200)

Once we have our language model loaded, we can process a single sentence. Once you feed it to spaCy, all the magic happens behind the scenes - all that's left for us to do is loop through doc.ents and see the entities inside!

doc = nlp("Apple is looking at buying U.K. startup for $1 billion")

for ent in doc.ents:
    print(ent.text, ent.start_char, ent.end_char, ent.label_)
Apple 0 5 ORG
U.K. 27 31 GPE
$1 billion 44 54 MONEY

We can also visualize the entities in the sentence using the wonderfully-named displacy inside of spaCy.

from spacy import displacy

displacy.render(doc, style="ent")
Apple ORG is looking at buying U.K. GPE startup for $1 billion MONEY

Here's what spaCy found:

  • Apple is an organization
  • U.K. is a geo-political entity
  • $1 billion is money

If we wanted to be a little more computational about it, we can throw these results into a dataframe. Along with the text we're also adding the lemma of the text, just so capitalization and the like can be normalized.

entities = [(ent.text, ent.label_, ent.lemma_) for ent in doc.ents]
df = pd.DataFrame(entities, columns=['text', 'type', 'lemma'])
df
text type lemma
0 Apple ORG Apple
1 U.K. GPE U.K.
2 $1 billion MONEY $ 1 billion

Processing longer texts#

Processing longer texts is the exact same thing as processing something shorter! Let's look at a sample article from the Washington Post.

content = """The owner of a Virginia company that provides the U.S. Navy with ballistic vests, protective helmets and riot gear is facing a federal wire fraud charge, accused of misleading authorities about where the products were made.

Prosecutors said Arthur Morgan, the 67-year-old chief executive of Surveillance Equipment Group Inc. and its division SEG Armor, falsely claimed the equipment was made in Hong Kong and the United States when it in fact was made in mainland China.

According to federal court records, Morgan’s company was an authorized seller of law enforcement and security supplies to federal agencies. Such sales must comply with the Trade Agreements Act, which requires products to be made or “substantially transformed” in a “designated country.”

The United States includes Hong Kong, a special administrative region of China, on its list of countries designated to make equipment under the act but excludes the mainland. If a contractor wants to supply products from non-designated countries, it must specifically disclose that information in an initial offer.

“A contractor’s failure to do so disqualifies the contractor from eligibility for the contract,” a federal affidavit said, “and a contractor who falsely certifies cannot lawfully seek payment from the United States.”

Surveillance Equipment Group became an authorized equipment provider in 2003 and has fulfilled multiple federal orders over the past 16 years, the U.S. attorney for the District of Maryland said. In 2014, prosecutors said, the company’s price list stated that concealable body armor and helmets were made in Hong Kong.

When a General Services Administration contracting officer asked Morgan whether his items complied with the trade act, prosecutors said, Morgan emailed saying his products were made in the “United States/Hong Kong.” In 2017, he submitted a spreadsheet to the GSA stating that the ballistic helmets, anti-riot suits and shields originated in Louisa, Va.

A federal prosecutor visited the Louisa address, on Mount Airy Road, which property records listed as a home. “Specifically, no manufacturing facility was observed at the address, which appeared, from the point of my observation, to be a field and/or forested area containing several vehicles,” the affidavit said.

An Army special agent then checked pictures Morgan’s firm had filed with the GSA and detected that a photo of a helmet for sale had been altered, court records said. When the agent did a reverse image search, he found the unaltered photo on Alibaba.com, a Chinese e-commerce site, indicating the helmet was made by a Chinese firm. Another reverse image search found the same was true for a ballistic vest.

Federal prosecutors researched shipping records from U.S. Customs and Border Protection and found that Morgan’s company received 14 shipments of vests or helmets between 2015 and 2017 from the same Chinese firm that made the equipment agents found in the unaltered photos.

Investigators also found serial numbers on equipment that traced back to the Chinese company and Mandarin handwriting on ballistic material, prosecutors said. Emails Morgan had sent, however, indicated that orders were made in the United States and were being shipped from a factory in southern Virginia.

Between 2015 and July of this year, prosecutors said, five federal agencies placed nine orders for ballistic vests, helmets or riot gear from Surveillance Equipment Group, totaling about $640,000.

On Thursday, a magistrate at U.S. District Court in Greenbelt, Md., ordered that Morgan be released to home confinement after he paid a $75,000 bond. An order of detention filed Friday showed he hadn’t found a suitable custodian and hadn’t posted bond.

An email and phone message left for Morgan on Sunday were not returned, and no lawyer was listed in court records.

If convicted, prosecutors said, Morgan could face a maximum sentence of 20 years in federal prison. Actual sentences are typically less than that, they said.
"""
doc = nlp(content)

Amazing, look at all that! Let's throw it into a dataframe to see if we can figure out what this is about.

entities = [(ent.text, ent.label_, ent.lemma_) for ent in doc.ents]
df = pd.DataFrame(entities, columns=['text', 'type', 'lemma'])
df.head()
text type lemma
0 Virginia GPE Virginia
1 the U.S. Navy ORG the U.S. Navy
2 Arthur Morgan PERSON Arthur Morgan
3 Surveillance Equipment Group Inc. ORG Surveillance Equipment Group Inc.
4 SEG Armor ORG SEG Armor

Let's see which geopolitical entities are the most common.

df[df.type == 'GPE'].lemma.value_counts()
the United States                  4
Virginia                           3
Hong Kong                          3
China                              2
U.S.                               2
Louisa                             1
Greenbelt                          1
the " United States / Hong Kong    1
Md.                                1
Name: lemma, dtype: int64

Trying one more time#

Processing longer texts is the exact same thing as processing something shorter! Below we'll look at a piece by Reveal involving judges making rulings on companies they own stock in.

The story itself actually used named entity recognition! Here's part of a description of the process from Jonathan Stray's What do journalists do with documents?:

Shifflet exhaustively transcribed California federal judges’ “statement of economic interest" disclosures to generate lists of companies in which they owned stock. He then scraped the PACER database for every case those judges presided over (robust import) and used NER to generate a per-judge list of the entities involved [42][personal communication]. By comparing these lists the reporters were able to find cases in which judges had ruled favorably for companies in which they owned stock.

Which judges is it about? Let's try to use NER to find out!

# Download and parse the article
url = "https://www.revealnews.org/article/federal-judges-rulings-favored-companies-in-which-he-owned-stock/"
response = requests.get(url)
bs_doc = BeautifulSoup(response.text, 'lxml')
# Pull out the article content and look at 
content = bs_doc.select_one("#content_body").text
doc = nlp(content)

Now that we've processed it, it's just a matter of building our entities dataframe and just looking at the people.

entities = [(ent.text, ent.label_, ent.lemma_) for ent in doc.ents]
df = pd.DataFrame(entities, columns=['text', 'type', 'lemma'])
df.head()
text type lemma
0 Manuel Real PERSON Manuel Real
1 the U.S. District Court ORG the U.S. District Court
2 Los Angeles GPE Los Angeles
3 1966.Photo CARDINAL 1966.photo
4 Virginia Lee Hunter PERSON Virginia Lee Hunter
df[df.type == 'PERSON'].lemma.value_counts().head()
Herndon      8
Patel        6
Schneider    6
Dwyer        4
Anderson     4
Name: lemma, dtype: int64

Clearly it's all about a handful of judges: Herndon, Patel, Schneider, and Dwyer, at least. Because we shouldn't just blindly trust an algorithm, let's use our eyes and brain and actually read the spaCy-annotated annotated article.

displacy.render(doc, style="ent")


Judge Manuel Real PERSON of the U.S. District Court ORG in Los Angeles GPE was appointed to the bench in 1966.Photo CARDINAL by Virginia Lee Hunter PERSON

A federal judge has issued three CARDINAL key rulings over a four-year DATE period that favored companies in which he owned stock, a California Watch ORG analysis has found.
Measures are in place to prevent judges from violating federal conflict-of-interest laws. But Judge Manuel Real PERSON , a 46-year veteran of the bench appointed by President Lyndon B. Johnson PERSON , appears to have skirted those safeguards, records and interviews show.
Judges are supposed to disclose everything from their investments to their attendance at expenses-paid seminars. When a financial conflict arises, no matter how small, they are required to step aside, by federal law and the Code of Conduct for United States Judges LAW .  
“This is what we call a ‘bright line’ rule, meaning that it gives clear and unambiguous guidance to judges and the public,” said Steven Lubet PERSON , a Northwestern University ORG law professor who specializes in judicial ethics.
But in at least three CARDINAL cases before the federal District Court ORG for the Central District of California GPE in Los Angeles GPE , Real did not recuse himself:

In 2008 DATE , he awarded Microsoft Corp. ORG $ 746,027 MONEY in damages and fees in a copyright infringement case against a computer sales and repair company. At the time, Real held Microsoft ORG stock worth between $15,001 and $50,000 MONEY , according to his financial disclosures.
In another 2008 DATE case involving a contract dispute between Atlanta Cancer Care ORG and biotech giant Amgen, Real dismissed the suit against Amgen ORG . Real held between $15,001 and $50,000 MONEY of Amgen ORG stock, too, which he transferred to someone else shortly after the case was appealed.  
The following year DATE , Real dismissed a lawsuit against  Verizon PERSON . After the plaintiff in the case appealed the decision to the 9th ORDINAL U.S. Circuit Court of Appeals ORG , Real bought Verizon ORG stock worth $15,001 to $50,000 MONEY . The appeals court upheld Real’s dismissal, but returned the case to Real for further deliberation. The parties reached an agreement in February 2011 DATE , and Real dismissed the case.

In all three CARDINAL cases, the company’s stock rose at least a dollar MONEY per share during the two months DATE following Real’s ruling or dismissal.
“When there is money involved, it is human nature to protect your own interests,” said John Schneider PERSON , a plaintiff in the Verizon ORG case and a retired electrical contractor. “I would say he looked out for his financial interests before he looked out for mine. Judges should be above reproach.”
Real, previously reprimanded for poor conduct on the bench, did not respond to repeated interview requests made via email or messages left with his courtroom clerk. 
There is no indication that Real had a financial incentive in making his decisions, and many factors affect stock prices. But legal experts consulted by California Watch ORG , a project of the Center for Investigative Reporting ORG , indicated that Real’s rulings were, at a minimum, good news for the companies. California Watch ORG asked law professor Laurie Levenson PERSON , who holds the David W. Burcham Chair ORG in Ethical Advocacy at Loyola Law School ORG in Los Angeles GPE , to review the cases.
A judge who repeatedly fails to withdraw from cases can face sanctions ranging from a private reprimand to suspension from hearing cases. Beyond that, a judge can be referred to Congress ORG for an impeachment hearing.
“If a judge is willfully disregarding the disqualification rules, there is precedent for saying he should be disciplined,” said Charles Geyh PERSON , an expert in judicial ethics who teaches law at Indiana University ORG . “In addition, where judges are not diligent in keeping track of their financial conflicts, where there is a pattern of incompetence, they could also be sanctioned.”
But Geyh acknowledged that such sanctions are rare, typically occurring only in extreme situations. One CARDINAL recent case involved a federal district judge from New Orleans GPE , impeached and removed from office by the U.S. Senate ORG in 2010 DATE for failing to disqualify himself from cases in which he accepted cash and favors from lawyers and a bail bonds company.
Potential ethics violations fall to the Judicial Council of the 9th Circuit ORG to investigate. Chief Judge Alex Kozinksi PERSON , chairman of the council, did not return calls seeking comment.
Federal judges are required to report not only their financial holdings, but also those of their spouses to the federal court system. Since September 2006 DATE , they are supposed to use special conflict-checking software, which cross-references their stock holdings against their courtroom dockets, automatically flagging potential problems.
But technology is no panacea. Courts generally afford judges autonomy in who does the checks and how often. Some judges run checks before every case, while others do so intermittently, according to Central District LOC of California GPE communications specialist Gary Horimoto PERSON . The district is the largest of the 94 CARDINAL federal judicial districts, serving a population of more than 18 million CARDINAL people in Los Angeles GPE , Ventura GPE , Santa Barbara GPE , San Luis Obispo GPE , Orange, Riverside and San Bernardino GPE counties.
“It is up to each judge to actually run these reports,” said Molly Dwyer PERSON , clerk of court of the 9th ORDINAL U.S. Circuit Court of Appeals ORG . “We are not policing the judges. … We are accepting them at their word.”
Public scrutiny of the financial disclosures is complicated by logistical hurdles. While anyone can request judges’ annual DATE financial disclosures through the federal courts’ administrative office in Washington GPE , the process of obtaining these documents and cross-checking them against court rulings is cumbersome and expensive. Judges file annual DATE financial disclosures by May 15 DATE .
In the courtroom
Real, 88 DATE , was first ORDINAL appointed to the bench in 1966 DATE . He earns $ 174,000 MONEY a year and like other federal trial court judges enjoys what has effectively become life tenure, a benefit engineered by authors of the Constitution LAW to protect the court’s independence. A graduate of the University of Southern California ORG , Real earned a law degree from Loyola Law School ORG before becoming assistant U.S. GPE attorney for the Southern District LOC of California GPE and, in 1964 DATE , the district’s U.S. GPE attorney.
One CARDINAL of Real’s more notable decisions was a 1970 DATE order to use mandatory busing to desegregate Pasadena ORG schools.
Among judicial ethicists as well as attorneys who have argued cases before him, Real is known as an iconoclast.
On a recent day DATE , Real rarely looked up from his desk as a string of lawyers directed their arguments at the top of his head. Dwarfed by his burgundy leather chair, Real commanded the cavernous courtroom with the occasional gruff directive.
Then a mustachioed man in an orange jumpsuit and handcuffs appeared. He was there to plead guilty to being caught in the country after being deported.
Real leaned forward and peppered the inmate with questions. Then, when a prosecutor from the Justice Department ORG urged Real to make sure the man understood the facts of the crime before accepting his plea – as required by federal rules – Real lashed out.
“I just went through all that with him,” Real responded. “What do you think that was all about? We went through the elements of the offense.”
The attorney said nothing more.
Notable cases
Real is famous for a courtroom spat with Hustler ORG magazine publisher Larry Flynt PERSON in 1984 DATE . Flynt GPE had refused to reveal the source of a video of a sting operation that he had given to a television network. He appeared before Real and after repeated outbursts, Real ordered Flynt ORG gagged and handcuffed to his wheelchair.
Years later DATE , the 9th ORDINAL U.S. Circuit Court of Appeals ORG issued an opinion in which it criticized Real for his accounting of $33.8 million MONEY in disputed assets of the Philippines GPE dictator Ferdinand Marcos PERSON . The assets had been held in a Merrill Lynch ORG account while the courts decided how to divide funds among various claimants, including Filipinos NORP who claimed to have suffered human rights abuses.
Real, the court documents indicated, declined to provide more than a brief accounting “filled with cryptic notations” of the transactions involving the assets or who authorized them.
Real faced a potential impeachment inquiry by Congress ORG in 2006 DATE over misconduct allegations, congressional documents show. He was accused of showing favoritism in a bankruptcy case toward a woman whose probation he supervised.
In the end, Congress ORG did not pursue the impeachment. But shortly after the congressional hearing, the Judicial Council of the 9th Circuit ORG publicly reprimanded Real for showing favoritism in the bankruptcy case and making misleading statements to investigators.
The Committee on Judicial Conduct and Disability of ORG the Judicial Conference of the United States GPE asked the 9th Circuit ORG to review a complaint in which Real was accused of failing to provide the required reasons for his rulings. In April 2010 DATE , the conference reaffirmed the conclusion of the Judicial Council of the 9th Circuit ORG , which had reviewed 38 CARDINAL of Real’s cases, that there was no misconduct – but warned Real that his decisions would be closely scrutinized.
Arthur D. Hellman PERSON , a law professor at the University of Pittsburgh ORG and leading authority on the federal courts, said few federal judges have received as much scrutiny from the 9th Circuit as Real ORG .
“I doubt that there is any federal judge that has been taken off as many cases as Judge Real PERSON ,” Hellman PERSON said.
Federal trial court judges do not have to detail their reasons for withdrawing from cases, so it is difficult to pinpoint how many avoid financial conflicts of interest. The Central District LOC doesn’t track how often judges withdraw from cases, said Horimoto ORG , the district communications specialist.
However, Real has been taken off at least 20 CARDINAL cases over the past 25 years DATE by the 9th Circuit ORG , which has criticized him for making decisions that ignore precedent, court records show, and creating “an atmosphere in which an objectively fair trial could not be conducted.”
‘A controversial judge’
It is unclear how Real’s multiple conflicts of interest could have escaped notice. His annual DATE financial disclosures list the companies involved in the three CARDINAL cases, a connection the conflict-checking software is designed to catch. At least two CARDINAL of the cases were resolved before Real was required to file his annual DATE disclosures, however, leaving the attorneys involved no means for evaluating his financial interests on their own.
In one of Real’s cases, Microsoft ORG claimed that All-Valley Computer ORG in Cathedral City GPE and its owner, Glenn Somervell PERSON , distributed software that infringed on Microsoft ORG ’s copyrights and trademarks. All-Valley failed to respond to Microsoft ORG ’s complaint by the deadline, and Microsoft ORG ’s lawyers urged Real to issue a judgment against All-Valley LOC . Real awarded Microsoft ORG about $746,000 MONEY in damages and fees.
Two weeks later DATE , Real added a permanent injunction against All-Valley LOC that prohibited it from distributing software protected by Microsoft ORG trademarks or selling counterfeit Microsoft ORG products.
Somervell ORG , who closed All-Valley LOC before the suit to care for his dying mother, said Real’s decisions damaged his career prospects.
“I probably can’t get a job for the rest of my life; it doesn’t look too good on my résumé,” Somervell ORG said. “If (Real’s) involved with Microsoft ORG , he is going to take their side. It’s totally unfair.”
In the Amgen ORG case, Atlanta Cancer Care ORG – which runs medical practices in and around Atlanta GPE – alleged that the biotechnology company wrongfully recouped $ 184,625 MONEY in rebates owed to the oncology practice for medications it purchased for patients. Real was unmoved. Siding with Amgen ORG ’s lawyers, he dismissed the suit. But the 9th Circuit ORG disagreed, reversing Real’s decision and sending the case back to him in late 2009 DATE for further consideration. The parties reached a negotiated settlement in the case at the end of that year DATE .
Leland Wahl PERSON , one CARDINAL of the lead attorneys representing Atlanta Cancer Care ORG in the lawsuit, said Real did not disclose his financial interest in Amgen GPE during the case.
“He is a controversial judge,” Wahl PERSON said. “If he does something unusual, many people would not be surprised, including me.”
And in the Verizon ORG case, the communications company stood to lose millions CARDINAL . That’s because Schneider PERSON , the retired electrical contractor, brought a class-action suit on behalf of Verizon ORG customers challenging the company’s practice of billing each of them up to $149 MONEY for canceling their Internet service before the end of their contract.
Schneider PERSON ’s attorneys argued that the early termination fee was designed to lock in customers and had little bearing on the actual costs of cancellation. Verizon ORG ’s attorneys countered that the complaint lacked merit. Real dismissed the suit. On appeal, the 9th Circuit ORG reversed part of Real’s decision and sent the rest back to him. Verizon ORG later settled the case with Schneider PERSON , but no money was awarded to its other customers.
Checking for conflicts
Around the nation, attorneys and legal scholars point to judges and judicial districts that are doing things right – examples that differ from some of California GPE ’s practices.
One CARDINAL federal judge who pursues conflict checking with vigor is Chief Judge David R. Herndon PERSON of the Southern District LOC of Illinois GPE . He believes it is essential, he said, to retain the public’s trust.
A nominee of President Bill Clinton PERSON on the bench for 14 years DATE , Herndon PERSON does not rely on conflict-checking software alone. He posts a list of his stock holdings online, updating it monthly DATE , in the hope that litigants and lawyers will catch any conflicts he fails to see.   
“Software is not infallible; humans are not infallible,” Herndon PERSON said.
Herndon PERSON and a staff member cross-check his case assignments against his financial holdings daily, he said. In addition, he said, he has instructed his broker not to invest in large companies involved in frequent litigation.
From October 2011 DATE through September DATE , five CARDINAL federal judges in the Southern District LOC of Illinois GPE recused themselves on 14 CARDINAL occasions, Herndon PERSON said.
In the Northern District LOC of Iowa GPE , the clerk’s office – rather than judges or their chamber staff – screens for conflicts before assigning cases. The Iowa GPE district also posts judges’ stock holdings and other information on its website, including law firms or businesses affiliated with their family members.
“It helps lawyers sort out whether judges have conflicts,” said Robert Phelps PERSON , the district’s clerk of court. “In creating the list and publishing it, it also puts that consideration into the minds of judges.”
In California GPE , Dwyer PERSON , the 9th ORDINAL Circuit court clerk, said privacy and security considerations keep California GPE ’s disclosures offline. Among the information included in the filings are details such as addresses of rental properties judges own or the name of their spouse’s employer.
“I don’t think judges want their holdings known by everyone and their mother,” Dwyer PERSON said.
Geyh, the Indiana GPE law professor, scoffed at those objections, pointing out that the financial disclosure is technically a public record, so the lack of online posting merely makes it harder to get.
“It is the price you pay for being a government employee,” he said.
Obtaining financial filings
Without such Web access, obtaining judges’ financial filings is complicated. A written request must be sent to federal officials in Washington GPE , and judges are warned about who is scrutinizing their disclosures. In some cases, under federal law, judges may black out key information, if it includes “revealing personal and sensitive information (that) could endanger” the judge or a family member. 
For example, in mid-2008 DATE , Real transferred 19 CARDINAL stocks ­– most of which were worth between $15,001 and $100,000 MONEY each, one CARDINAL worth up to $500,000 MONEY – to a recipient whose name has been blacked out. The companies ranged from Adobe Systems ORG to UnitedHealth Group ORG .
Another Southern California LOC federal court judge, Percy Anderson PERSON , issued more than two dozen CARDINAL rulings in a 2007 DATE trademark infringement case involving Verizon ORG , including a preliminary injunction and some other rulings in favor of the company. 
Eight months DATE into the continuing Los Angeles GPE case, Anderson PERSON withdrew, saying “that he should not preside over this case because it was reasonably brought to his attention that he has a financial interest in one CARDINAL of the parties,” court records show.
Verizon PERSON was the only publicly traded company involved in the case. Lawyers said Anderson ORG recused himself because he owned Verizon ORG stock. But there is no way to know for sure because Anderson ORG was allowed to black out his financial disclosures before they were released to the public.
Anderson PERSON did not respond to messages left with his courtroom clerk.
Once financial documents are obtained, they must be checked against hundreds CARDINAL of cases each judge oversees, making it difficult to determine whether Real is an anomaly or a symbol of a wider problem.
A California Watch ORG analysis of Northern California LOC district judges, for instance, found that they issued at least 20 CARDINAL rulings involving companies in which they owned stock between 2006 and 2010 DATE , according to court records and financial disclosures.
For the most part, however, those rulings did not appear to be favorable or significant enough to sway the cases in favor of the judge’s stock, according to legal experts who reviewed the cases for California Watch ORG .
In one CARDINAL instance, Judge Marilyn Patel PERSON presided over a case involving ReliaStar Life Insurance Co. ORG , a subsidiary of ING Groep N.V. ORG , beginning in April 2009 DATE . Five months DATE into the case, Patel GPE bought $50,000 to $100,000 MONEY worth of stock in ING Groep FAC . She sold it at the end of that year DATE for a profit of $5,001 to $15,000 MONEY , two months DATE before she signed a court order dismissing the case at the request of the parties. In a letter to California Watch ORG , Patel PERSON defended her role, saying she did not issue any rulings in the case while she held the ING ORG stock. 
“It appears that the system in place for performing conflicts checks did not reveal ING Groep PERSON since it was not a party to the action,” wrote Patel PERSON , who retired from the bench in September DATE .
It is not clear whether Patel PERSON reviewed one CARDINAL of the first ORDINAL court filings in the case, which disclosed ING ORG 's affiliation with ReliaStar ORG
She added: “I do not manage our family portfolio and am not involved in the buying or selling of stocks in it.”
This story was edited by Amy Pyle PERSON and Mark Katches PERSON . It was copy edited by Nikki Frick ORG and Christine Lee PERSON .




We’ve been telling stories that change laws and lives for more than 40 years DATE . And we’re just getting started.

Sign up for our newsletter.






Republish NORP this content








Republish Our Stories
×




Federal judge’s rulings favored companies in which he owned stock
By Jennifer Gollan PERSON and Shane Shifflett PERSON
Reveal from The Center for Investigative Reporting ORG   November 20, 2012 DATE



Thanks for your interest in republishing this story. As a nonprofit newsroom, we want to share our work freely with as many people as possible. We only ask that you follow a few guidelines.

You may embed our audio and video content and republish any written story for free under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 LAW license and will indemnify our content as long as you strictly follow these guidelines:

TEXT

Credit and tag Reveal when sharing the story on social. We’re @reveal on Twitter and you can find us on at Facebook/ThisIsReveal.

Include this language at the beginning of the story: “This story was produced by Reveal from The Center for Investigative Reporting ORG (link organization name to revealnews.org), a nonprofit news organization. Get their investigations emailed to you directly by signing up at revealnews.org/newsletter.
Our reporter(s) must be blind. We prefer the following format: By Emmanuel Martinez PERSON , Reveal GPE .

If you plan to republish our content, please notify us at republish@revealnews.org.
Do not change or edit our material, except only to reflect changes in time and location. (For example, “ yesterday DATE ” can be changed to “ last week DATE ,” and “ Portland GPE , Ore. GPE ” to “ Portland GPE ” or “here.”)
Include all links from the story.

PHOTOS
You can republish Reveal photos only if you run them in or alongside the stories with which they originally appeared, include the original caption, and do not change them.

If you want to run a photo apart from that story, please request specific permission to license by contacting our web team, webteam@revealnews.org. Reveal often uses photos we purchase from The Associated Press ORG ; those are not available for replication.

DATA

If you want to republish Reveal graphics or data, please contact Director of Audience Hannah Young PERSON , hyoung@revealnews.org.

IN GENERAL
We do not compensate anyone who republishes our work. You also cannot sell our material separately or syndicate it.

You can’t republish all of our material wholesale, or automatically; you need to select stories to be republished individually. To inquire about syndication or licensing opportunities, please contact our web team, webteam@revealnews.org

If you plan to republish our content, you must notify us at republish@revealnews.org.
If we send you a request to remove our content from your website, you must agree to do so immediately.
FYI ORG , you can grab HTML code for our stories easily. Click on the “ Republish PRODUCT this content” link at the bottom of every story. Please do not alter this code.
DO NOT APPLY IF
If you wish to only use portions of the work or create a derivative, you need separate permission and the license and indemnification do not apply. This license only applies to replication of full works.
Additionally, we will not provide indemnification if you are located or publishing outside the United States GPE , but you may contact us to obtain a license and indemnification on a case-by-case basis.

CONTACT US GPE

If you have any other questions, please contact us at republish@revealnews.org


Federal judge’s rulings favored companies in which he owned stock
By Jennifer Gollan PERSON and Shane Shifflett / ORG November 20, 2012 DATE

This story was originally published by Reveal from The Center for Investigative Reporting ORG , a nonprofit news organization based in the San Francisco Bay Area LOC . Learn more at revealnews.org and subscribe to the Reveal ORG podcast, produced with PRX ORG , at revealnews.org/podcast.Judge Manuel Real PERSON of the U.S. District Court ORG in Los Angeles GPE was appointed to the bench in 1966.Photo CARDINAL by Virginia Lee Hunter PERSON

A federal judge has issued three CARDINAL key rulings over a four-year DATE period that favored companies in which he owned stock, a California Watch ORG analysis has found.
Measures are in place to prevent judges from violating federal conflict-of-interest laws. But Judge Manuel Real PERSON , a 46-year veteran of the bench appointed by President Lyndon B. Johnson PERSON , appears to have skirted those safeguards, records and interviews show.
Judges are supposed to disclose everything from their investments to their attendance at expenses-paid seminars. When a financial conflict arises, no matter how small, they are required to step aside, by federal law and the Code of Conduct for United States Judges LAW .  
“This is what we call a ‘bright line’ rule, meaning that it gives clear and unambiguous guidance to judges and the public,” said Steven Lubet PERSON , a Northwestern University ORG law professor who specializes in judicial ethics.
But in at least three CARDINAL cases before the federal District Court ORG for the Central District of California GPE in Los Angeles GPE , Real did not recuse himself:
In 2008 DATE , he awarded Microsoft Corp. ORG $ 746,027 MONEY in damages and fees in a copyright infringement case against a computer sales and repair company. At the time, Real held Microsoft ORG stock worth between $15,001 and $50,000 MONEY , according to his financial disclosures.
In another 2008 DATE case involving a contract dispute between Atlanta Cancer Care ORG and biotech giant Amgen, Real dismissed the suit against Amgen ORG . Real held between $15,001 and $50,000 MONEY of Amgen ORG stock, too, which he transferred to someone else shortly after the case was appealed.  
The following year DATE , Real dismissed a lawsuit against  Verizon PERSON . After the plaintiff in the case appealed the decision to the 9th ORDINAL U.S. Circuit Court of Appeals ORG , Real bought Verizon ORG stock worth $15,001 to $50,000 MONEY . The appeals court upheld Real’s dismissal, but returned the case to Real for further deliberation. The parties reached an agreement in February 2011 DATE , and Real dismissed the case.
In all three CARDINAL cases, the company’s stock rose at least a dollar MONEY per share during the two months DATE following Real’s ruling or dismissal.
“When there is money involved, it is human nature to protect your own interests,” said John Schneider PERSON , a plaintiff in the Verizon ORG case and a retired electrical contractor. “I would say he looked out for his financial interests before he looked out for mine. Judges should be above reproach.”
Real, previously reprimanded for poor conduct on the bench, did not respond to repeated interview requests made via email or messages left with his courtroom clerk. 
There is no indication that Real had a financial incentive in making his decisions, and many factors affect stock prices. But legal experts consulted by California Watch ORG , a project of the Center for Investigative Reporting ORG , indicated that Real’s rulings were, at a minimum, good news for the companies. California Watch ORG asked law professor Laurie Levenson PERSON , who holds the David W. Burcham Chair ORG in Ethical Advocacy at Loyola Law School ORG in Los Angeles GPE , to review the cases.
A judge who repeatedly fails to withdraw from cases can face sanctions ranging from a private reprimand to suspension from hearing cases. Beyond that, a judge can be referred to Congress ORG for an impeachment hearing.
“If a judge is willfully disregarding the disqualification rules, there is precedent for saying he should be disciplined,” said Charles Geyh PERSON , an expert in judicial ethics who teaches law at Indiana University ORG . “In addition, where judges are not diligent in keeping track of their financial conflicts, where there is a pattern of incompetence, they could also be sanctioned.”
But Geyh acknowledged that such sanctions are rare, typically occurring only in extreme situations. One CARDINAL recent case involved a federal district judge from New Orleans GPE , impeached and removed from office by the U.S. Senate ORG in 2010 DATE for failing to disqualify himself from cases in which he accepted cash and favors from lawyers and a bail bonds company.
Potential ethics violations fall to the Judicial Council of the 9th Circuit ORG to investigate. Chief Judge Alex Kozinksi PERSON , chairman of the council, did not return calls seeking comment.
Federal judges are required to report not only their financial holdings, but also those of their spouses to the federal court system. Since September 2006 DATE , they are supposed to use special conflict-checking software, which cross-references their stock holdings against their courtroom dockets, automatically flagging potential problems.
But technology is no panacea. Courts generally afford judges autonomy in who does the checks and how often. Some judges run checks before every case, while others do so intermittently, according to Central District LOC of California GPE communications specialist Gary Horimoto PERSON . The district is the largest of the 94 CARDINAL federal judicial districts, serving a population of more than 18 million CARDINAL people in Los Angeles GPE , Ventura GPE , Santa Barbara GPE , San Luis Obispo GPE , Orange, Riverside and San Bernardino GPE counties.
“It is up to each judge to actually run these reports,” said Molly Dwyer PERSON , clerk of court of the 9th ORDINAL U.S. Circuit Court of Appeals ORG . “We are not policing the judges. … We are accepting them at their word.”
Public scrutiny of the financial disclosures is complicated by logistical hurdles. While anyone can request judges’ annual DATE financial disclosures through the federal courts’ administrative office in Washington GPE , the process of obtaining these documents and cross-checking them against court rulings is cumbersome and expensive. Judges file annual DATE financial disclosures by May 15 DATE .
In the courtroom
Real, 88 DATE , was first ORDINAL appointed to the bench in 1966 DATE . He earns $ 174,000 MONEY a year and like other federal trial court judges enjoys what has effectively become life tenure, a benefit engineered by authors of the Constitution LAW to protect the court’s independence. A graduate of the University of Southern California ORG , Real earned a law degree from Loyola Law School ORG before becoming assistant U.S. GPE attorney for the Southern District LOC of California GPE and, in 1964 DATE , the district’s U.S. GPE attorney.
One CARDINAL of Real’s more notable decisions was a 1970 DATE order to use mandatory busing to desegregate Pasadena ORG schools.
Among judicial ethicists as well as attorneys who have argued cases before him, Real is known as an iconoclast.
On a recent day DATE , Real rarely looked up from his desk as a string of lawyers directed their arguments at the top of his head. Dwarfed by his burgundy leather chair, Real commanded the cavernous courtroom with the occasional gruff directive.
Then a mustachioed man in an orange jumpsuit and handcuffs appeared. He was there to plead guilty to being caught in the country after being deported.
Real leaned forward and peppered the inmate with questions. Then, when a prosecutor from the Justice Department ORG urged Real to make sure the man understood the facts of the crime before accepting his plea – as required by federal rules – Real lashed out.
“I just went through all that with him,” Real responded. “What do you think that was all about? We went through the elements of the offense.”
The attorney said nothing more.
Notable cases
Real is famous for a courtroom spat with Hustler ORG magazine publisher Larry Flynt PERSON in 1984 DATE . Flynt GPE had refused to reveal the source of a video of a sting operation that he had given to a television network. He appeared before Real and after repeated outbursts, Real ordered Flynt ORG gagged and handcuffed to his wheelchair.
Years later DATE , the 9th ORDINAL U.S. Circuit Court of Appeals ORG issued an opinion in which it criticized Real for his accounting of $33.8 million MONEY in disputed assets of the Philippines GPE dictator Ferdinand Marcos PERSON . The assets had been held in a Merrill Lynch ORG account while the courts decided how to divide funds among various claimants, including Filipinos NORP who claimed to have suffered human rights abuses.
Real, the court documents indicated, declined to provide more than a brief accounting “filled with cryptic notations” of the transactions involving the assets or who authorized them.
Real faced a potential impeachment inquiry by Congress ORG in 2006 DATE over misconduct allegations, congressional documents show. He was accused of showing favoritism in a bankruptcy case toward a woman whose probation he supervised.
In the end, Congress ORG did not pursue the impeachment. But shortly after the congressional hearing, the Judicial Council of the 9th Circuit ORG publicly reprimanded Real for showing favoritism in the bankruptcy case and making misleading statements to investigators.
The Committee on Judicial Conduct and Disability of ORG the Judicial Conference of the United States GPE asked the 9th Circuit ORG to review a complaint in which Real was accused of failing to provide the required reasons for his rulings. In April 2010 DATE , the conference reaffirmed the conclusion of the Judicial Council of the 9th Circuit ORG , which had reviewed 38 CARDINAL of Real’s cases, that there was no misconduct – but warned Real that his decisions would be closely scrutinized.
Arthur D. Hellman PERSON , a law professor at the University of Pittsburgh ORG and leading authority on the federal courts, said few federal judges have received as much scrutiny from the 9th Circuit as Real ORG .
“I doubt that there is any federal judge that has been taken off as many cases as Judge Real PERSON ,” Hellman PERSON said.
Federal trial court judges do not have to detail their reasons for withdrawing from cases, so it is difficult to pinpoint how many avoid financial conflicts of interest. The Central District LOC doesn’t track how often judges withdraw from cases, said Horimoto ORG , the district communications specialist.
However, Real has been taken off at least 20 CARDINAL cases over the past 25 years DATE by the 9th Circuit ORG , which has criticized him for making decisions that ignore precedent, court records show, and creating “an atmosphere in which an objectively fair trial could not be conducted.”
‘A controversial judge’
It is unclear how Real’s multiple conflicts of interest could have escaped notice. His annual DATE financial disclosures list the companies involved in the three CARDINAL cases, a connection the conflict-checking software is designed to catch. At least two CARDINAL of the cases were resolved before Real was required to file his annual DATE disclosures, however, leaving the attorneys involved no means for evaluating his financial interests on their own.
In one of Real’s cases, Microsoft ORG claimed that All-Valley Computer ORG in Cathedral City GPE and its owner, Glenn Somervell PERSON , distributed software that infringed on Microsoft ORG ’s copyrights and trademarks. All-Valley failed to respond to Microsoft ORG ’s complaint by the deadline, and Microsoft ORG ’s lawyers urged Real to issue a judgment against All-Valley LOC . Real awarded Microsoft ORG about $746,000 MONEY in damages and fees.
Two weeks later DATE , Real added a permanent injunction against All-Valley LOC that prohibited it from distributing software protected by Microsoft ORG trademarks or selling counterfeit Microsoft ORG products.
Somervell ORG , who closed All-Valley LOC before the suit to care for his dying mother, said Real’s decisions damaged his career prospects.
“I probably can’t get a job for the rest of my life; it doesn’t look too good on my résumé,” Somervell ORG said. “If (Real’s) involved with Microsoft ORG , he is going to take their side. It’s totally unfair.”
In the Amgen ORG case, Atlanta Cancer Care ORG – which runs medical practices in and around Atlanta GPE – alleged that the biotechnology company wrongfully recouped $ 184,625 MONEY in rebates owed to the oncology practice for medications it purchased for patients. Real was unmoved. Siding with Amgen ORG ’s lawyers, he dismissed the suit. But the 9th Circuit ORG disagreed, reversing Real’s decision and sending the case back to him in late 2009 DATE for further consideration. The parties reached a negotiated settlement in the case at the end of that year DATE .
Leland Wahl PERSON , one CARDINAL of the lead attorneys representing Atlanta Cancer Care ORG in the lawsuit, said Real did not disclose his financial interest in Amgen GPE during the case.
“He is a controversial judge,” Wahl PERSON said. “If he does something unusual, many people would not be surprised, including me.”
And in the Verizon ORG case, the communications company stood to lose millions CARDINAL . That’s because Schneider PERSON , the retired electrical contractor, brought a class-action suit on behalf of Verizon ORG customers challenging the company’s practice of billing each of them up to $149 MONEY for canceling their Internet service before the end of their contract.
Schneider PERSON ’s attorneys argued that the early termination fee was designed to lock in customers and had little bearing on the actual costs of cancellation. Verizon ORG ’s attorneys countered that the complaint lacked merit. Real dismissed the suit. On appeal, the 9th Circuit ORG reversed part of Real’s decision and sent the rest back to him. Verizon ORG later settled the case with Schneider PERSON , but no money was awarded to its other customers.
Checking for conflicts
Around the nation, attorneys and legal scholars point to judges and judicial districts that are doing things right – examples that differ from some of California GPE ’s practices.
One CARDINAL federal judge who pursues conflict checking with vigor is Chief Judge David R. Herndon PERSON of the Southern District LOC of Illinois GPE . He believes it is essential, he said, to retain the public’s trust.
A nominee of President Bill Clinton PERSON on the bench for 14 years DATE , Herndon PERSON does not rely on conflict-checking software alone. He posts a list of his stock holdings online, updating it monthly DATE , in the hope that litigants and lawyers will catch any conflicts he fails to see.   
“Software is not infallible; humans are not infallible,” Herndon PERSON said.
Herndon PERSON and a staff member cross-check his case assignments against his financial holdings daily, he said. In addition, he said, he has instructed his broker not to invest in large companies involved in frequent litigation.
From October 2011 DATE through September DATE , five CARDINAL federal judges in the Southern District LOC of Illinois GPE recused themselves on 14 CARDINAL occasions, Herndon PERSON said.
In the Northern District LOC of Iowa GPE , the clerk’s office – rather than judges or their chamber staff – screens for conflicts before assigning cases. The Iowa GPE district also posts judges’ stock holdings and other information on its website, including law firms or businesses affiliated with their family members.
“It helps lawyers sort out whether judges have conflicts,” said Robert Phelps PERSON , the district’s clerk of court. “In creating the list and publishing it, it also puts that consideration into the minds of judges.”
In California GPE , Dwyer PERSON , the 9th ORDINAL Circuit court clerk, said privacy and security considerations keep California GPE ’s disclosures offline. Among the information included in the filings are details such as addresses of rental properties judges own or the name of their spouse’s employer.
“I don’t think judges want their holdings known by everyone and their mother,” Dwyer PERSON said.
Geyh, the Indiana GPE law professor, scoffed at those objections, pointing out that the financial disclosure is technically a public record, so the lack of online posting merely makes it harder to get.
“It is the price you pay for being a government employee,” he said.
Obtaining financial filings
Without such Web access, obtaining judges’ financial filings is complicated. A written request must be sent to federal officials in Washington GPE , and judges are warned about who is scrutinizing their disclosures. In some cases, under federal law, judges may black out key information, if it includes “revealing personal and sensitive information (that) could endanger” the judge or a family member. 
For example, in mid-2008 DATE , Real transferred 19 CARDINAL stocks ­– most of which were worth between $15,001 and $100,000 MONEY each, one CARDINAL worth up to $500,000 MONEY – to a recipient whose name has been blacked out. The companies ranged from Adobe Systems ORG to UnitedHealth Group ORG .
Another Southern California LOC federal court judge, Percy Anderson PERSON , issued more than two dozen CARDINAL rulings in a 2007 DATE trademark infringement case involving Verizon ORG , including a preliminary injunction and some other rulings in favor of the company. 
Eight months DATE into the continuing Los Angeles GPE case, Anderson PERSON withdrew, saying “that he should not preside over this case because it was reasonably brought to his attention that he has a financial interest in one CARDINAL of the parties,” court records show.
Verizon PERSON was the only publicly traded company involved in the case. Lawyers said Anderson ORG recused himself because he owned Verizon ORG stock. But there is no way to know for sure because Anderson ORG was allowed to black out his financial disclosures before they were released to the public.
Anderson PERSON did not respond to messages left with his courtroom clerk.
Once financial documents are obtained, they must be checked against hundreds CARDINAL of cases each judge oversees, making it difficult to determine whether Real is an anomaly or a symbol of a wider problem.
A California Watch ORG analysis of Northern California LOC district judges, for instance, found that they issued at least 20 CARDINAL rulings involving companies in which they owned stock between 2006 and 2010 DATE , according to court records and financial disclosures.
For the most part, however, those rulings did not appear to be favorable or significant enough to sway the cases in favor of the judge’s stock, according to legal experts who reviewed the cases for California Watch ORG .
In one CARDINAL instance, Judge Marilyn Patel PERSON presided over a case involving ReliaStar Life Insurance Co. ORG , a subsidiary of ING Groep N.V. ORG , beginning in April 2009 DATE . Five months DATE into the case, Patel GPE bought $50,000 to $100,000 MONEY worth of stock in ING Groep FAC . She sold it at the end of that year DATE for a profit of $5,001 to $15,000 MONEY , two months DATE before she signed a court order dismissing the case at the request of the parties. In a letter to California Watch ORG , Patel PERSON defended her role, saying she did not issue any rulings in the case while she held the ING ORG stock. 
“It appears that the system in place for performing conflicts checks did not reveal ING Groep PERSON since it was not a party to the action,” wrote Patel PERSON , who retired from the bench in September DATE .
It is not clear whether Patel PERSON reviewed one CARDINAL of the first ORDINAL court filings in the case, which disclosed ING ORG 's affiliation with ReliaStar ORG
She added: “I do not manage our family portfolio and am not involved in the buying or selling of stocks in it.”
This story was edited by Amy Pyle PERSON and Mark Katches PERSON . It was copy edited by Nikki Frick ORG and Christine Lee PERSON . Copy HTML

Here's the thing: after the first two hits for Manuel Real, it misses almost every other mention of him. And he's the main character of the piece!

There's also a great point where Verizon is tagged as a person, and then as an organization in the very next sentence. It's trying its best, I guess!

Addressing the issues#

While you can train spaCy further or use a different analyzer altogether, all NER systems have weaknesses and are apt to make mistakes. Instead of pretending you're going to hit 100% with your tool, it's best to design your process knowing that you aren't likely to get everything! And that if you don't catch it, you might completely miss out on some categories, like we did up above.

Spot-checking and reviewing a random sample of results is always a good idea, just to see what tweaks you might need to make.

It also might be more healthy to think of NER as a search engine that's friendly enough to give you a suggested list of automatically-generated search terms, not as an authoritative list of what's in the text.

More reading#

If you're interesting in taking NER further, the spaCy documentation has some really interesting uses. One in particular sticks out:

Here, we extract money and currency values (entities labelled as MONEY) and then check the dependency tree to find the noun phrase they are referring to – for example: "$9.4 million""Net income".

Amazing!

Review#

In this section we covered named entity recognition which can be used to extract "real world" objects from text. We used the spaCy library to find companies, people, countries, and more.

We quickly came up against some issues with NER as a Source of Truth, as it often misclassifies or misses entities that humans would easily understand. While it isn't a replacement for actually reading documents, with a healthy dose of skepticism and spot-checking it's sure to aid in research and analysis.

Discussion topics#

TODO