An interface for using Language Style Matching to determine the likeness of different texts and their authors.
npm install lsm
var LSM = ;var text_1 = "In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.\"Whenever you feel like criticizing any one,\" he told me, \"just remember that all the people in this world haven't had the advantages that you've had.\"";var text_2 = "I'm a romantic; a sentimental person thinks things will last, a romantic person hopes against hope that they won't.";var result = LSM;console;// 0.6211902592673091
A likeness value of 1 indicates that the compared samples are identical in their proportions of function words. A value of 0 indicates total dissimilarity.
What is Language Style Matching?
Language Style Matching (LSM) uses function words -- like conjunctions, pronouns, prepositions, etc. -- as proxies for the author's personality. LSM calculates likeness between texts by comparing the proportions of different classes of function words.
In research, LSM has proven a resilient indicator of compatibility in romance, friendship, and business.
Read the Economist's thoughts on it, or check out the science:
- Language Style Matching Predicts Relationship Initiation and Stability
- Language Style Matching in Writing: Synchrony in Essays, Correspondence, and Poetry