long-coref / app.py
kwang2049's picture
examples
e5bdec1
import os
os.system("pip install -r requirements-after.txt")
from typing import Any, Dict
import gradio as gr
from pipeline import LongCorefPipeline
from huggingface_hub import snapshot_download
long_coref = LongCorefPipeline(snapshot_download("kwang2049/long-coref"))
def fn(doc: str) -> Dict[str, Any]:
return long_coref(doc)
examples = [
"""Barack Hussein Obama II[a] (born August 4, 1961) is an American politician who served as the 44th president of the United States from 2009 to 2017. As a member of the Democratic Party, he was the first African-American president in U.S. history. Obama previously served as a U.S. senator representing Illinois from 2005 to 2008 and as an Illinois state senator from 1997 to 2004.
Obama was born in Honolulu, Hawaii. He graduated from Columbia University in 1983 with a Bachelor of Arts degree in political science and later worked as a community organizer in Chicago. In 1988, Obama would enroll in Harvard Law School, where he became the first black president of the Harvard Law Review. He became a civil rights attorney and an academic, teaching constitutional law at the University of Chicago Law School from 1992 to 2004. He also went into elective politics; Obama represented the 13th district in the Illinois Senate from 1997 until 2004, when he successfully ran for the U.S. Senate. In the 2008 presidential election, after a close primary campaign against Hillary Clinton, he was nominated by the Democratic Party for president. Obama selected Joe Biden as his running mate and they defeated Republican nominees John McCain and Sarah Palin.
As president, Obama's first-term actions addressed the 2007–2008 financial crisis and included a major stimulus package to guide the economy in recovering from the Great Recession, a partial extension of George W. Bush's tax cuts, legislation to reform health care, a major financial regulation reform bill, and the end of a major U.S. military presence in Iraq. Obama also appointed Supreme Court justices Sonia Sotomayor and Elena Kagan, the former being the first Hispanic American on the Supreme Court. He ordered Operation Neptune Spear, the raid that killed Osama bin Laden, who was responsible for the September 11 attacks. Obama downplayed Bush's counterinsurgency model, expanding air strikes and making extensive use of special forces while encouraging greater reliance on host government militaries. He also ordered military involvement in Libya in order to implement UN Security Council Resolution 1973, contributing to the overthrow of Muammar Gaddafi.
Obama defeated Republican opponent Mitt Romney in the 2012 presidential election. In his second term, Obama took steps to combat climate change, signing the Paris Agreement, a major international climate agreement; and an executive order to limit carbon emissions. Obama also presided over the implementation of the Affordable Care Act and other legislation passed in his first term. He negotiated a nuclear agreement with Iran and normalized relations with Cuba. The number of American soldiers in Afghanistan decreased during Obama's second term, though U.S. soldiers remained in the country throughout his presidency. Obama promoted inclusion for LGBT Americans, becoming the first sitting U.S. president to publicly support same-sex marriage.
Obama left office on January 20, 2017, and continues to reside in Washington, D.C. Historians and political scientists rank him among the upper tier in historical rankings of American presidents. His presidential library in the South Side of Chicago began construction in 2021. Since leaving office, Obama has remained politically active, campaigning for candidates in various American elections, including Biden's successful presidential bid in 2020. Outside of politics, Obama has published three books: Dreams from My Father (1995), The Audacity of Hope (2006), and A Promised Land (2020).""",
"""Joseph Robinette Biden Jr.[b] (born November 20, 1942) is an American politician who has been the 46th and current president of the United States since 2021. A member of the Democratic Party, he served as the 47th vice president from 2009 to 2017 under President Barack Obama and represented Delaware in the U.S. Senate from 1973 to 2009.
Born in Scranton, Pennsylvania, Biden moved with his family to Delaware in 1953. He graduated from the University of Delaware in 1965 and from Syracuse University in 1968. He was elected to the New Castle County Council in 1970 and the U.S. Senate in 1972. As a senator, Biden drafted and led the effort to pass the Violent Crime Control and Law Enforcement Act and the Violence Against Women Act. He also oversaw six U.S. Supreme Court confirmation hearings, including the contentious hearings for Robert Bork and Clarence Thomas. Biden ran unsuccessfully for the 1988 and 2008 Democratic presidential nominations. In 2008, Obama chose Biden as his running mate, and he was a close counselor to Obama during his two terms as vice president. In the 2020 presidential election, the Democratic Party nominated Biden for president. He selected Kamala Harris as his running mate, and they defeated Republican incumbents Donald Trump and Mike Pence. He is the oldest president in U.S. history and the first to serve with a female vice president.
As president, Biden signed the American Rescue Plan Act in response to the COVID-19 pandemic and subsequent recession. He signed bipartisan bills on infrastructure and manufacturing. He proposed the Build Back Better Act, which failed in Congress, but aspects of which were incorporated into the Inflation Reduction Act that he signed into law in 2022. Biden appointed Ketanji Brown Jackson to the Supreme Court. He worked with congressional Republicans to resolve the 2023 debt-ceiling crisis by negotiating a deal to raise the debt ceiling. In foreign policy, Biden restored America's membership in the Paris Agreement. He oversaw the complete withdrawal of U.S. troops from Afghanistan that ended the war in Afghanistan, leading to the collapse of the Afghan government and the Taliban seizing control. He responded to the Russian invasion of Ukraine by imposing sanctions on Russia and authorizing civilian and military aid to Ukraine. During the Israel–Hamas war, Biden condemned the actions of Hamas as terrorism, announced military support for Israel and sent limited humanitarian aid to the Gaza Strip.
In April 2023, Biden announced his reelection campaign and, after the Democratic primaries, became the Democratic Party's presumptive nominee in the 2024 presidential election. However, after his performance during the first presidential debate on June 27, he withdrew his candidacy in July 2024 amid concerns about his age and health, becoming the first U.S. president to stop running for reelection after securing enough delegates to win renomination. He endorsed Vice President Harris to be the Democrats' nominee.""",
]
demo = gr.Interface(fn=fn, inputs="text", outputs="text", examples=examples)
demo.launch()