It struck me as remarkable that The New York Times editorial board outright stated that Trump and Musk are “upending the rule of law.” As the article explains, the rule of law is the bedrock of this nation’s success because it produces stability across generations. Destroying it is destroying the country.
More remarkable was that this plain declaration that the rule of law may cease to exist in the United States did not occur until the middle of the article. To me, this is a headline (rather than a friendly nod to Musk somehow “misunderstanding” things; Musk and Trump perfectly understand what they are doing).
The people in control of the law are destroying it. As a result, the country will cease to function as it has for generations. The social, economic, and national and personal security costs will be enormous. We will turn into a nation of gangs where whoever wields the most violence, most money, and most shamelessness controls collective decision-making.
As I looked more closely at the text, I was curious: How long did it take to state “Mr. Musk and Mr. Trump are not trying to change laws; they are upending the rule of law”? What sentence number is it?
Spoiler: It is sentence No. 28 out of 58, though this may not be exact because I got the answer using somewhat imperfect JavaScript to scrape and analyze the article.
The tool, SentenceIt, grabs all the paragraphs within a certain chunk of the page, breaks them up into sentences, then orders those sentences in a list. I did the work using the Google Gemini addon within Visual Studio; I am surprised it worked, though it took numerous iterations.
Trying to remove some text, such as “advertisements,” became pretty complex and customized to the structure of The New York Times pages. It was also difficult to instruct the app to handle quotes and material within quotes well. For example, quotes that run more than a sentence end up having part of the quote put into a new numbered line.
A few things I learned about working with AIs in this context:
- The more specific your prompt, the better the result. Use specific language to refer to specific parts of the code. This is not a creative thinking machine; it is an executor of your will and analysis. But I imagine there are instructions that can produce analysis it can then act upon. I did try this once or twice, but the results seemed worse.
- The AI isn’t great at thinking holistically about what might be causing a problem. For example, when I slogged through handling quoted elements of an article, I had to remind it that it might be missing quotes in smartquote style, so it needed to scan for the encoding of smartquotes. Then I had to remind it that there are multiple ways to encode smartquotes, and it needed to find them all. It actually figured out a way to do this, but, sadly, other more severe problems with the code were reintroduced, and I could never get everything to work (and I did not dive into the code myself).
If you’d like to use the SentenceIt app, create a bookmarklet that will call up the code on my site. A what? A bookmarklet is a browser bookmark that uses JavaScript code rather than a URL.
You can create a bookmarklet using two methods:
- Drag this linked word into your browser bar: SentenceIt
- Or manually create a new bookmark:
- create a new bookmark in your browser;
- name it SentenceIt or whatever you like;
- put the code below in the URL field (the code starts with “javascript:..”);
- save your bookmark, then click on it when you are on the page of a New York Times article. It might work with other publications, too, but maybe not, as different outlets have somewhat different ways of structuring their HTML.
Update 3/9/2025: I began using version 15 to clean up the results even further. Still, it is proving impossible to handle sentences within quotes and smartquotes. Multiple sentences within a quote are being broken to new lines. Not terrible. But not perfect. The code below now references “vs-cleaner-sentence-v15.js”.
javascript:(function(){document.body.appendChild(document.createElement('script')).src='https://graffy.hellotumo.com/vs-cleaner-sentence-v15.js';})();