Hello --

I'm struggling to find a solution to what ought to be a fairly straightforward Stata issue, and was hoping the forum could help.

I'm looking for a way to match two string variables in one dataset (similar to what matchit does), but rather than scoring on simple similarity, I want to score on how much of one string (e.g. what proportion of bigrams, the exact algorithm doesn't matter too much) is contained within the other. It doesn't look like matchit has this functionality, and I wanted to see if there were established ways of doing this.

I've left some sample data below if useful. Specifically, I'm looking for a way to generate a score that is 1 if all of pp_info (by whatever string similarity function is used) is contained in scrape_title_short, zero if none of it is, with appropriate gradations in between. The strings are titles of 17th and 18th century sermons from two different sources, one of which only gives a brief summary of the title, while the other gives the (generally long) full text of the title.

Many thanks!

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str222 pp_info str200 scrape_title_short
"Fanatack's Mite cast in the Treasury."                                                        "A fannaticks mite cast into the Kings treasury :being a sermon printed to the King because not preach'd before the King"                               
"A Parrallel between David, Christ and King Charles 1st. in their Humiliation and Exaltation." "A Word for all, or, The Rumps funerall sermon, held forth by Mr. Feak to a conventicle of fanatiques at Bedlam upon the last dissolution of the half q"
"Funeral sermon"                                                                               "A Word for all, or, The Rumps funerall sermon, held forth by Mr. Feak to a conventicle of fanatiques at Bedlam upon the last dissolution of the half q"
"Absalom's unnatural Rebellion."                                                               "A Word for all, or, The Rumps funerall sermon, held forth by Mr. Feak to a conventicle of fanatiques at Bedlam upon the last dissolution of the half q"
"Athaliahs Treason."                                                                           "A Word for all, or, The Rumps funerall sermon, held forth by Mr. Feak to a conventicle of fanatiques at Bedlam upon the last dissolution of the half q"
"House of Mourning, or funeral Discourses"                                                     "A Word for all, or, The Rumps funerall sermon, held forth by Mr. Feak to a conventicle of fanatiques at Bedlam upon the last dissolution of the half q"
"The Sinfulness of Compliance with a Multitude in sinning."                                    "A plaine & profitable catechisme : whereunto is added a sermon preached upon Exod.23.2."                                                               
"Plea for Caesar."                                                                             "Votum pro Caesare, or, A plea for Caesar : discovering briefly the great sinfulness of opposing the authority of the higher powers : delivered in a se"
"May 24."                                                                                      "The Kings return :A sermon preached at Winchcomb in Gloucestershire upon the Kings-day, Thursday, May 24. 1660"                                        
"On proclaiming K. Charles 2."                                                                 "The strong man ejected by a stronger then he :In a sermon preached at Gloucester, the 15th of May, 1660. Being the day his Royal Majesty, King Charles"
"Funeral of Bishop Morton."                                                                    "Hieronikēs, or, The fight, victory, and triumph of S. Paul : accommodated to the Right Reverend Father in God Thomas, late L. Bishop of Duresme, in a"
"Fast."                                                                                        "The life of faith, as it is the evidence of things unseen :a sermon preached (contractedly) before the King at White-Hall upon July the 12th 1660"     
"before King."                                                                                 "The life of faith, as it is the evidence of things unseen :a sermon preached (contractedly) before the King at White-Hall upon July the 12th 1660"     
"Funeral The Mute Christian under the smarting Rod."                                           "A believers last day is his best day : a sermon preached at the funerall of Mris Martha Randoll, at Christs Church, London, June 28, 1651"             
"The best Wisdom."                                                                             "Vlastēma ex hypsous, or, The best vvisdome :propounded to the gentry of Suffolk in a sermon at Ipswich : prepared for the 9th of April, 1660, the"
"May 29. Solomon's blessed Land."                                                              "Solomons blessed land a sermon upon Ecclesiastes X.17. : Preached before an extraordinary assembly at Newark upon Trent, May 29. 1660. Being the birth"
"Thanksgiving before L. St. Paul's Thanksg."                                                   "St. Paul's thanksgiving: : set forth in a sermon preached before the right honorable House of Peers in the Abby-Church Westminster, on Thursday May 10"
"Discourses"                                                                                   "The saints happinesse. : Together with the severall steps leading thereunto, delivered in divers lectures on the Beatitudes; being part of Christs Ser"
"The Christian's Encouragement to believe."                                                    "The Christians encouragement to believe: or a sermon preached on Rom, 10.11. By Thomas Cleland, minister of the gospel at Chivelston in Devon"         
"before Lord Mayor and General Monk. Pattern of Mercy,"                                        "A pattern of mercy. : Opened in a sermon at St. Pauls, before the Right Honorable, the Lord Mayor, and the Lord General Monck: February 12. 1659."     
"Thanksgiving for his Majesty's Return. O."                                                    "Judah's purging in the melting pot :a sermon preached in the cathedral at Sarum before the Reverend Sir Robert Foster, and Sir Thomas Tirrell, Knights"
"Assize."                                                                                      "Judah's purging in the melting pot :a sermon preached in the cathedral at Sarum before the Reverend Sir Robert Foster, and Sir Thomas Tirrell, Knights"
"Funeral sermon"                                                                               "Great Britains resurrection. Or, England's complacencie in her royal soveraign King Charles the Second. : A sermon preached in the lecture at Gloucest"
"Funerals made Cordials."                                                                      "A sermon preached in St. Pauls Church London ... February 28, 1659 : being a day of solemn thanksgiving unto God for restoring of the excluded members"
"Thanksgiving"                                                                                 "A sermon preached in St. Pauls Church London ... February 28, 1659 : being a day of solemn thanksgiving unto God for restoring of the excluded members"
"Fast. before Commons."                                                                        "A sermon preached in St. Pauls Church London ... February 28, 1659 : being a day of solemn thanksgiving unto God for restoring of the excluded members"
"Funeral of Bishop Brownrig."                                                                  "A sermon preached in St. Pauls Church London ... February 28, 1659 : being a day of solemn thanksgiving unto God for restoring of the excluded members"
"Thanksgiving May 24. The Son of Nobles."                                                      "Ben horim = filius heröum = the son of nobles : set forth in a sermon preached at St Mary's in Cambridge before the university, on Thursday the 24th "
"Thanksgiving May 27. Restoration."                                                            "David's returne from his banishment :set forth in a thanks-giving sermon for the returne of His Sacred Majesty Charles the II, and preached at St. Mar"
"Lady-day. The Fear of God and the King."                                                      "The Samaritan revived : and the course he then took to cure the wounded traveller by powring in wine and oyl : historically applyed for the sound and "
"A Changling, no Company for Lovers of Loyalty."                                               "The accomplish'd courtier consisting of institutions and examples, by which courtiers and officers of state may square their transactions prudently, a"
"Lent. before King."                                                                           "A sermon preached before the kings majesty at Whitehall on Friday the 22 of March ... 1660"                                                            
"The Beauty of Magistrates."                                                                   "Men are gods, or, The dignity of magistracy, and the duty of the magistrate :as it was presented in a sermon at the assize holden at Hertford for that"
"Samaria's Downfall."                                                                          "Men are gods, or, The dignity of magistracy, and the duty of the magistrate :as it was presented in a sermon at the assize holden at Hertford for that"
"Fast. before Lords."                                                                          "A divine prospective : representing the just mans peacefull end : in a funerall sermon preached at Katherine Creechurch, Aug. 14, 1649, at the enterme"
"Thanksgiving"                                                                                 "Sions halelujah: : set forth in a sermon preached before the Right Honourable House of Peers, in the abbie church of Westminster, on Thursday June 28."
"Funeral of Mr. Thomas Ball."                                                                  "A funeral sermon thundred forth by John Feak in his private congregation, for the loss of their dearly beloved champion, Maj. Gen. Harison"            
"Christ, God-Man."                                                                             "Real comforts, extracted from moral and spiritual principles :Presented in a sermon, preached at the funeral of that reverend divine Mr. Thomas Ball l"
"Funeral"                                                                                      "The grand statute: or The law of death unalterable; : opened and applied in a sermon preached May 11. 1660. At the funerals of that pious, useful, and"
"5 Sermons"                                                                                    "Five seasonable sermons. As they were preached before eminent auditories, upon several arguments. / By Paul Knell Master in Arts, of Clare-Hall in Cam"
"Funeral sermon"                                                                               "The king of terrors metamorphosis. Or, Death transform'd into sleep. : A sermon preached at the funeral of Mrs. Elizabeth Nicoll, daughter to that wor"
"Hosannah, or Thanksgiving Sermon June 28."                                                    "Hosannah, a thanksgiving-sermon Jvne 28th 1660"                                                                                                        
"Circumspec."                                                                                  "Spiritual vvisdom improved against temptation. : In a sermon preached at Stepney Septemb. 16. 1660. And now made publick to obviate misrepresentation" 
"Thanksgiving"                                                                                 "A plant of paradise, : being a sermon preached at St. Martin's in the Fields at the funeral of John-Goodhand Holt, the young son, onely child, and hop"
"Funeral"                                                                                      "A plant of paradise, : being a sermon preached at St. Martin's in the Fields at the funeral of John-Goodhand Holt, the young son, onely child, and hop"
"Thanksgiving"                                                                                 "Post nubila Phoebus, or, A sermon of thanksgiving for the safe and happy returne of our gracious soveraign .. :preached in the city of Aberden at the "
"Funeral of Mr. Jacomb. Divine Arithmetick."                                                   "Divine arithmetick, or The right art of numbring our dayes :Being a sermon preached June 17. 1659. at the funerals of Mr. Samuel Jacomb, B.D. Minister"
"before Lord Mayor. Evangelical Worship, spiritual Worship."                                   "Evangelical worship is spiritual vvorship : as it was discussed in a sermon preached before the Right Honourable the Lord Maior, at Pauls Church, Aug."
"before Commons."                                                                              "A sermon preached before the Honourable House of Commons at Saint Margarets in Westminster, on Thursday the 10. of May : being a day of solemn thanksg"
"On the Restoration."                                                                          "Gods working and Brittains wonder. : A sermon congratulating the most happy establishment of His sacred Majesty Charls the II. on His throne. Presente"
"entitled the non such Professor in his meridian Splendor."                                    "A wedding-ring fit for the finger: or, The salve of divinity on the sore of humanity : Laid open in a sermon at a wedding in Edmondton, by William Sec"
"before King. Thanksgiving David's Deliverance and Thanksgiving."                              "Davids deliverance and thanksgiving. : A sermon preached before the King at VVhitehall upon June 28. 1660. being the day of solemn thanksgiving for th"
"Funeral sermon"                                                                               "A sermon preached at the funeral oe [sic] the incomparably vertuous and truly pious gentlewoman Mrs. Dorothy Litster."                                 
"Discourses"                                                                                   "The life and death of Mr. William Moore, late fellow of Caius Colledge, and keeper of the University-Library :as it was delivered in a sermon preached"
"Thanksgiving June 21. The righteous Ruler."                                                   "The righteous ruler :a sermon preached at St Maries in Cambridge, June 28, 1660"                                                                       
"A caveat against Seducers."                                                                   "A caveat against seducers: as it was preached by Richard Standfast, Mr. of Arts, and rector of Christ-Church in Bristol, whereunto are annexed the bli"
"3 Seasonable sermons"                                                                         "The beatitudes: or A discourse upon part of Christs famous Sermon on the Mount :Wherunto is added Christs various fulnesse. The preciousnesse of the s"
"Consecration of 5 Bishops The office and dignity Of a Bishop."                                "A sermon preached at the consecration of the Right Reverend Fathers in God, : Gilbert Lord Bishop of London, Humphry Lord Bishop of Sarum, George Lord"
"before the King"                                                                              "Men are gods, or, The dignity of magistracy, and the duty of the magistrate :as it was presented in a sermon at the assize holden at Hertford for that"
"Insolent Usurper and regal Intruder."                                                         "A believers last day is his best day : a sermon preached at the funerall of Mris Martha Randoll, at Christs Church, London, June 28, 1651"             
"Funeral of Earl of Northampton."                                                              "Four sermons, preach'd by the right reverend father in God, John Towers, D.D. L. Bishop of Peterburgh. 1. At the funerall of the right honorable, Will"
"At the Baptism of Earl of Northam."                                                           "Four sermons, preach'd by the right reverend father in God, John Towers, D.D. L. Bishop of Peterburgh. 1. At the funerall of the right honorable, Will"
"before King. At Castle Ashby."                                                                "Four sermons, preach'd by the right reverend father in God, John Towers, D.D. L. Bishop of Peterburgh. 1. At the funerall of the right honorable, Will"
"before King. Lent."                                                                           "Four sermons, preach'd by the right reverend father in God, John Towers, D.D. L. Bishop of Peterburgh. 1. At the funerall of the right honorable, Will"
"May 30. On the Entry into London."                                                            "God save the King: or Pious and loyal joy, the subjects duty, for their soveraign's safety. : Opened in a sermon at Aldermanbury, upon the 30 of May, "
"Thanksgiving"                                                                                 "The bowing the heart of subjects to their sovereign. : A sermon preached on the 24th of May, 1660. Being a day of publick thanksgiving to the Lord for"
"Sermons"                                                                                      "A view of fundamental principles first in general and then in particular. Divided into three parts. The first part, containing a general view of the c"
"Thanksgiving"                                                                                 "God save the King, or A sermon of thanksgiving, for His Majesties happy return to his throne. : Together with a character of his sacred person. Preach"
"Discourses"                                                                                   "The Beatitudes, or, A discourse upon part of Christs famous Sermon on the Mount : wherunto is added ..."                                               
"Concio ad Baccalaureos. De brevitate opportuni Temporis."                                     "The hope of glory, or, Christs in-dwelling in true believers is an evident demonstration of their hope of glory : as it was set forth in a sermon at H"
"3 Decads of Sermons."                                                                         "The hope of glory, or, Christs in-dwelling in true believers is an evident demonstration of their hope of glory : as it was set forth in a sermon at H"
"In defence of the Liturgy."                                                                   "Fides Catholica, or, The doctrine of the Catholick Church in eighteen grand ordinances referring to the Word, sacraments and prayer, in purity, number"
"Funeral of Lady Eliz. Capel."                                                                 "A sermon preached at the funerall of the Right Honourable and most excellent lady the Lady Elizabeth Capell, dowager : together with some brief memori"
"before L. M."                                                                                 "City security stated in a sermon preached at St. Pauls August 11th, 1661 :before the right Honourable the Lord Mayor"                                  
"On regal Power."                                                                              "Clavi trabales, or, Nailes fastned by some great masters of assemblyes :confirming the Kings supremacy, the subjects duty, church government by bishop"
"October 20. Deceivers deceived, or the Mistakes of Wickedness."                               "Deceivers deceiv'd, or, The mistakes of wickedness in sundry erroneous and deceitful principles, practised in our late fatal times, and suspected stil"
"Assize."                                                                                      "Jus poli et fori or, God and the King. : Judging for right against might. As it was delivered in a sermon before the honourable His Majesties judges o"
"Remedies against Satan's Devices."                                                            "A string of pearls, or, The best things reserved till last :discovered in a sermon preached in London, June 8, 1657, at the funeral of ... Mris. Mary "
"147 Sermons"                                                                                  "An expository comment, doctrinal, controversal, and practical upon the whole first chapter to the second epistle of St. Paul to the Corinthians by Ant"
"On Conscience."                                                                               "Conscience it's nature and corruption, with it's repairs and means to inform it aright : in a vindication of the publick prayers and ceremonies of the"
"Funeral"                                                                                      "The taking away of righteous & merciful persons must be taken to heart : applied in a sermon at the funeralls of Mris Anne-Mary Child, wife of Thomas "
"Of the Supremacy."                                                                            "The royal prerogative vindicated in the converted recusant : convinced by Scripture, reasons, fathers, and councils, that the oath of abjuration (comp"
"May 29."                                                                                      "A sermon preached on the 29th of May 1661 : The day of His Majestie's birth, and happy restauration, after a long exile, to his crown and kingdome. Be"
"Funeral of Lady Caecilia Peyton."                                                             "The churches patience and faith in afflictions :Delivered in a sermon at the funerall of the right worshipfull, and vertuous Cecilia Lady Peyton, Octo"
"Thanksgiving for the Exiles Restoration."                                                     "Parallēla dysparallēla, or, The loyal subjects indignation for his royal sovereign's decollation : expressed in an unparallel'd parallel between the"
"January 30. The loyal Subject's Indignation for his royal Sovereign's Decollation."           "Parallēla dysparallēla, or, The loyal subjects indignation for his royal sovereign's decollation : expressed in an unparallel'd parallel between the"
"Causa Dei."                                                                                   "Anti Baal-Berith or The binding of the covenant and all covenanters to their good behaviours. By a just vindication of Dr. Gaudens Analysis (that is, "
"Sermons"                                                                                      "The contemplations upon the history of the New Testament. now complete : together with divers treatises reduced to the greater volume / by Jos. Exon." 
"Consecration of 7 Bishops The Hierarcy exalted, and its Enemies humbled."                     "The hierarchy exalted and its enemies humbled :a sermon preached on the first Sunday in Advent, being the 2d day of Decemb. 1660 : after the consecrat"
"Funeral of Mrs Ellen Harcourt."                                                               "[Mataiobrachytēs tou biou] :The brevity and vanity of man's life : discovered in a sermon preached at the funerals of Mrs. Ellen Hartcourt, young"
"Ass. sermon"                                                                                  "[Mataiobrachytēs tou biou] :The brevity and vanity of man's life : discovered in a sermon preached at the funerals of Mrs. Ellen Hartcourt, young"
"May 29."                                                                                      "A sermon preached in the collegiate church of St. Peter in Westminster, on Wednesday May 29th, 1661 :being the anniversary of His Majesties most joyfu"
"Coronation"                                                                                   "A sermon preached at the collegiate church at Manchester on Tuesday the 23. of April 1661. : Being the coronation-day of his Royal Majestie Charles II"
"May 29. before Lord Mayor."                                                                   "Regina Diervm, or, The joyful day :in a sermon preached at S. Pauls, before the right honourable the Lord Mayor, &c., on Wednesday, May 29. 1661 : the"
"Funeral sermon"                                                                               "A sermon preach'd at the funerals of that worthy personage George Purefoy the elder of Wadley in Berks, esq., who was buried by his ancestors at Drayt"
"Funeral The unrighteous Mammon exchanged for the true Riches."                                "The vnrighteovs Mammon exchanged for the true riches or A sermon, preached at the funeral of William Adams Esq; in the parish church of St. Lawrence I"
"May 29."                                                                                      "A sermon preached at White-Hall on the 29th of May :being the happy day of His Majesties inauguration and birth"                                       
"Coronation April 23."                                                                         "A sermon preached at the magnificent coronation of the most high and mighty King Charles the IId : King of Great Britain, France, and Ireland, Defende"
"Funeral"                                                                                      "The cross crowned: or, Short affliction making way for eternal glory : Opened in a sermon preached at the funeral of Daniel Waldoe Esq; in the Parish-"
"January 30."                                                                                  "Hadadrimmon, sive, Threnodia anglicana ob regicidium :a sermon on Davids humiliation for cutting off the royal robe, and detestation of cutting off th"
end