Skip to main content

No project description provided

Project description

from compressor.semantic import compress_text, find_needle_in_haystack

text = """
Akin to France's heartier, spicier, richer boeuf bourguignon, "alcatra" is synonymous with a single island in the remote Azores archipelago.  The Azores, an archipelago of nine islands belonging to Portugal and located roughly between Europe and the US, are cow country. They're said to be home to more cattle than people, and despite being home to less than 3% of Portugal's population, the islands produce 30% of Portugal's dairy products and 13% of its beef.   Beef is part of everyday life in the Azores, and come spring on one particular island, the ingredient even crosses paths with religion.   In the days following Easter, Azorean people kick off a series of religious celebrations called Festas do Espírito Santo (Festivals of the Holy Spirit). During the 13th Century, a Catholic sect called the Cult of the Holy Spirit predicted a utopian era on Earth. This fringe faith was discouraged in mainland Europe but lived on in these remote islands in the middle of the Atlantic Ocean. The sect was also promoted by Portuguese queen Elizabeth of Aragon (also known as Elizabeth of Portugal), who was known for her charity.  Over the subsequent centuries, a series of festivals emerged on the Azores that blended these utopian aspirations with the queen's alleged generosity. Between Easter and the week following Whitsunday, a total of eight weeks, the islands host a series of parades and other cultural and religious festivals that revolve around brightly coloured community houses called impérios. During this time, the community houses also collect donations from locals, which is then redistributed to people in the form of bread, beef and wine.  These three elements generally come together in the form of a soup, called sopa do Espírito Santo, that's served at the impérios during the festivals. But on the island of Terceira, locals combine these ingredients in a different and delicious way, one that's become synonymous with the island's culinary identity.  Austin Bush The Festas do Espírito Santo revolve around community houses called impérios (Credit: Austin Bush)Austin Bush The Festas do Espírito Santo revolve around community houses called impérios (Credit: Austin Bush) "People eat alcatra year round, but especially during the celebrations in spring and summer," explains Duarte Fournier. He is the Grand Master of the Brotherhood of Alcatra, a culinary fraternity on Terceira, and is telling me about the island's signature dish: cuts of beef braised in local wine, smoked pork fat and dried spices, resulting in something of a heartier, spicier, richer version of France's famed boeuf bourguignon.  We're sitting at a cafe in Angra do Heroísmo, Terceira's largest city, and as we chat, children race to and from a nearby império delivering massive trays of raw beef to neighbours. Fournier tells me that alcatra likely has its origins in northern Portugal, where there's a tradition of baking goat in wine.  "We don't know why it's called alcatra," he says. "We suppose it's from Arabic. Al catar means 'small pieces of meat'."  According to Fournier, alcatra differs from mainland Portugal's baked meat dishes in that it includes dried spices, generally allspice and black peppercorns, but also sometimes clove or cinnamon.
""".strip()

compressed_text_90_percent = compress_text(text, compression_rate=0.9)
print(compressed_text_90_percent)
# "He is the Grand Master of the Brotherhood of Alcatra, a culinary fraternity on Terceira, and is telling me about the island's signature dish: cuts of beef braised in local wine, smoked pork fat and dried spices, resulting in something of a heartier, spicier, richer version of France's famed boeuf bourguignon."

compressed_text_to_100_tokens = compress_text(text, target_token_count=100)
print(compressed_text_to_100_tokens)
# 'Akin to France\'s heartier, spicier, richer boeuf bourguignon, "alcatra" is synonymous with a single island in the remote Azores archipelago.'

text_reference = "Archipelago Islands"
compressed_text_with_steering = compress_text(text, compression_rate=0.7, reference_text_steering=text_reference)
# 'Akin to france\'s heartier, spicier, richer boeuf bourguignon, "alcatra" is synonymous with a single island in the remote azores archipelago. The azores, an archipelago of nine islands belonging to portugal and located roughly between europe and the us, are cow country. Beef is part of everyday life in the azores, and come spring on one particular island, the ingredient even crosses paths with religion. But on the island of terceira, locals combine these ingredients in a different and delicious way, one that\'s become synonymous with the island\'s culinary identity. He is the grand master of the brotherhood of alcatra, a culinary fraternity on terceira, and is telling me about the island\'s signature dish: cuts of beef braised in local wine, smoked pork fat and dried spices, resulting in something of a heartier, spicier, richer version of france\'s famed boeuf bourguignon.'

needle_in_haystack = find_needle_in_haystack(
    haystack = text,
    needle = "Archipelago Islands",
    block_size = 200
)
# 'Akin to France\'s heartier, spicier, richer boeuf bourguignon, "alcatra" is synonymous with a single island in the remote Azores archipelago.  The Azores, an archipelago of nine islands belonging to Portugal and located roughly between Europe and the US, are cow country. They\'re said to be home to more cattle than people, and despite being home to less than 3% of Portugal\'s population, the islands'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semantic_compressor-1.4.tar.gz (45.9 MB view details)

Uploaded Source

Built Distribution

semantic_compressor-1.4-py3-none-any.whl (45.9 MB view details)

Uploaded Python 3

File details

Details for the file semantic_compressor-1.4.tar.gz.

File metadata

  • Download URL: semantic_compressor-1.4.tar.gz
  • Upload date:
  • Size: 45.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for semantic_compressor-1.4.tar.gz
Algorithm Hash digest
SHA256 4eae7d163887e9413dca3b4e59af40eb3e2c36142a29755b7fb52312cdc64204
MD5 3ce9432efd0af92f79cc6d33a4c5c018
BLAKE2b-256 919eb5dd7ec5db8e0dd28bf32dccce2bd1f48c399b1e3020134cad5999de5fa0

See more details on using hashes here.

File details

Details for the file semantic_compressor-1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_compressor-1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 57dddf5dc2eb94e6742280f3eaa75bdccd01c56d427e1b17da151f47f471b4cb
MD5 8feb02cf45a8ca4b002ac58d407b9d9a
BLAKE2b-256 cb5ee508bacfd3bc249fa1a3f52c20033d6547d4b1b34391b10bc12c13a58e34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page