rnkn / fountain-mode

Emacs major mode for screenwriting in Fountain plain-text markup
https://fountain-mode.org
GNU General Public License v3.0
391 stars 16 forks source link

Can we see this package contain a very rough estimate on length and general stats? #138

Open chariegg opened 9 months ago

chariegg commented 9 months ago

It would be very beneficial (and I would really like to see this get implemented to make fountain-mode even more appealing to use since it has built in export now if you have groff installed) to get a very rough estimate on how long the screenplay is and how long dialogue is for each character and each scene. Looking at the source code for betterfountain, which is fountain support for visual studio code, it's commented the general formula it's using to give a guess on average how long it would take for the movie to go by. I'm a terrible programmer and wanted to hear your feedback how this would be implemented.

Now, the formula is this (Hopefully I'm understanding this right): You take how long the sentence is and how many sentences are per character dialogue. The more dialogue and action elements, the longer a scene will be. I'm going to give a ballpark estimate that the average person would say a sentence at normal speed no longer than 3-5 seconds (See attached PDF for a research paper done on average articulation from 14 movies). Take the total time and possibly include word count and add together all the dialogue and action such as monologue into the scene itself. Then you can show statistics breakdown of each scene. The betterfountain extension only truly cares if the scene starts with INT. or EXT. Everything else (Because anything can be a scene heading under fountain) is categorized under other and it also shows if more stuff happened at night or day. Even more using all this, it can show how many total pages based on what you've typed. But I think fountain mode already does that.

Attaching an example snippet of the typescript code, this was what was under 'calculateDialogueDuration' from utils.ts:

export const calculateDialogueDuration = (dialogue:string): number =>{
    var duration = 0;

    //According to this paper: http://www.office.usp.ac.jp/~klinger.w/2010-An-Analysis-of-Articulation-Rates-in-Movies.pdf
    //The average amount of syllables per second in the 14 movies analysed is 5.13994 (0.1945548s/syllable)
    var sanitized = dialogue.replace(/[^\w]/gi, '');
    duration+=((sanitized.length)/3)*0.1945548;
    //duration += syllable(dialogue)*0.1945548;

    //According to a very crude analysis involving watching random movie scenes on youtube and measuring pauses with a stopwatch
    //A comma in the middle of a sentence adds 0.4sec and a full stop/excalmation/question mark adds 0.8 sec.
    var punctuationMatches=dialogue.match(/(\.|\?|\!|\:) |(\, )/g);
    if(punctuationMatches){
        if(punctuationMatches[0]) duration+=0.75*punctuationMatches[0].length;
        if(punctuationMatches[1]) duration+=0.3*punctuationMatches[1].length;
    }
    return duration
}

Apologizes for the large wall of text. I wanted to help make it not confusing about how to tackle this and generally, it would be very helpful to have this included because then one less reason to leave emacs.

You can find betterfountain here and attached is the PDF as mentioned: AnAnalysisOfArticulationRatesInMovies.pdf

chariegg commented 9 months ago

I wanted to add as well, I'm in the process of learning a bit of elisp. If you cannot find the time to implement this by yourself, I'll give it a shot.

rnkn commented 8 months ago

Yes a fountain-stats command would probably be good. As discussed in IRC I don't think this should attempt to time the script, but there's plenty of other interesting stats that could be displayed.

chariegg commented 8 months ago

I've been making this look far more complex than it really is. Visual Studio Code when it gives you stats presents it in 3 different tabs for the panel. Time Duration, Scene Breakdown, and Character Breakdown. All of this, all of it, can very easily be applied to the KISS (Keep It Simple, Stupid) principle.

If it's an action or dialogue element, it will apply one of two different formulas. Say for dialogue, it uses regex to check if it's a dialogue element and then counts the length of the total dialogue, then divide by 3 and taking the results of that multiply by 0.1945548. I did the following test with just a single sentence and compared it to timing myself speaking it out at a normal length.

echo "It's just been a while. I guess I was getting lulled into thinking I had a normal life." | wc -c returned back 89 characters including spaces. Then adding in an additional padding for commas, end of sentence such as question mark and in addition: space between words, it gives you the total time for the dialogue. Then taking all that adds it together. It's incredibly simple if I don't make it sound more complex than it really is. The calculated formula I presented for the sentence matched very close to how long the timer reported back me timing myself. I truly think some kind of time feedback that's a very rough estimate can be done. In just a few new functions as well, not writing up complex algorithms.

general-stats

rnkn commented 8 months ago

I don't have much interest in timing a script (beyond the old rule of one page = one minute). There are other stats that could be interesting. A distraction from actual writing, but interesting nonetheless.