Package: perfectextractor
PefectExtractorExtracting Perfects (and related forms) from parallel corporaThis command-line application allows for extraction of Perfects (and related forms, like the Recent Past construction in French and Spanish) from part-of-speech-tagged, lemmatized and sentence-aligned parallel corpora encoded in XML.Recognizing PerfectsIn English, apresent perfectis easily recognizable as a present form ofto haveplus a past participle, like in (1):(1) I have seen that movie twenty times.However, one difficulty in finding Perfects in most languages is that there might be words between the auxiliary and the past participle, like in (2):(2) Nobody has ever climbed that mountain.Furthermore, languages have passive forms that generally require the past participle ofto beto be interjected, like in (3):(3) The bill has been paid by John.In English, there is the additional issue of thepresent perfect continuous, which in form shares the first part of the construction with thepresent perfect, like in (4):(4) He has been waiting here for two hours.In some languages (e.g. French, German, and Dutch), the Perfect can be formed with both Have and Be.
The past participle governs which auxiliary verb is used, as (5) and (6) show.(5) J'ai vu quelque chose [lit. I have seen some thing]
(6) Elle est arrivé [lit. She is arrived]For French, this is a closed list
(DR and MRS P. VANDERTRAMP),
but for other languages, this might be a more open class.The last common issue with finding Perfects is that in e.g. Dutch and German, the Perfect might appear before the auxiliary verb in subordinate clauses. (7) is an example:(7) Dat is de stad waar hij gewoond heeft. [lit. This is the city where he lived has]The extraction script provided here takes care of all these issues, and can have language-specific settings.ImplementationThe extraction script (apps/extractor/perfectextractor.py) is implemented using thelxml XML toolkit.The script looks for auxiliary verbs (using aXPath expression), and for each of these,
it tries to find a past participle on the right hand side of the sentence (or left hand side in Dutch/German), allowing for words between the verbs,
though this lookup stops at the occurrence of other verbs, punctuation and coordinating conjunctions.The script also allows for extraction ofpresent perfect continuousforms.The script handles these by a list of verbs that use Be as auxiliary.
The functionget_ergative_verbsinextractor/wiktionary.pyextracts these verbs fromWiktionaryfor Dutch.
This function uses theRequests: HTTP for Humanspackage.
For German, the list is compiled fromthis list.Recognizing Recent PastsMost Romance languages share a grammaticalized construction to refer to events in the recent past, e.g. thepassé récentin French and thepasado recientein Spanish.
In English, typically apresent perfectalongside the adverbjustis used to convey this meaning, commonly referred to asperfect of recent past(Comrie 1985) orhot news perfect(McCawley 1971).The Frenchpassé récentis formed with a present tense ofvenir'come' followed by the particledeand an infinitive, as in (8) below.(8) Je viens de voir Marie. [lit. I come DE see Mary]The Spanishpasado recienteis (quite similarly) formed with a present tense ofacabar'finish' followed by the particledeand an infinitive, as in (9) below.(9) Acabo de ver a María. [lit. I finish DE see Mary]The extraction script (apps/extractor/recentpastextractor.py) provided here allows export of these constructions from parallel corpora.Other extractorsThis application also allows extraction from parallel corpora based on part-of-speech tags or regexes.CorporaDutch Parallel CorpusThe extraction was first tested with theDutch Parallel Corpus.
This corpus (that uses theTEI format) consists of three languages: Dutch, French and English.
The configuration for this corpus can be found incorpora/dpc/base.cfgandcorpora/dpc/perfect.cfg.
Example documents from this corpus are included in thetests/data/dpcdirectory.
The data for this corpus isclosed source, to retrieve the corpus, you'll have to contact the authors on the cited website.
After you've obtained the data, you can run the extraction script with:python extract.py <folder> en fr nl --corpus=dpc --extractor=perfectOPUS CorporaThe extraction has also been implemented for the open parallel corpusOPUS, that contains most notably theEuroparl Corpusand theOpenSubtitles Corpus.
This corpus (that uses theXCES formatfor alignment) consists of a wide variety of languages.
The configuration for this corpus can be found incorpora/opus/base.cfgandcorpora/opus/perfect.cfg: implementations have been made for Dutch, English, French, German and Spanish.
Example documents from this corpus are included in thetests/data/europarldirectory.
The data for this corpus isopen source: you can download the corpus and the alignment files from the cited website.
After you've obtained the data, you can run the extraction script with:python extract.py <folder> en de es --corpus=opus --extractor=perfectBNC CorpusThe extraction has also been implemented for the monolingual BNC Corpus.
The data for this corpus isopen source: you can download the corpus from the cited website.
After you've obtained the data, you can run the extraction script with:python extract.py <folder> en --corpus=bnc --extractor=perfectImplementing your own corpusIf you want to implement the extraction for another corpus, you'll have to create:An implementation of the corpus in thecorporadirectory (seecorpora/opusfor an example).A configuration file in this directory (seecorpora/opus/base.cfgfor an example).An entry in the main script (seeextract.py)Other options to the extraction scriptYou can view all options of the extraction script by typing:python extract.py --helpDo note that at this point in time, not all options are available in all corpora.
Feel free to send a pull request once you have implemented an option, or to request one by creating an issue.Other scriptsThese scripts can be found inperfectextractor/scripts.pick_alignmentsThis script allows to filter the alignment file based on (for example) a file prefix.
This is helpful in the case of large alignment files, as is e.g. the case for the Europarl corpus.
Example usage:python pick_alignments.pymerge_resultsThis script allows to merge results from various files.
Example usage:python merge_results.pysplitterThis script allows to split a big corpus into subparts and then to run the extractors.
Example usage:python splitter.pyTestsThe unit tests can be run using:python -m unittest discover -bA coverage report can be generated (after installingcoverage.py) using:coverage run --source . -m unittest discover -b
coverage htmlCitingIf you happen to have used (parts of) this project for your research, please refer to this paper:van der Klis, M., Le Bruyn, B., de Swart, H. (2017). Mapping the Perfect via Translation Mining.Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 2, Short Papers2017, 497-502.