!pip install whoosh paginate-whoosh streamlit -Uq
!wget https://tufts.box.com/shared/static/325sgkodnq30ez61ugazvctif6r24hsu.csv -O daf.csv
--2025-02-04 14:28:37-- https://tufts.box.com/shared/static/325sgkodnq30ez61ugazvctif6r24hsu.csv
Resolving tufts.box.com (tufts.box.com)... 74.112.186.157, 2620:117:bff0:12d::
Connecting to tufts.box.com (tufts.box.com)|74.112.186.157|:443... connected.
HTTP request sent, awaiting response...
301 Moved Permanently
Location: /public/static/325sgkodnq30ez61ugazvctif6r24hsu.csv [following]
--2025-02-04 14:28:37-- https://tufts.box.com/public/static/325sgkodnq30ez61ugazvctif6r24hsu.csv
Reusing existing connection to tufts.box.com:443.
HTTP request sent, awaiting response...
301 Moved Permanently
Location: https://tufts.app.box.com/public/static/325sgkodnq30ez61ugazvctif6r24hsu.csv [following]
--2025-02-04 14:28:38-- https://tufts.app.box.com/public/static/325sgkodnq30ez61ugazvctif6r24hsu.csv
Resolving tufts.app.box.com (tufts.app.box.com)... 74.112.186.157, 2620:117:bff0:12d::
Connecting to tufts.app.box.com (tufts.app.box.com)|74.112.186.157|:443... connected.
HTTP request sent, awaiting response...
302 Found
Location: https://public.boxcloud.com/d/1/b1!BW3vidpb1pN1sLVFg7im74AsAHuvtUf4-czZCHPoepis4-gnlVRe9Dxha1dbH0o1Lhc0ZBKnKPEFmSe2dFHhx6mqZgGeIw9Zm-IXsaxvFw4zV0FWddEv6wAIYx9pnYt5CbcrqT9SBdI8p9mTXWgnnRdZ88V_3CKdunNoVlms2t3_IJ06bCw4hr2t_CCILnc8O7dBJgSJlipRAGgmwPfbsPjAbiOUSND_PwXl91uLy-eArLPV4jNprV5BVX3E1USKfmiFhoit5qOflV-Y-mHxmcuLUwIl6jUiT-4BxJX0C5yliB_uzo2LeUwANbUFfRNR0LnSOeIOS7RPNaxvFTp0Nd_OztoChVhsGFM7cLURda748VNvC-iEs2SOmno34hzs_xXy9lTYaDnbWxrL-6pll0vjc8lveJQhQPmhw7K0eGMODasya0iwQMc8X8xFHj2E532qB4N1tK1gaaTm3vYHg4o_vAu5kKM8IvPnEG5uiFOKvJC-OAf1o2wDJHWveUi8TnHzyxodNrDwoMBlUtWFetTILPbsSlvgiOc1-8BbRVve4vD238-_UzYerfdwlslZMZJx_6TnyIuzRaUGfPRVe6w84pmFemTsQ9--JI4Ab5TgqDXfLjDPGzqhPGeUv-j1UJW3JsNRRMvIStQdbkx-x8vJmKkCYOM4AMc_37FSQNCy1isOZl2Wfg6EOBDEIfhEcBfBfRqMul6rlVn6fchXxg4DAbBohe-eWI7RVglVNC1ayfAi5yJrXNkC2ngv23HgJa6YYgGxNXtD8OgbpNtQPn5zki7Bos_zVbcRT1fxqQL8oQDrjyEKNn9QDZ1vf21zMQnFYQZtnvBLI2DwQCIZ-nBRcxfX48DKJuTpUaNpYk5-PfyzpUJEGrKPil-MX3UUlEkGq3aWwNzGU7OiwY-kpsnuAR7jckE-BDIztLuhEQKOYvpqeZpaRe3ZSFSWj2XRgjLy10D5gAjzGwIoWec5R5_aIG26dF7iUDOetC-J3XwWPah-lvQkGSgSvVD_yQHQl4YmI0aKUw1IIUjNFazXh7UBGgND0UuRmv2_A0sGNxd4trSm5SbTnpQNyb2mFpgfpvj-VlR-GgCFiV9xtKliquW5LojrAZYJm9oVzcQIvq7RPwRU5AWPkwRDWwFvquzSPJ_dQC4gdVPfkeBfbMUnq09Jr5QMAhcbG_gsKpkUd7e-30HfS0_ElXWrnGUtDzX74-BIdb6FEtyqGrPIhJwvJKI3s-IPf_QAusq4wWSCC_InoJvUCKV7rL8RUF5Us7XTue8GQfQ111DEPTI7RQCkLZfg5lPv-6I6tKGi5pzbkewf_d12izNRCwMT2u-ebHr-RmpmiwMB2I0r5Q_Rx77hFMT2BBfn2oxx2BaKtuppuaYrY1ouOknmxVLvM9cjCuHO3Q-6n2DG0qhvqirNtnmqqPDBcIR55-IIJNFmprfLkMSqT56S53xcqB12nqvFKIPpYxf5fhLSh3QtqHxPwxBPkzMQYFQ7PX9FzY9O-g../download [following]
--2025-02-04 14:28:38-- https://public.boxcloud.com/d/1/b1!BW3vidpb1pN1sLVFg7im74AsAHuvtUf4-czZCHPoepis4-gnlVRe9Dxha1dbH0o1Lhc0ZBKnKPEFmSe2dFHhx6mqZgGeIw9Zm-IXsaxvFw4zV0FWddEv6wAIYx9pnYt5CbcrqT9SBdI8p9mTXWgnnRdZ88V_3CKdunNoVlms2t3_IJ06bCw4hr2t_CCILnc8O7dBJgSJlipRAGgmwPfbsPjAbiOUSND_PwXl91uLy-eArLPV4jNprV5BVX3E1USKfmiFhoit5qOflV-Y-mHxmcuLUwIl6jUiT-4BxJX0C5yliB_uzo2LeUwANbUFfRNR0LnSOeIOS7RPNaxvFTp0Nd_OztoChVhsGFM7cLURda748VNvC-iEs2SOmno34hzs_xXy9lTYaDnbWxrL-6pll0vjc8lveJQhQPmhw7K0eGMODasya0iwQMc8X8xFHj2E532qB4N1tK1gaaTm3vYHg4o_vAu5kKM8IvPnEG5uiFOKvJC-OAf1o2wDJHWveUi8TnHzyxodNrDwoMBlUtWFetTILPbsSlvgiOc1-8BbRVve4vD238-_UzYerfdwlslZMZJx_6TnyIuzRaUGfPRVe6w84pmFemTsQ9--JI4Ab5TgqDXfLjDPGzqhPGeUv-j1UJW3JsNRRMvIStQdbkx-x8vJmKkCYOM4AMc_37FSQNCy1isOZl2Wfg6EOBDEIfhEcBfBfRqMul6rlVn6fchXxg4DAbBohe-eWI7RVglVNC1ayfAi5yJrXNkC2ngv23HgJa6YYgGxNXtD8OgbpNtQPn5zki7Bos_zVbcRT1fxqQL8oQDrjyEKNn9QDZ1vf21zMQnFYQZtnvBLI2DwQCIZ-nBRcxfX48DKJuTpUaNpYk5-PfyzpUJEGrKPil-MX3UUlEkGq3aWwNzGU7OiwY-kpsnuAR7jckE-BDIztLuhEQKOYvpqeZpaRe3ZSFSWj2XRgjLy10D5gAjzGwIoWec5R5_aIG26dF7iUDOetC-J3XwWPah-lvQkGSgSvVD_yQHQl4YmI0aKUw1IIUjNFazXh7UBGgND0UuRmv2_A0sGNxd4trSm5SbTnpQNyb2mFpgfpvj-VlR-GgCFiV9xtKliquW5LojrAZYJm9oVzcQIvq7RPwRU5AWPkwRDWwFvquzSPJ_dQC4gdVPfkeBfbMUnq09Jr5QMAhcbG_gsKpkUd7e-30HfS0_ElXWrnGUtDzX74-BIdb6FEtyqGrPIhJwvJKI3s-IPf_QAusq4wWSCC_InoJvUCKV7rL8RUF5Us7XTue8GQfQ111DEPTI7RQCkLZfg5lPv-6I6tKGi5pzbkewf_d12izNRCwMT2u-ebHr-RmpmiwMB2I0r5Q_Rx77hFMT2BBfn2oxx2BaKtuppuaYrY1ouOknmxVLvM9cjCuHO3Q-6n2DG0qhvqirNtnmqqPDBcIR55-IIJNFmprfLkMSqT56S53xcqB12nqvFKIPpYxf5fhLSh3QtqHxPwxBPkzMQYFQ7PX9FzY9O-g../download
Resolving public.boxcloud.com (public.boxcloud.com)... 74.112.186.164, 2620:117:bff0:e2::
Connecting to public.boxcloud.com (public.boxcloud.com)|74.112.186.164|:443... connected.
HTTP request sent, awaiting response...
200 OK
Length: 4643634 (4.4M) [text/csv]
Saving to: ‘daf.csv’
daf.csv 0%[ ] 0 --.-KB/s
daf.csv 100%[===================>] 4.43M --.-KB/s in 0.1s
2025-02-04 14:28:39 (31.1 MB/s) - ‘daf.csv’ saved [4643634/4643634]
Creating a Search Engine for your own data using Whoosh
#
No matter the discipline, scholars tend to accumulate a vast array of textual sources. Regardless of whether these are primary or seconrdary sources, researchers often need help wading through these sources and finding places where it’s best to start digging into the text.
In this notebook, we’ll explore how to create and customize your own search engine so that you can easily and quickly search through your data. We will be using a Python library Whoosh
, which implements indexing, complex logical queries and searching in pure Python, meaning that it doesn’t require a compiler or Java. Whoosh
is not a search engine itself, but rather a library that allows users to develop their own search engine.
Setting up the data#
In this section I’ll download some data and put it into a form that is to easy index for Whoosh
. In this notebook, we’ll be searching through Edward Gibbon’s Decline and Fall of the Roman Empire, a notoriously long and difficult book about the history of Europe from ~200 to ~1400 CE.
import pandas as pd
daf = pd.read_csv('daf.csv')[['title','text']]
daf
title | text | |
---|---|---|
0 | The Extent Of The Empire In The Age Of The Ant... | Introduction. The Extent And Military Fo... |
1 | The Extent Of The Empire In The Age Of The Ant... | It was an ancient tradition, that when the Cap... |
2 | The Extent Of The Empire In The Age Of The Ant... | The camp of a Roman legion presented the appea... |
3 | The Internal Prosperity In The Age Of The Anto... | Of The Union And Internal Prosperity Of The Ro... |
4 | The Internal Prosperity In The Age Of The Anto... | Till the privileges of Romans had been progres... |
... | ... | ... |
291 | Final Settlement Of The Ecclesiastical State.—... | Never perhaps has the energy and effect of a s... |
292 | Final Settlement Of The Ecclesiastical State.—... | Without drawing his sword, count Pepin restore... |
293 | Final Settlement Of The Ecclesiastical State.—... | The royal prerogative of coining money, which ... |
294 | Prospect Of The Ruins Of Rome In The Fifteenth... | Prospect Of The Ruins Of Rome In The Fifteenth... |
295 | Prospect Of The Ruins Of Rome In The Fifteenth... | These general observations may be separately a... |
296 rows × 2 columns
I have this data already in a DataFrame or spreadsheet. However, this is not needed for Whoosh
. Instead, I’m using this format as an easy way to store and access the data.
Indexing our data#
Now that we have some data to search through, we can begin indexing it. When it indexes text data, Whoosh
creates a variety of files for us. These files contain tables which relate document names (in our case, the names of the chapters, the title
column) to vectorized collections of words. Vectorization is the process of turning natural language into long lists of numbers so that we can conduct automated processes. There are a many ways to do this, so if you are interested, I recommend checking out the Textual Feature Extraction using Traditional Machine Learning
workshop after this one.
To index data in Whoosh
we need a couple things in addition to our dawta:
An empty directory, where we can saved the files that
Whoosh
producesWe also need a schema, a list of names and data types that we give to
Whoosh
so that the indexer knows how to store our data
See the example below.
# designing a schema
# we have two fields, title and text, both strings, so this will be a relatively simple schema
from whoosh.fields import Schema, TEXT, KEYWORD, ID, STORED
from whoosh.analysis import StemmingAnalyzer
schema = Schema(
title = ID(stored=True),
text = TEXT(analyzer=StemmingAnalyzer(), stored=True) # (optional) applies stemming to the text -> run, running, ran are all found when searching for "run"
)
# now that we have a schema we can index our text
import os
from whoosh import index
if not os.path.exists("daf_index"): # creates an empty directory
os.mkdir("daf_index")
ix = index.create_in("daf_index", schema)
Nota bene: When you create an index as we have in the last line of the cell above that directory is now classified as an FileIndex
type object. This means that if you need to start over, you’ll need to delete this folder and make it again. Sometimes, this can be confusing, especially because the error doesn’t give you much guidance.
writer = ix.writer() # allows us to add documents
for i, row in daf.iterrows(): # looping through our data
writer.add_document(title=row['title'], text=row['text']) # adding each row to our index
writer.commit() # commits the added documents
Search our data#
With our completed index, we can begin searching through our data. Whoosh
provides many options for searching including boolean operators (AND, OR, NOT) applying the stemmer we used when indexing.
from whoosh.qparser import QueryParser
from pprint import pprint
qp = QueryParser(
"text", # field we want to search in
schema=ix.schema
)
q = qp.parse(u"The Crusades")
# can print out the results below
with ix.searcher() as s:
results = s.search(q) # list of dictionaries
for i, hit in enumerate(results): # loop through them
print(f"Result {i+1}")
print(hit['title']) # chapter name from our schema
pprint(hit['text']) # text
print('--'*20)
Result 1
The Crusades.—Part I.
('Preservation Of The Greek Empire.—Numbers, Passage, And Event, Of The '
'Second And Third Crusades.—St. Bernard.— Reign Of Saladin In Egypt And '
'Syria.—His Conquest Of Jerusalem.—Naval Crusades.—Richard The First Of '
'England.— Pope Innocent The Third; And The Fourth And Fifth Crusades.— '
'The Emperor Frederic The Second.—Louis The Ninth Of France; And The Two '
'Last Crusades.—Expulsion Of The Latins Or Franks By The Mamelukes. In '
'a style less grave than that of history, I should perhaps compare the '
'emperor Alexius In the twelfth century, three great '
'emigrations marched by land from the West for the relief of Palestine. The '
'soldiers and pilgrims of Lombardy, France, and Germany were excited by the '
'example and success of the first crusade. I. Of the swarms that so '
'closely trod in the footsteps of the first pilgrims, the chiefs were equal '
'in rank, though unequal in fame and merit, to Godfrey of Bouillon and his '
'fellow-adventurers. At their head were displayed the banners of the dukes of '
'Burgundy, Bavaria, and Aquitain; the first a descendant of Hugh Capet, the '
'second, a father of the Brunswick line: the archbishop of Milan, a temporal '
'prince, transported, for the benefit of the Turks, the treasures and '
'ornaments of his church and palace; and the veteran crusaders, Hugh the '
'Great and Stephen of Chartres, returned to consummate their unfinished vow. '
'The huge and disorderly bodies of their followers moved forward in two '
'columns; and if the first consisted of two hundred and sixty thousand '
'persons, the second might possibly amount to sixty thousand horse and one '
'hundred thousand foot. II. The number and character of the '
'strangers was an object of terror to the effeminate Greeks, and the '
'sentiment of fear is nearly allied to that of hatred. This aversion was '
'suspended or softened by the apprehension of the Turkish power; and the '
'invectives of the Latins will not bias our more candid belief, that the '
'emperor Alexius dissembled their insolence, eluded their hostilities, '
'counselled their rashness, and opened to their ardor the road of pilgrimage '
'and conquest. But when the Turks had been driven from Nice and the '
'sea-coast, when the Byzantine princes no longer dreaded the distant sultans '
'of Cogni, they felt with purer indignation the free and frequent passage of '
'the western Barbarians, who violated the majesty, and endangered the safety, '
'of the empire. The second and third crusades were undertaken under the reign '
'of Manuel Comnenus and Isaac Angelus. Of the former, the passions were '
'always impetuous, and often malevolent; and the natural union of a cowardly '
'and a mischievous temper was exemplified in the latter, who, without merit '
'or mercy, could punish a tyrant, and occupy his throne. It was secretly, and '
'perhaps tacitly, resolved by the prince and people to destroy, or at least '
'to discourage, the pilgrims, by every species of injury and oppression; and '
'their want of prudence and discipline continually afforded the pretence or '
'the opportunity. The Western monarchs had stipulated a safe passage and fair '
'market in the country of their Christian brethren; the treaty had been '
'ratified by oaths and hostages; and the poorest soldier of Frederic’s army '
'was furnished with three marks of silver to defray his expenses on the road. '
'But every engagement was violated by treachery and injustice; and the '
'complaints of the Latins are attested by the honest confession of a Greek '
'historian, who has dared to prefer truth to his country. III. The '
'swarms that followed the first crusade were destroyed in Anatolia by famine, '
'pestilence, and the Turkish arrows; and the princes only escaped with some '
'squadrons of horse to accomplish their lamentable pilgrimage. A just opinion '
'may be formed of their knowledge and humanity; of their knowledge, from the '
'design of subduing Persia and Chorasan in their way to '
'Jerusalem; The enthusiasm of the first crusade is a '
'natural and simple event, while hope was fresh, danger untried, and '
'enterprise congenial to the spirit of the times. But the obstinate '
'perseverance of Europe may indeed excite our pity and admiration; that no '
'instruction should have been drawn from constant and adverse experience; '
'that the same confidence should have repeatedly grown from the same '
'failures; that six succeeding generations should have rushed headlong down '
'the precipice that was open before them; and that men of every condition '
'should have staked their public and private fortunes on the desperate '
'adventure of possessing or recovering a tombstone two thousand miles from '
'their country. In a period of two centuries after the council of Clermont, '
'each spring and summer produced a new emigration of pilgrim warriors for the '
'defence of the Holy Land; but the seven great armaments or crusades were '
'excited by some impending or recent calamity: the nations were moved by the '
'authority of their pontiffs, and the example of their kings: their zeal was '
'kindled, and their reason was silenced, by the voice of their holy orators; '
'and among these, Bernard, Omnipotence itself cannot '
'escape the murmurs of its discordant votaries; since the same dispensation '
'which was applauded as a deliverance in Europe, was deplored, and perhaps '
'arraigned, as a calamity in Asia. After the loss of Jerusalem, the Syrian '
'fugitives diffused their consternation and sorrow; Bagdad mourned in the '
'dust; the cadhi Zeineddin of Damascus tore his beard in the caliph’s '
'presence; and the whole divan shed tears at his melancholy tale. ')
----------------------------------------
Result 2
The Crusades.—Part III.
('Philip Augustus, and Richard the First, are the only kings of France and '
'England who have fought under the same banners; but the holy service in '
'which they were enlisted was incessantly disturbed by their national '
'jealousy; and the two factions, which they protected in Palestine, were more '
'averse to each other than to the common enemy. In the eyes of the Orientals; '
'the French monarch was superior in dignity and power; and, in the emperor’s '
'absence, the Latins revered him as their temporal chief. '
'During these hostilities, a languid and tedious negotiation The '
'noblest monument of a conqueror’s fame, and of the terror which he inspired, '
'is the Saladine tenth, a general tax which was imposed on the laity, and '
'even the clergy, of the Latin church, for the service of the holy war. The '
'practice was too lucrative to expire with the occasion: and this tribute '
'became the foundation of all the tithes and tenths on ecclesiastical '
'benefices, which have been granted by the Roman pontiffs to Catholic '
'sovereigns, or reserved for the immediate use of the apostolic '
'see. The persons, the families, and estates of the pilgrims, were '
'under the immediate protection of the popes; and these spiritual patrons '
'soon claimed the prerogative of directing their operations, and enforcing, '
'by commands and censures, the accomplishment of their vow. Frederic the '
'Second, Of the seven crusades, the two last were undertaken by '
'Louis the Ninth, king of France; who lost his liberty in Egypt, and his life '
'on the coast of Africa. Twenty-eight years after his death, he was canonized '
'at Rome; and sixty-five miracles were readily found, and solemnly attested, '
'to justify the claim of the royal saint. In complete armor, the '
'oriflamme waving before him, Louis leaped foremost on the beach; and the '
'strong city of Damietta, which had cost his predecessors a siege of sixteen '
'months, was abandoned on the first assault by the trembling Moslems. But '
'Damietta was the first and the last of his conquests; and in the fifth and '
'sixth crusades, the same causes, almost on the same ground, were productive '
'of similar calamities. The memory of his defeat excited Louis, after '
'sixteen years of wisdom and repose, to undertake the seventh and last of the '
'crusades. His finances were restored, his kingdom was enlarged; a new '
'generation of warriors had arisen, and he advanced with fresh confidence at '
'the head of six thousand horse and thirty thousand foot. The loss of Antioch '
'had provoked the enterprise; a wild hope of baptizing the king of Tunis '
'tempted him to steer for the African coast; and the report of an immense '
'treasure reconciled his troops to the delay of their voyage to the Holy '
'Land. Instead of a proselyte, he found a siege: the French panted and died '
'on the burning sands: St. Louis expired in his tent; and no sooner had he '
'closed his eyes, than his son and successor gave the signal of the '
'retreat. A more unjust and absurd constitution cannot be devised than '
'that which condemns the natives of a country to perpetual servitude, under '
'the arbitrary dominion of strangers and slaves. Yet such has been the state '
'of Egypt above five hundred years. The most illustrious sultans of the '
'Baharite and Borgite dynasties After the loss of Jerusalem, '
'Acre, ')
----------------------------------------
Result 3
The First Crusade.—Part II.
('Of the chiefs and soldiers who marched to the holy sepulchre, I will dare to '
'affirm, that all were prompted by the spirit of enthusiasm; the belief of '
'merit, the hope of reward, and the assurance of divine aid. But I am equally '
'persuaded, that in many it was not the sole, that in some it was not the '
'leading, principle of action. The use and abuse of religion are feeble to '
'stem, they are strong and irresistible to impel, the stream of national '
'manners. Against the private wars of the Barbarians, their bloody '
'tournaments, licentious love, and judicial duels, the popes and synods might '
'ineffectually thunder. It is a more easy task to provoke the metaphysical '
'disputes of the Greeks, to drive into the cloister the victims of anarchy or '
'despotism, to sanctify the patience of slaves and cowards, or to assume the '
'merit of the humanity and benevolence of modern Christians. War and exercise '
'were the reigning passions of the Franks or Latins; they were enjoined, as a '
'penance, to gratify those passions, to visit distant lands, and to draw '
'their swords against the nation of the East. Their victory, or even their '
'attempt, would immortalize the names of the intrepid heroes of the cross; '
'and the purest piety could not be insensible to the most splendid prospect '
'of military glory. In the petty quarrels of Europe, they shed the blood of '
'their friends and countrymen, for the acquisition perhaps of a castle or a '
'village. They could march with alacrity against the distant and hostile '
'nations who were devoted to their arms; their fancy already grasped the '
'golden sceptres of Asia; and the conquest of Apulia and Sicily by the '
'Normans might exalt to royalty the hopes of the most private adventurer. '
'Christendom, in her rudest state, must have yielded to the climate and '
'cultivation of the Mahometan countries; and their natural and artificial '
'wealth had been magnified by the tales of pilgrims, and the gifts of an '
'imperfect commerce. The vulgar, both the great and small, were taught to '
'believe every wonder, of lands flowing with milk and honey, of mines and '
'treasures, of gold and diamonds, of palaces of marble and jasper, and of '
'odoriferous groves of cinnamon and frankincense. In this earthly paradise, '
'each warrior depended on his sword to carve a plenteous and honorable '
'establishment, which he measured only by the extent of his wishes. '
'These motives were potent and numerous: when we have singly computed their '
'weight on the mind of each individual, we must add the infinite series, the '
'multiplying powers, of example and fashion. The first proselytes became the '
'warmest and most effectual missionaries of the cross: among their friends '
'and countrymen they preached the duty, the merit, and the recompense, of '
'their holy vow; and the most reluctant hearers were insensibly drawn within '
'the whirlpool of persuasion and authority. The martial youths were fired by '
'the reproach or suspicion of cowardice; the opportunity of visiting with an '
'army the sepulchre of Christ was embraced by the old and infirm, by women '
'and children, who consulted rather their zeal than their strength; and those '
'who in the evening had derided the folly of their companions, were the most '
'eager, the ensuing day, to tread in their footsteps. The ignorance, which '
'magnified the hopes, diminished the perils, of the enterprise. Since the '
'Turkish conquest, the paths of pilgrimage were obliterated; the chiefs '
'themselves had an imperfect notion of the length of the way and the state of '
'their enemies; and such was the stupidity of the people, that, at the sight '
'of the first city or castle beyond the limits of their knowledge, they were '
'ready to ask whether that was not the Jerusalem, the term and object of '
'their labors. Yet the more prudent of the crusaders, who were not sure that '
'they should be fed from heaven with a shower of quails or manna, provided '
'themselves with those precious metals, which, in every country, are the '
'representatives of every commodity. To defray, according to their rank, the '
'expenses of the road, princes alienated their provinces, nobles their lands '
'and castles, peasants their cattle and the instruments of husbandry. The '
'value of property was depreciated by the eager competition of multitudes; '
'while the price of arms and horses was raised to an exorbitant height by the '
'wants and impatience of the buyers. The fifteenth of August had been '
'fixed in the council of Clermont for the departure of the pilgrims; but the '
'day was anticipated by the thoughtless and needy crowd of plebeians, and I '
'shall briefly despatch the calamities which they inflicted and suffered, '
'before I enter on the more serious and successful enterprise of the chiefs. '
'Early in the spring, from the confines of France and Lorraine, above sixty '
'thousand of the populace of both sexes flocked round the first missionary of '
'the crusade, and pressed him with clamorous importunity to lead them to the '
'holy sepulchre. The hermit, assuming the character, without the talents or '
'authority, of a general, impelled or obeyed the forward impulse of his '
'votaries along the banks of the Rhine and Danube. Their wants and numbers '
'soon compelled them to separate, and his lieutenant, Walter the Penniless, a '
'valiant though needy soldier, conducted a van guard of pilgrims, whose '
'condition may be determined from the proportion of eight horsemen to fifteen '
'thousand foot. The example and footsteps of Peter were closely pursued by '
'another fanatic, the monk Godescal, whose sermons had swept away fifteen or '
'twenty thousand peasants from the villages of Germany. Their rear was again '
'pressed by a herd of two hundred thousand, the most stupid and savage refuse '
'of the people, who mingled with their devotion a brutal license of rapine, '
'prostitution, and drunkenness. Some counts and gentlemen, at the head of '
'three thousand horse, attended the motions of the multitude to partake in '
'the spoil; but their genuine leaders (may we credit such folly?) were a '
'goose and a goat, who were carried in the front, and to whom these worthy '
'Christians ascribed an infusion of the divine spirit. Between the '
'frontiers of Austria and the seat of the Byzantine monarchy, the crusaders '
'were compelled to traverse as interval of six hundred miles; the wild and '
'desolate countries of Hungary “To save time and space, I shall '
'represent, in a short table, the particular references to the great events '
'of the first crusade.” [See Table ')
----------------------------------------
Result 4
Schism Of The Greeks And Latins.—Part I.
('Schism Of The Greeks And Latins.—Reign And Character Of Amurath The '
'Second.—Crusade Of Ladislaus, King Of Hungary.— His Defeat And '
'Death.—John Huniades.—Scanderbeg.— Constantine Palæologus, Last Emperor '
'Of The East. The respective merits of Rome and Constantinople are compared '
'and celebrated by an eloquent Greek, the father of the Italian '
'schools. The last hope of the falling city and empire was placed in '
'the harmony of the mother and daughter, in the maternal tenderness of Rome, '
'and the filial obedience of Constantinople. In the synod of Florence, the '
'Greeks and Latins had embraced, and subscribed, and promised; but these '
'signs of friendship were perfidious or fruitless; The schism was not '
'confined to the narrow limits of the Byzantine empire. Secure under the '
'Mamaluke sceptre, the three patriarchs of Alexandria, Antioch, and '
'Jerusalem, assembled a numerous synod; disowned their representatives at '
'Ferrara and Florence; condemned the creed and council of the Latins; and '
'threatened the emperor of Constantinople with the censures of the Eastern '
'church. Of the sectaries of the Greek communion, the Russians were the most '
'powerful, ignorant, and superstitious. Their primate, the cardinal Isidore, '
'hastened from Florence to Moscow, “Sultan Murad, or Amurath, lived '
'forty-nine, and reigned thirty years, six months, and eight days. He was a '
'just and valiant prince, of a great soul, patient of labors, learned, '
'merciful, religious, charitable; a lover and encourager of the studious, and '
'of all who excelled in any art or science; a good emperor and a great '
'general. No man obtained more or greater victories than Amurath; Belgrade '
'alone withstood his attacks. But the most striking feature in the life '
'and character of Amurath is the double abdication of the Turkish throne; '
'and, were not his motives debased by an alloy of superstition, we must '
'praise the royal philosopher, After the departure of his Greek '
'brethren, Eugenius had not been unmindful of their temporal interest; and '
'his tender regard for the Byzantine empire was animated by a just '
'apprehension of the Turks, who approached, and might soon invade, the '
'borders of Italy. But the spirit of the crusades had expired; and the '
'coldness of the Franks was not less unreasonable than their headlong '
'passion. In the eleventh century, a fanatic monk could precipitate Europe on '
'Asia for the recovery of the holy sepulchre; but in the fifteenth, the most '
'pressing motives of religion and policy were insufficient to unite the '
'Latins in the defence of Christendom. Germany was an inexhaustible '
'storehouse of men and arms: Of the Polish and Hungarian diets, a '
'religious war was the unanimous cry; and Ladislaus, after passing the '
'Danube, led an army of his confederate subjects as far as Sophia, the '
'capital of the Bulgarian kingdom. In this expedition they obtained two '
'signal victories, which were justly ascribed to the valor and conduct of '
'Huniades. In the first, with a vanguard of ten thousand men, he surprised '
'the Turkish camp; in the second, he vanquished and made prisoner the most '
'renowned of their generals, who possessed the double advantage of ground and '
'numbers. The approach of winter, and the natural and artificial obstacles of '
'Mount Hæmus, arrested the progress of the hero, who measured a narrow '
'interval of six days’ march from the foot of the mountains to the hostile '
'towers of Adrianople, and the friendly capital of the Greek empire. The '
'retreat was undisturbed; and the entrance into Buda was at once a military '
'and religious triumph. An ecclesiastical procession was followed by the king '
'and his warriors on foot: he nicely balanced the merits and rewards of the '
'two nations; and the pride of conquest was blended with the humble temper of '
'Christianity. Thirteen bashaws, nine standards, and four thousand captives, '
'were unquestionable trophies; and as all were willing to believe, and none '
'were present to contradict, the crusaders multiplied, with unblushing '
'confidence, the myriads of Turks whom they had left on the field of '
'battle. During the whole transaction, the cardinal legate had observed a '
'sullen silence, unwilling to approve, and unable to oppose, the consent of '
'the king and people. But the diet was not dissolved before Julian was '
'fortified by the welcome intelligence, that Anatolia was invaded by the '
'Caramanian, and Thrace by the Greek emperor; that the fleets of Genoa, '
'Venice, and Burgundy, were masters of the Hellespont; and that the allies, '
'informed of the victory, and ignorant of the treaty, of Ladislaus, '
'impatiently waited for the return of his victorious army. “And is it thus,” '
'exclaimed the cardinal, ')
----------------------------------------
Result 5
Partition Of The Empire By The French And Venetians.—Part III.
('But in this abject distress, the emperor and empire were still possessed of '
'an ideal treasure, which drew its fantastic value from the superstition of '
'the Christian world. The merit of the true cross was somewhat impaired by '
'its frequent division; and a long captivity among the infidels might shed '
'some suspicion on the fragments that were produced in the East and West. But '
'another relic of the Passion was preserved in the Imperial chapel of '
'Constantinople; and the crown of thorns which had been placed on the head of '
'Christ was equally precious and authentic. It had formerly been the practice '
'of the Egyptian debtors to deposit, as a security, the mummies of their '
'parents; and both their honor and religion were bound for the redemption of '
'the pledge. In the same manner, and in the absence of the emperor, the '
'barons of Romania borrowed the sum of thirteen thousand one hundred and '
'thirty-four pieces of gold The Latins of Constantinople '
'Intent on his great object, the emperor Michael visited in person and '
'strengthened the troops and fortifications of Thrace. The remains of the '
'Latins were driven from their last possessions: he assaulted without success '
'the suburb of Galata; and corresponded with a perfidious baron, who proved '
'unwilling, or unable, to open the gates of the metropolis. The next spring, '
'his favorite general, Alexius Strategopulus, whom he had decorated with the '
'title of Cæsar, passed the Hellespont with eight hundred horse and some '
'infantry, After this narrative of the expeditions of the Latins '
'to Palestine and Constantinople, I cannot dismiss the subject without '
'resolving the general consequences on the countries that were the scene, and '
'on the nations that were the actors, of these memorable crusades. If we '
'compare the æra of the crusades, the Latins of Europe with the Greeks and '
'Arabians, their respective degrees of knowledge, industry, and art, our rude '
'ancestors must be content with the third rank in the scale of nations. Their '
'successive improvement and present superiority may be ascribed to a peculiar '
'energy of character, to an active and imitative spirit, unknown to their '
'more polished rivals, who at that time were in a stationary or retrograde '
'state. With such a disposition, the Latins should have derived the most '
'early and essential benefits from a series of events which opened to their '
'eyes the prospect of the world, and introduced them to a long and frequent '
'intercourse with the more cultivated regions of the East. The first and most '
'obvious progress was in trade and manufactures, in the arts which are '
'strongly prompted by the thirst of wealth, the calls of necessity, and the '
'gratification of the sense or vanity. Among the crowd of unthinking '
'fanatics, a captive or a pilgrim might sometimes observe the superior '
'refinements of Cairo and Constantinople: the first importer of '
'windmills ')
----------------------------------------
Result 6
The First Crusade.—Part I.
('Origin And Numbers Of The First Crusade.—Characters Of The Latin '
'Princes.—Their March To Constantinople.—Policy Of The Greek Emperor '
'Alexius.—Conquest Of Nice, Antioch, And Jerusalem, By The '
'Franks.—Deliverance Of The Holy Sepulchre.— Godfrey Of Bouillon, First '
'King Of Jerusalem.—Institutions Of The French Or Latin Kingdom. About '
'twenty years after the conquest of Jerusalem by the Turks, the holy '
'sepulchre was visited by a hermit of the name of Peter, a native of Amiens, '
'in the province of Picardy The magnanimous spirit of Gregory the '
'Seventh had already embraced the design of arming Europe against Asia; the '
'ardor of his zeal and ambition still breathes in his epistles: from either '
'side of the Alps, fifty thousand Catholics had enlisted under the banner of '
'St. Peter; It may occasion some surprise that the Roman '
'pontiff should erect, in the heart of France, the tribunal from whence he '
'hurled his anathemas against the king; but our surprise will vanish so soon '
'as we form a just estimate of a king of France of the eleventh '
'century. So familiar, and as it were so natural to man, is '
'the practice of violence, that our indulgence allows the slightest '
'provocation, the most disputable right, as a sufficient ground of national '
'hostility. But the name and nature of a holy war demands a more rigorous '
'scrutiny; nor can we hastily believe, that the servants of the Prince of '
'Peace would unsheathe the sword of destruction, unless the motive were pure, '
'the quarrel legitimate, and the necessity inevitable. The policy of an '
'action may be determined from the tardy lessons of experience; but, before '
'we act, our conscience should be satisfied of the justice and propriety of '
'our enterprise. In the age of the crusades, the Christians, both of the East '
'and West, were persuaded of their lawfulness and merit; their arguments are '
'clouded by the perpetual abuse of Scripture and rhetoric; but they seem to '
'insist on the right of natural and religious defence, their peculiar title '
'to the Holy Land, and the impiety of their Pagan and Mahometan foes. II. '
'Palestine could add nothing to the strength or safety of the Latins; and '
'fanaticism alone could pretend to justify the conquest of that distant and '
'narrow province. The Christians affirmed that their inalienable title to the '
'promised land had been sealed by the blood of their divine Savior; it was '
'their right and duty to rescue their inheritance from the unjust possessors, '
'who profaned his sepulchre, and oppressed the pilgrimage of his disciples. '
'Vainly would it be alleged that the preeminence of Jerusalem, and the '
'sanctity of Palestine, have been abolished with the Mosaic law; that the God '
'of the Christians is not a local deity, and that the recovery of Bethlem or '
'Calvary, his cradle or his tomb, will not atone for the violation of the '
'moral precepts of the gospel. Such arguments glance aside from the leaden '
'shield of superstition; and the religious mind will not easily relinquish '
'its hold on the sacred ground of mystery and miracle. III. But the holy '
'wars which have been waged in every climate of the globe, from Egypt to '
'Livonia, and from Peru to Hindostan, require the support of some more '
'general and flexible tenet. It has been often supposed, and sometimes '
'affirmed, that a difference of religion is a worthy cause of hostility; that '
'obstinate unbelievers may be slain or subdued by the champions of the cross; '
'and that grace is the sole fountain of dominion as well as of mercy. As '
'the manners of the Christians were relaxed, their discipline of '
'penance ')
----------------------------------------
Result 7
The First Crusade.—Part IV.
('I have expiated with pleasure on the first steps of the crusaders, as they '
'paint the manners and character of Europe: but I shall abridge the tedious '
'and uniform narrative of their blind achievements, which were performed by '
'strength and are described by ignorance. From their first station in the '
'neighborhood of Nicomedia, they advanced in successive divisions; passed the '
'contracted limit of the Greek empire; opened a road through the hills, and '
'commenced, by the siege of his capital, their pious warfare against the '
'Turkish sultan. His kingdom of Roum extended from the Hellespont to the '
'confines of Syria, and barred the pilgrimage of Jerusalem, his name was '
'Kilidge-Arslan, or Soliman, Soliman was rather provoked than '
'dismayed by the loss of his capital: he admonished his subjects and allies '
'of this strange invasion of the Western Barbarians; the Turkish emirs obeyed '
'the call of loyalty or religion; the Turkman hordes encamped round his '
'standard; and his whole force is loosely stated by the Christians at two '
'hundred, or even three hundred and sixty thousand horse. Yet he patiently '
'waited till they had left behind them the sea and the Greek frontier; and '
'hovering on the flanks, observed their careless and confident progress in '
'two columns beyond the view of each other. Some miles before they could '
'reach Dorylaeum in Phrygia, the left, and least numerous, division was '
'surprised, and attacked, and almost oppressed, by the Turkish '
'cavalry. To improve the general consternation, the cousin of '
'Bohemond and the brother of Godfrey were detached from the main army with '
'their respective squadrons of five, and of seven, hundred knights. They '
'overran in a rapid career the hills and sea-coast of Cilicia, from Cogni to '
'the Syrian gates: the Norman standard was first planted on the walls of '
'Tarsus and Malmistra; but the proud injustice of Baldwin at length provoked '
'the patient and generous Italian; and they turned their consecrated swords '
'against each other in a private and profane quarrel. Honor was the motive, '
'and fame the reward, of Tancred; but fortune smiled on the more selfish '
'enterprise of his rival. Before the Franks could enter Syria, the '
'summer, and even the autumn, were completely wasted: the siege of Antioch, '
'or the separation and repose of the army during the winter season, was '
'strongly debated in their council: the love of arms and the holy sepulchre '
'urged them to advance; and reason perhaps was on the side of resolution, '
'since every hour of delay abates the fame and force of the invader, and '
'multiplies the resources of defensive war. The capital of Syria was '
'protected by the River Orontes; and the iron bridge, In the '
'eventful period of the siege and defence of Antioch, the crusaders were '
'alternately exalted by victory or sunk in despair; either swelled with '
'plenty or emaciated with hunger. A speculative reasoner might suppose, that '
'their faith had a strong and serious influence on their practice; and that '
'the soldiers of the cross, the deliverers of the holy sepulchre, prepared '
'themselves by a sober and virtuous life for the daily contemplation of '
'martyrdom. Experience blows away this charitable illusion; and seldom does '
'the history of profane war display such scenes of intemperance and '
'prostitution as were exhibited under the walls of Antioch. The grove of '
'Daphne no longer flourished; but the Syrian air was still impregnated with '
'the same vices; the Christians were seduced by every temptation '
'For their salvation and victory, they were indebted to the same fanaticism '
'which had led them to the brink of ruin. In such a cause, and in such an '
'army, visions, prophecies, and miracles, were frequent and familiar. In the '
'distress of Antioch, they were repeated with unusual energy and success: St. '
'Ambrose had assured a pious ecclesiastic, that two years of trial must '
'precede the season of deliverance and grace; the deserters were stopped by '
'the presence and reproaches of Christ himself; the dead had promised to '
'arise and combat with their brethren; the Virgin had obtained the pardon of '
'their sins; and their confidence was revived by a visible sign, the '
'seasonable and splendid discovery of the Holy Lance. The policy of their '
'chiefs has on this occasion been admired, and might surely be excused; but a '
'pious fraud is seldom produced by the cool conspiracy of many persons; and a '
'voluntary impostor might depend on the support of the wise and the credulity '
'of the people. Of the diocese of Marseilles, there was a priest of low '
'cunning and loose manners, and his name was Peter Bartholemy. He presented '
'himself at the door of the council-chamber, to disclose an apparition of St. '
'Andrew, which had been thrice reiterated in his sleep with a dreadful '
'menace, if he presumed to suppress the commands of Heaven. “At Antioch,” '
'said the apostle, “in the church of my brother St. Peter, near the high '
'altar, is concealed the steel head of the lance that pierced the side of our '
'Redeemer. In three days that instrument of eternal, and now of temporal, '
'salvation, will be manifested to his disciples. Search, and ye shall find: '
'bear it aloft in battle; and that mystic weapon shall penetrate the souls of '
'the miscreants.” The pope’s legate, the bishop of Puy, affected to listen '
'with coldness and distrust; but the revelation was eagerly accepted by Count '
'Raymond, whom his faithful subject, in the name of the apostle, had chosen '
'for the guardian of the holy lance. The experiment was resolved; and on the '
'third day after a due preparation of prayer and fasting, the priest of '
'Marseilles introduced twelve trusty spectators, among whom were the count '
'and his chaplain; and the church doors were barred against the impetuous '
'multitude. The ground was opened in the appointed place; but the workmen, '
'who relieved each other, dug to the depth of twelve feet without discovering '
'the object of their search. In the evening, when Count Raymond had withdrawn '
'to his post, and the weary assistants began to murmur, Bartholemy, in his '
'shirt, and without his shoes, boldly descended into the pit; the darkness of '
'the hour and of the place enabled him to secrete and deposit the head of a '
'Saracen lance; and the first sound, the first gleam, of the steel was '
'saluted with a devout rapture. The holy lance was drawn from its recess, '
'wrapped in a veil of silk and gold, and exposed to the veneration of the '
'crusaders; their anxious suspense burst forth in a general shout of joy and '
'hope, and the desponding troops were again inflamed with the enthusiasm of '
'valor. Whatever had been the arts, and whatever might be the sentiments of '
'the chiefs, they skilfully improved this fortunate revolution by every aid '
'that discipline and devotion could afford. The soldiers were dismissed to '
'their quarters with an injunction to fortify their minds and bodies for the '
'approaching conflict, freely to bestow their last pittance on themselves and '
'their horses, and to expect with the dawn of day the signal of victory. On '
'the festival of St. Peter and St. Paul, the gates of Antioch were thrown '
'open: a martial psalm, “Let the Lord arise, and let his enemies be '
'scattered!” was chanted by a procession of priests and monks; the battle '
'array was marshalled in twelve divisions, in honor of the twelve apostles; '
'and the holy lance, in the absence of Raymond, was intrusted to the hands of '
'his chaplain. The influence of his relic or trophy, was felt by the '
'servants, and perhaps by the enemies, of Christ; The prudence or '
'fortune of the Franks had delayed their invasion till the decline of the '
'Turkish empire. Yet this attack, when they were within the view and '
'reach of their glorious prize, was suspended above ten months after the '
'defeat of Kerboga. The zeal and courage of the crusaders were chilled in the '
'moment of victory; and instead of marching to improve the consternation, '
'they hastily dispersed to enjoy the luxury, of Syria. The causes of this '
'strange delay may be found in the want of strength and subordination. In the '
'painful and various service of Antioch, the cavalry was annihilated; many '
'thousands of every rank had been lost by famine, sickness, and desertion: '
'the same abuse of plenty had been productive of a third famine; and the '
'alternative of intemperance and distress had generated a pestilence, which '
'swept away above fifty thousand of the pilgrims. Few were able to command, '
'and none were willing to obey; the domestic feuds, which had been stifled by '
'common fear, were again renewed in acts, or at least in sentiments, of '
'hostility; the fortune of Baldwin and Bohemond excited the envy of their '
'companions; the bravest knights were enlisted for the defence of their new '
'principalities; and Count Raymond exhausted his troops and treasures in an '
'idle expedition into the heart of Syria. ')
----------------------------------------
Result 8
The First Crusade.—Part V.
('Jerusalem has derived some reputation from the number and importance of her '
'memorable sieges. It was not till after a long and obstinate contest that '
'Babylon and Rome could prevail against the obstinacy of the people, the '
'craggy ground that might supersede the necessity of fortifications, and the '
'walls and towers that would have fortified the most accessible '
'plain. Eight days after this memorable event, which Pope '
'Urban did not live to hear, the Latin chiefs proceeded to the election of a '
'king, to guard and govern their conquests in Palestine. Hugh the Great, and '
'Stephen of Chartres, had retired with some loss of reputation, which they '
'strove to regain by a second crusade and an honorable death. Baldwin was '
'established at Edessa, and Bohemond at Antioch; and two Roberts, the duke of '
'Normandy Without this indulgence, the conqueror would have '
'almost been stripped of his infant kingdom, which consisted only of '
'Jerusalem and Jaffa, with about twenty villages and towns of the adjacent '
'country. The spirit of freedom, which pervades '
'the feudal institutions, was felt in its strongest energy by the volunteers '
'of the cross, who elected for their chief the most deserving of his peers. '
'Amidst the slaves of Asia, unconscious of the lesson or example, a model of '
'political liberty was introduced; and the laws of the French kingdom are '
'derived from the purest source of equality and justice. Of such laws, the '
'first and indispensable condition is the assent of those whose obedience '
'they require, and for whose benefit they are designed. No sooner had Godfrey '
'of Bouillon accepted the office of supreme magistrate, than he solicited the '
'public and private advice of the Latin pilgrims, who were the best skilled '
'in the statutes and customs of Europe. From these materials, with the '
'counsel and approbation of the patriarch and barons, of the clergy and '
'laity, Godfrey composed the Assise of Jerusalem, The justice and '
'freedom of the constitution were maintained by two tribunals of unequal '
'dignity, which were instituted by Godfrey of Bouillon after the conquest of '
'Jerusalem. The king, in person, presided in the upper court, the court of '
'the barons. Of these the four most conspicuous were the prince of Galilee, '
'the lord of Sidon and Caesarea, and the counts of Jaffa and Tripoli, who, '
'perhaps with the constable and marshal, The trial by battle was '
'established in all criminal cases which affected the life, or limb, or '
'honor, of any person; and in all civil transactions, of or above the value '
'of one mark of silver. It appears that in criminal cases the combat was the '
'privilege of the accuser, who, except in a charge of treason, avenged his '
'personal injury, or the death of those persons whom he had a right to '
'represent; but wherever, from the nature of the charge, testimony could be '
'obtained, it was necessary for him to produce witnesses of the fact. In '
'civil cases, the combat was not allowed as the means of establishing the '
'claim of the demandant; but he was obliged to produce witnesses who had, or '
'assumed to have, knowledge of the fact. The combat was then the privilege of '
'the defendant; because he charged the witness with an attempt by perjury to '
'take away his right. He came therefore to be in the same situation as the '
'appellant in criminal cases. It was not then as a mode of proof that the '
'combat was received, nor as making negative evidence, (according to the '
'supposition of Montesquieu; Among the causes which enfranchised the '
'plebeians from the yoke of feudal tyranny, the institution of cities and '
'corporations is one of the most powerful; and if those of Palestine are '
'coeval with the first crusade, they may be ranked with the most ancient of '
'the Latin world. Many of the pilgrims had escaped from their lords under the '
'banner of the cross; and it was the policy of the French princes to tempt '
'their stay by the assurance of the rights and privileges of freemen. It is '
'expressly declared in the Assise of Jerusalem, that after instituting, for '
'his knights and barons, the court of peers, in which he presided himself, '
'Godfrey of Bouillon established a second tribunal, in which his person was '
'represented by his viscount. The jurisdiction of this inferior court '
'extended over the burgesses of the kingdom; and it was composed of a select '
'number of the most discreet and worthy citizens, who were sworn to judge, '
'according to the laws of the actions and fortunes of their equals. '
'VOLUME SIX')
----------------------------------------
Result 9
Partition Of The Empire By The French And Venetians.—Part I.
('Partition Of The Empire By The French And Venetians,—Five Latin '
'Emperors Of The Houses Of Flanders And Courtenay.— Their Wars Against '
'The Bulgarians And Greeks.—Weakness And Poverty Of The Latin '
'Empire.—Recovery Of Constantinople By The Greeks.—General Consequences '
'Of The Crusades. After the death of the lawful princes, the French and '
'Venetians, confident of justice and victory, agreed to divide and regulate '
'their future possessions. In the division of the Greek '
'provinces, Two fugitives, who had reigned at '
'Constantinople, still asserted the title of emperor; and the subjects of '
'their fallen throne might be moved to pity by the misfortunes of the elder '
'Alexius, or excited to revenge by the spirit of Mourzoufle. A domestic '
'alliance, a common interest, a similar guilt, and the merit of extinguishing '
'his enemies, a brother and a nephew, induced the more recent usurper to '
'unite with the former the relics of his power. Mourzoufle was received with '
'smiles and honors in the camp of his father Alexius; but the wicked can '
'never love, and should rarely trust, their fellow-criminals; he was seized '
'in the bath, deprived of his eyes, stripped of his troops and treasures, and '
'turned out to wander an object of horror and contempt to those who with more '
'propriety could hate, and with more justice could punish, the assassin of '
'the emperor Isaac and his son. As the tyrant, pursued by fear or remorse, '
'was stealing over to Asia, he was seized by the Latins of Constantinople, '
'and condemned, after an open trial, to an ignominious death. His judges '
'debated the mode of his execution, the axe, the wheel, or the stake; and it '
'was resolved that Mourzoufle The Latin conquerors had '
'been saluted with a solemn and early embassy from John, or Joannice, or '
'Calo-John, the revolted chief of the Bulgarians and Walachians. He deemed '
'himself their brother, as the votary of the Roman pontiff, from whom he had '
'received the regal title and a holy banner; and in the subversion of the '
'Greek monarchy, he might aspire to the name of their friend and accomplice. '
'But Calo-John was astonished to find, that the Count of Flanders had assumed '
'the pomp and pride of the successors of Constantine; and his ambassadors '
'were dismissed with a haughty message, that the rebel must deserve a pardon, '
'by touching with his forehead the footstool of the Imperial throne. His '
'resentment Alarmed by this sudden and growing danger, the emperor '
'despatched a swift messenger to recall Count Henry and his troops; and had '
'Baldwin expected the return of his gallant brother, with a supply of twenty '
'thousand Armenians, he might have encountered the invader with equal numbers '
'and a decisive superiority of arms and discipline. But the spirit of '
'chivalry could seldom discriminate caution from cowardice; and the emperor '
'took the field with a hundred and forty knights, and their train of archers '
'and sergeants. The marshal, who dissuaded and obeyed, led the vanguard in '
'their march to Adrianople; the main body was commanded by the count of '
'Blois; the aged doge of Venice followed with the rear; and their scanty '
'numbers were increased from all sides by the fugitive Latins. They undertook '
'to besiege the rebels of Adrianople; and such was the pious tendency of the '
'crusades that they employed the holy week in pillaging the country for their '
'subsistence, and in framing engines for the destruction of their '
'fellow-Christians. But the Latins were soon interrupted and alarmed by the '
'light cavalry of the Comans, who boldly skirmished to the edge of their '
'imperfect lines: and a proclamation was issued by the marshal of Romania, '
'that, on the trumpet’s sound, the cavalry should mount and form; but that '
'none, under pain of death, should abandon themselves to a desultory and '
'dangerous pursuit. This wise injunction was first disobeyed by the count of '
'Blois, who involved the emperor in his rashness and ruin. The Comans, of the '
'Parthian or Tartar school, fled before their first charge; but after a '
'career of two leagues, when the knights and their horses were almost '
'breathless, they suddenly turned, rallied, and encompassed the heavy '
'squadrons of the Franks. The count was slain on the field; the emperor was '
'made prisoner; and if the one disdained to fly, if the other refused to '
'yield, their personal bravery made a poor atonement for their ignorance, or '
'neglect, of the duties of a general. ')
----------------------------------------
Result 10
The First Crusade.—Part III.
('Between the age of Charlemagne and that of the crusades, a revolution had '
'taken place among the Spaniards, the Normans, and the French, which was '
'gradually extended to the rest of Europe. The service of the infantry was '
'degraded to the plebeians; the cavalry formed the strength of the armies, '
'and the honorable name of miles, or soldier, was confined to the '
'gentlemen Such were the troops, and such the leaders, who assumed '
'the cross for the deliverance of the holy sepulchre. As soon as they were '
'relieved by the absence of the plebeian multitude, they encouraged each '
'other, by interviews and messages, to accomplish their vow, and hasten their '
'departure. Their wives and sisters were desirous of partaking the danger and '
'merit of the pilgrimage: their portable treasures were conveyed in bars of '
'silver and gold; and the princes and barons were attended by their equipage '
'of hounds and hawks to amuse their leisure and to supply their table. The '
'difficulty of procuring subsistence for so many myriads of men and horses '
'engaged them to separate their forces: their choice or situation determined '
'the road; and it was agreed to meet in the neighborhood of Constantinople, '
'and from thence to begin their operations against the Turks. From the banks '
'of the Meuse and the Moselle, Godfrey of Bouillon followed the direct way of '
'Germany, Hungary, and Bulgaria; and, as long as he exercised the sole '
'command every step afforded some proof of his prudence and virtue. On the '
'confines of Hungary he was stopped three weeks by a Christian people, to '
'whom the name, or at least the abuse, of the cross was justly odious. The '
'Hungarians still smarted with the wounds which they had received from the '
'first pilgrims: in their turn they had abused the right of defence and '
'retaliation; and they had reason to apprehend a severe revenge from a hero '
'of the same nation, and who was engaged in the same cause. But, after '
'weighing the motives and the events, the virtuous duke was content to pity '
'the crimes and misfortunes of his worthless brethren; and his twelve '
'deputies, the messengers of peace, requested in his name a free passage and '
'an equal market. To remove their suspicions, Godfrey trusted himself, and '
'afterwards his brother, to the faith of Carloman, In some '
'oriental tale I have read the fable of a shepherd, who was ruined by the '
'accomplishment of his own wishes: he had prayed for water; the Ganges was '
'turned into his grounds, and his flock and cottage were swept away by the '
'inundation. Such was the fortune, or at least the apprehension of the Greek '
'emperor Alexius Comnenus, whose name has already appeared in this history, '
'and whose conduct is so differently represented by his daughter '
'Anne, The same arms which threatened Europe might deliver Asia, and '
'repel the Turks from the neighboring shores of the Bosphorus and Hellespont. '
'The fair provinces from Nice to Antioch were the recent patrimony of the '
'Roman emperor; and his ancient and perpetual claim still embraced the '
'kingdoms of Syria and Egypt. In his enthusiasm, Alexius indulged, or '
'affected, the ambitious hope of leading his new allies to subvert the '
'thrones of the East; but the calmer dictates of reason and temper dissuaded '
'him from exposing his royal person to the faith of unknown and lawless '
'Barbarians. His prudence, or his pride, was content with extorting from the '
'French princes an oath of homage and fidelity, and a solemn promise, that '
'they would either restore, or hold, their Asiatic conquests as the humble '
'and loyal vassals of the Roman empire. Their independent spirit was fired at '
'the mention of this foreign and voluntary servitude: they successively '
'yielded to the dexterous application of gifts and flattery; and the first '
'proselytes became the most eloquent and effectual missionaries to multiply '
'the companions of their shame. The pride of Hugh of Vermandois was soothed '
'by the honors of his captivity; and in the brother of the French king, the '
'example of submission was prevalent and weighty. In the mind of Godfrey of '
'Bouillon every human consideration was subordinate to the glory of God and '
'the success of the crusade. He had firmly resisted the temptations of '
'Bohemond and Raymond, who urged the attack and conquest of Constantinople. '
'Alexius esteemed his virtues, deservedly named him the champion of the '
'empire, and dignified his homage with the filial name and the rights of '
'adoption. Private or public interest suppressed the murmurs of the '
'dukes and counts; but a French baron (he is supposed to be Robert of '
'Paris The conquest of Asia was undertaken and achieved by Alexander, '
'with thirty-five thousand Macedonians and Greeks; ')
----------------------------------------
Yay! Our search engine worked! But there’s more than we can do. To start, we’re only seeing the first 10 results. This is by default, as this results
list is paginated meaning that in the searcher method we could specify what “page” of ten results we want to see at a particular time. This will be useful a bit later, but for now we can set the keyword argument limit
to None
.
q = qp.parse(u"The Crusades")
with ix.searcher() as s:
results = s.search(q, limit=None)
print(len(results))
25
# logical operators
q = qp.parse(u"The Crusades AND Bohemond")
with ix.searcher() as s:
results = s.search(q, limit=None)
print(q, len(results))
q = qp.parse(u"The Crusades OR Bohemond")
with ix.searcher() as s:
results = s.search(q, limit=None)
print(q, len(results))
q = qp.parse(u"The Crusades NOT Bohemond")
with ix.searcher() as s:
results = s.search(q, limit=None)
print(q, len(results))
(text:crusad AND text:bohemond) 3
(text:crusad OR text:bohemond) 25
(text:crusad AND NOT text:bohemond) 22
# can also filter by chapter
from whoosh import query
q = qp.parse(u"The Crusades")
with ix.searcher() as s:
allow_q = query.Term("title", "The Crusades.—Part I.") # query.Term takes a schema field (title) and something from that field
results = s.search(q, filter=allow_q, limit=None)
for hit in results: # only return results from that chapter
print(hit['title'])
pprint(hit['text'])
print('--'*20)
The Crusades.—Part I.
('Preservation Of The Greek Empire.—Numbers, Passage, And Event, Of The '
'Second And Third Crusades.—St. Bernard.— Reign Of Saladin In Egypt And '
'Syria.—His Conquest Of Jerusalem.—Naval Crusades.—Richard The First Of '
'England.— Pope Innocent The Third; And The Fourth And Fifth Crusades.— '
'The Emperor Frederic The Second.—Louis The Ninth Of France; And The Two '
'Last Crusades.—Expulsion Of The Latins Or Franks By The Mamelukes. In '
'a style less grave than that of history, I should perhaps compare the '
'emperor Alexius In the twelfth century, three great '
'emigrations marched by land from the West for the relief of Palestine. The '
'soldiers and pilgrims of Lombardy, France, and Germany were excited by the '
'example and success of the first crusade. I. Of the swarms that so '
'closely trod in the footsteps of the first pilgrims, the chiefs were equal '
'in rank, though unequal in fame and merit, to Godfrey of Bouillon and his '
'fellow-adventurers. At their head were displayed the banners of the dukes of '
'Burgundy, Bavaria, and Aquitain; the first a descendant of Hugh Capet, the '
'second, a father of the Brunswick line: the archbishop of Milan, a temporal '
'prince, transported, for the benefit of the Turks, the treasures and '
'ornaments of his church and palace; and the veteran crusaders, Hugh the '
'Great and Stephen of Chartres, returned to consummate their unfinished vow. '
'The huge and disorderly bodies of their followers moved forward in two '
'columns; and if the first consisted of two hundred and sixty thousand '
'persons, the second might possibly amount to sixty thousand horse and one '
'hundred thousand foot. II. The number and character of the '
'strangers was an object of terror to the effeminate Greeks, and the '
'sentiment of fear is nearly allied to that of hatred. This aversion was '
'suspended or softened by the apprehension of the Turkish power; and the '
'invectives of the Latins will not bias our more candid belief, that the '
'emperor Alexius dissembled their insolence, eluded their hostilities, '
'counselled their rashness, and opened to their ardor the road of pilgrimage '
'and conquest. But when the Turks had been driven from Nice and the '
'sea-coast, when the Byzantine princes no longer dreaded the distant sultans '
'of Cogni, they felt with purer indignation the free and frequent passage of '
'the western Barbarians, who violated the majesty, and endangered the safety, '
'of the empire. The second and third crusades were undertaken under the reign '
'of Manuel Comnenus and Isaac Angelus. Of the former, the passions were '
'always impetuous, and often malevolent; and the natural union of a cowardly '
'and a mischievous temper was exemplified in the latter, who, without merit '
'or mercy, could punish a tyrant, and occupy his throne. It was secretly, and '
'perhaps tacitly, resolved by the prince and people to destroy, or at least '
'to discourage, the pilgrims, by every species of injury and oppression; and '
'their want of prudence and discipline continually afforded the pretence or '
'the opportunity. The Western monarchs had stipulated a safe passage and fair '
'market in the country of their Christian brethren; the treaty had been '
'ratified by oaths and hostages; and the poorest soldier of Frederic’s army '
'was furnished with three marks of silver to defray his expenses on the road. '
'But every engagement was violated by treachery and injustice; and the '
'complaints of the Latins are attested by the honest confession of a Greek '
'historian, who has dared to prefer truth to his country. III. The '
'swarms that followed the first crusade were destroyed in Anatolia by famine, '
'pestilence, and the Turkish arrows; and the princes only escaped with some '
'squadrons of horse to accomplish their lamentable pilgrimage. A just opinion '
'may be formed of their knowledge and humanity; of their knowledge, from the '
'design of subduing Persia and Chorasan in their way to '
'Jerusalem; The enthusiasm of the first crusade is a '
'natural and simple event, while hope was fresh, danger untried, and '
'enterprise congenial to the spirit of the times. But the obstinate '
'perseverance of Europe may indeed excite our pity and admiration; that no '
'instruction should have been drawn from constant and adverse experience; '
'that the same confidence should have repeatedly grown from the same '
'failures; that six succeeding generations should have rushed headlong down '
'the precipice that was open before them; and that men of every condition '
'should have staked their public and private fortunes on the desperate '
'adventure of possessing or recovering a tombstone two thousand miles from '
'their country. In a period of two centuries after the council of Clermont, '
'each spring and summer produced a new emigration of pilgrim warriors for the '
'defence of the Holy Land; but the seven great armaments or crusades were '
'excited by some impending or recent calamity: the nations were moved by the '
'authority of their pontiffs, and the example of their kings: their zeal was '
'kindled, and their reason was silenced, by the voice of their holy orators; '
'and among these, Bernard, Omnipotence itself cannot '
'escape the murmurs of its discordant votaries; since the same dispensation '
'which was applauded as a deliverance in Europe, was deplored, and perhaps '
'arraigned, as a calamity in Asia. After the loss of Jerusalem, the Syrian '
'fugitives diffused their consternation and sorrow; Bagdad mourned in the '
'dust; the cadhi Zeineddin of Damascus tore his beard in the caliph’s '
'presence; and the whole divan shed tears at his melancholy tale. ')
----------------------------------------
from IPython.display import display, HTML
# can also highlight where a keyword appears
q = qp.parse(u"The Crusades")
with ix.searcher() as s:
results = s.search(q, limit=None)
results.fragmenter.maxchars = 1000 # increasing context of the highlight
results.fragmenter.surround = 250
for i, hit in enumerate(results):
print(f"Result {i+1}")
print(hit['title'])
display(HTML(hit.highlights("text"))) # highlights are given bold html (<b></b>) tags, using IPython to display this
print('--'*20)
Result 1
The Crusades.—Part I.
----------------------------------------
Result 2
The Crusades.—Part III.
----------------------------------------
Result 3
The First Crusade.—Part II.
----------------------------------------
Result 4
Schism Of The Greeks And Latins.—Part I.
----------------------------------------
Result 5
Partition Of The Empire By The French And Venetians.—Part III.
----------------------------------------
Result 6
The First Crusade.—Part I.
----------------------------------------
Result 7
The First Crusade.—Part IV.
----------------------------------------
Result 8
The First Crusade.—Part V.
----------------------------------------
Result 9
Partition Of The Empire By The French And Venetians.—Part I.
----------------------------------------
Result 10
The First Crusade.—Part III.
----------------------------------------
Result 11
The Fourth Crusade.—Part I.
----------------------------------------
Result 12
Greek Emperors Of Nice And Constantinople.—Part II.
----------------------------------------
Result 13
Moguls, Ottoman Turks.—Part IV.
----------------------------------------
Result 14
Union Of The Greek And Latin Churches.—Part II.
----------------------------------------
Result 15
Fate Of The Eastern Empire.—Part III.
----------------------------------------
Result 16
Prospect Of The Ruins Of Rome In The Fifteenth Century.—Part II
----------------------------------------
Result 17
Schism Of The Greeks And Latins.—Part II.
----------------------------------------
Result 18
Partition Of The Empire By The French And Venetians.—Part II.
----------------------------------------
Result 19
The Turks.—Part I.
----------------------------------------
Result 20
Union Of The Greek And Latin Churches.—Part I.
----------------------------------------
Result 21
Reign Of Mahomet The Second, Extinction Of Eastern Empire.—Part IV.
----------------------------------------
Result 22
The Fourth Crusade.—Part II.
----------------------------------------
Result 23
State Of Rome From The Twelfth Century.—Part I.
----------------------------------------
Result 24
Succession And Characters Of The Greek Emperors.—Part I.
----------------------------------------
Result 25
Succession And Characters Of The Greek Emperors.—Part IV.
----------------------------------------
Creating a search interface#
Searching our data is great, but we can go one step further and put a simple graphical interface in front of the search engine. I’ll use a Python-based web app framework called streamlit
. This notebook won’t go into depth about how this app is created, but if you are interested, please check out our Introduction to Streamlit
workshop.
#@title Load all of the code
#@markdown Run this cell to get all of the code needed for the application. You need to run this cell only once.
%%writefile app.py
from whoosh.index import open_dir
from whoosh import query
from whoosh.qparser import QueryParser
from IPython.display import display, HTML, clear_output
import re
import streamlit as st
@st.cache_data
def get_index():
return open_dir("daf_index")
ix = get_index()
st.title("Gibbon's *Decline and Fall of the Roman Empire* Simple Search")
with st.expander("Searching tips"):
st.write("""
* If you'd like to search for just a single term, you can enter it in the box below.
* If you'd like to search for a phrase, you can enclose it in quotations, such as "serious complications".
* A query like "serious complications"~5 would return results where "serious" and "complications" are at most 5 words away from each other.
* AND can be used as a boolean operator and will return results where two terms are both in a passage. AND is automatically placed in a query of two words, so 'latent syphilis' is internally represented as latent AND syphilis.
* OR can be used as a boolean operator and will return results where either one of two terms are in a passage.
* NOT can be used as a boolean operator and will return results which do not include the term following the NOT.
* From these boolean operators, one can construct complex queries like: syphilis AND hospitals NOT "serious complications". This query would return results that have both syphilis and hospitals in them, but do not have "serious complications".
* Parentheses can be used to group boolean statements. For example, the query syphilis AND ("serious complications" OR hospitals) would return results that have syphilis and either serious complications or hispitals in them.
* If you'd like to search in a specific date range, you can specify it with the date: field. For example, year:[19500101 TO 19600101] syphilis would return results between January 1st, 1950 and January 1st, 1960 that have syphilis in them.
""")
if 'page_count' not in st.session_state:
st.session_state['page_count'] = 0
if 'to_see' not in st.session_state:
st.session_state['to_see'] = 10
if 'pages' not in st.session_state:
st.session_state['pages'] = []
def clear_session_state():
st.session_state['page_count'] = 0
st.session_state['to_see'] = 10
st.session_state['pages'] = []
query_str = st.text_input("Search", key="search", on_change=clear_session_state)
stemmer = st.toggle('Use stemming', help='If selected, the search will use stemming to find words with the same root. For example, "running" will match "run" and "ran".', on_change=clear_session_state)
if stemmer:
parser = QueryParser("text", ix.schema, termclass=query.Variations)
else:
parser = QueryParser("text", ix.schema)
query = parser.parse(query_str)
html_template = """
<p>{hit}</p>
<hr/>
""".strip()
class Page:
def __init__(self, results, pageno, items_per_page):
self.results = results
self.pageno = pageno
self.items_per_page = items_per_page
def __len__(self):
return len(self.results)
def __call__(self):
for i, hit in enumerate(self.results):
st.write(f"<small>Document {i+1} of {len(self.results)}</small>", unsafe_allow_html=True)
title = hit['title']
st.write(f"<h4>{title}</h4>", unsafe_allow_html=True)
r = re.split('\w\.\.\.\w', hit.highlights("text").replace("\n\n", ""))
for h in r:
st.write(html_template.format(hit=h), unsafe_allow_html=True)
if query_str:
st.session_state['pages'] = []
with ix.searcher() as searcher:
with st.spinner("Searching..."):
res = searcher.search(query, limit=None)
res.fragmenter.maxchars = 1000
res.fragmenter.surround = 250
pages = (len(res) // st.session_state['to_see']) + 1
for i in range(1, pages):
page = res[i*st.session_state['to_see']-st.session_state['to_see']:i*st.session_state['to_see']]
p = Page(page, i, st.session_state['to_see'])
st.session_state['pages'].append(p)
with st.sidebar:
st.markdown("# Page Navigation")
if st.button('See next page', key='next'):
st.session_state['page_count'] += 1
if st.button('See previous page', key='prev'):
st.session_state['page_count'] -= 1
page_swap = st.number_input('What page do you want to visit?', min_value=1, max_value=len(st.session_state['pages']), value=1)
if st.button('Go to page'):
st.session_state['page_count'] = page_swap-1
st.write(f"Page {st.session_state['page_count']+1} of {pages-1}")
if st.session_state['page_count'] < len(st.session_state['pages']):
selected_page = st.session_state['pages'][st.session_state['page_count']]
selected_page()
elif st.session_state['page_count'] < 1:
st.session_state['page_count'] = 0
else:
st.write("No more pages!")
UsageError: Line magic function `%%writefile` not found.
#@title Start the application
#@markdown Run this cell and then wait for the URL to printed below.
#@markdown
#@markdown Click on it and use the password/Endpoint IP for the password.
!npm install localtunnel
!streamlit run /content/app.py &>/content/logs.txt &
print('\n'*3)
import urllib
print("Password/Endpoint IP for localtunnel is:",urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip("\n"))
print("Copy and paste this in the box in the link below.")
print('\n'*3)
print("Click on the link below.")
!npx localtunnel --port 8501
?25h
added 22 packages, and audited 23 packages in 3s
3 packages are looking for funding
run `npm fund` for details
2 moderate severity vulnerabilities
To address all issues, run:
npm audit fix
Run `npm audit` for details.
Password/Endpoint IP for localtunnel is: 34.148.103.234
Copy and paste this in the box in the link below.
Click on the link below.
your url is: https://chubby-paws-fail.loca.lt