GithubHelp home page GithubHelp logo

liatemplates / textanalysis Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 249 KB

Runs different metrics against a text

Home Page: https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/TextAnalysis/main/README.md

License: Creative Commons Zero v1.0 Universal

JavaScript 100.00%
liascript liascript-template oer text-analysis style

textanalysis's Introduction

TextAnalysis - Template

          --{{0}}--

This document defines basic text analysis functions macros for static text analysis to determine readability, complexity and grade level of a particular text. It is mainly based on the JavaScript package text-readability and the provided macros are intended to be used in trainig writing, to give students instant feedback for written texts. All macros/tests can be added to LiaScript code-blocks to make them editable.

Try it on LiaScript:

https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/TextAnalysis/main/README.md

See the project on Github:

https://github.com/liaTemplates/TextAnalysis

          --{{1}}--

There are three ways to use this template. The easiest way is to use the import statement and the url of the raw text-file of the master branch or any other branch or version. But you can also copy the required functionionality directly into the header of your Markdown document, see therefor the last slide. And of course, you could also clone this project and change it, as you wish.

       {{1}}
  1. Load the macros via

    import: https://raw.githubusercontent.com/liaTemplates/TextAnalysis/main/README.md

  2. Copy the definitions into your Project

  3. Clone this repository on GitHub

@Textanalysis.check

                --{{0}}--

There is one simple macro that runs all defined tests, it is @Textanalysis.check. It has to be attached to your Markdown code-block. It receives only one parameter, which is a list of strings, put into a verbatim elements (single backticks `). The order of strings also define the order of tests to be executed. Furthermore, if the command-string starts with a lower case, only a simple value/result gets returned, with upper case you will get also more information about the specific value and how it has to be interpreted.

``` text
Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.
```
@Textanalysis.check(`[words", "syllables", "sentences"]`)

Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.

@Textanalysis.check(["words", "syllables", "sentences"])

List of tests

Currently you can select all of the following tests. For more information see the source-code in src/index.js.

  • automatedReadabilityIndex:

    Returns the ARI (Automated Readability Index) which outputs a number that approximates the grade level needed to comprehend the text.

    For example if the ARI is 6.5, then the grade level to comprehend the text is 6th to 7th grade.

    Score Age Grade Level
    1 5-6 Kindergarten
    2 6-7 First/Second Grade
    3 7-9 Third Grade
    4 9-10 Fourth Grade
    5 10-11 Fifth Grade
    6 11-12 Sixth Grade
    7 12-13 Seventh Grade
    8 13-14 Eighth Grade
    9 14-15 Ninth Grade
    10 15-16 Tenth Grade
    11 16-17 Eleventh Grade
    12 17-18 Twelfth grade
    13 18-24 College student
    14 24+ Professor

    Wikipedia: Automated readability index

  • colemanLiauIndex:

    This is a grade formula in that a score of 9.3 means that a ninth grader would be able to read the document.

    Wikipedia: Coleman–Liau index

  • daleChallReadabilityScore:

    Different from other tests, since it uses a lookup table of the most commonly used 3000 English words. Thus it returns the grade level using the New Dale-Chall Formula.

    Score Notes
    4.9 or lower easily understood by an average 4th-grade student or lower
    5.0–5.9 easily understood by an average 5th or 6th-grade student
    6.0–6.9 easily understood by an average 7th or 8th-grade student
    7.0–7.9 easily understood by an average 9th or 10th-grade student
    8.0–8.9 easily understood by an average 11th or 12th-grade student
    9.0–9.9 easily understood by an average 13th to 15th-grade (college) student

    Wikipedia: Dale–Chall readability formula

  • fleschKincaidGrade:

    This is a grade formula in that a score of 9.3 means that a ninth grader would be able to read the document.

    Wikipedia: Flesch–Kincaid grade level

  • fleschReadingEase:

    While the maximum score is 121.22, there is no limit on how low the score can be. A negative score is valid.

    Score Difficulty
    90-100 Very Easy
    80-89 Easy
    70-79 Fairly Easy
    60-69 Standard
    50-59 Fairly Difficult
    30-49 Difficult
    0-29 Very Confusing

    Wikipedia: Flesch reading ease

  • gunningFog:

    This is a grade formula in that a score of 9.3 means that a ninth grader would be able to read the document.

    Fog Index Reading level by grade
    17 College graduate
    16 College senior
    15 College junior
    14 College sophomore
    13 College freshman
    12 High school senior
    11 High school junior
    10 High school sophomore
    9 High school freshman
    8 Eighth grade
    7 Seventh grade
    6 Sixth grade

    Wikipedia: Gunning fog index

  • linsearWriteFormula:

    This is a grade formula in that a score of 9.3 means that a ninth grader would be able to read the document.

    It is a readability metric for English text, purportedly developed for the United States Air Force to help them calculate the readability of their technical manuals. It is specifically designed to calculate the United States grade level of a text sample based on sentence length and the number of words used that have three or more syllables.

    Wikipedia: Linsear Write

  • readabilityConsensus:

    Based upon "Dale-Chall Readability Score", "Linsear Write Formula", "Coleman-Liau Index", "Automated Readability Index", "SMOG Index", "Fog Scale", " Flesch-Kincaid Grade Level", "Flesch Reading Ease formula", returns the estimated school grade level required to understand the text.

  • sentences: Returns the number of sentences present in the given text.

  • smogIndex:

    This is a grade formula in that a score of 9.3 means that a ninth grader would be able to read the document.

    Texts of fewer than 30 sentences are statistically invalid, because the SMOG formula was normed on 30-sentence samples. textstat requires atleast 3 sentences for a result.

    Wikipedia: SMOG

  • syllables: Returns the number of syllables present in the given text.

  • words: Calculates the number of words present in the text. (Punctuation is not taken into account)

  • readingTime:

    The speed at which subjects read a text aloud tend varies between 228±30 words per minute for English. While proofreading materials, people are able to read English at 200 words per minute on paper, and 180 words per on a monitor.

    Wikipedia: Reading and comprehension

  • speakingtime:

    Audiobooks are recommended to be 150–160 words per minute, which is the range that people comfortably hear and vocalize words. Slide presentations tend to be closer to 100–125 words per minute for a comfortable pace.

    Wikipedia: Speech and listening

@Textanalysis.full

--{{0}}--

The following macro runs all tests and gives an returns only the short results.

Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.

@Textanalysis.full

@Textanalysis.FULL

--{{0}}--

Use this macro to run all tests an provide more information on how the details have to interpreted.

Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.

@Textanalysis.FULL

@Textanalysis.time & @Textanalysis.TIME

--{{0}}--

The two time macros can be used to estimate the reading and speaking time for different contexts.

Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.

@Textanalysis.time

Playing games has always been thought to be important to
the development of well-balanced and creative children;
however, what part, if any, they should play in the lives
of adults has never been researched that deeply. I believe
that playing games is every bit as important for adults
as for children. Not only is taking time out to play games
with our children and other adults valuable to building
interpersonal relationships but is also a wonderful way
to release built up tension.

@Textanalysis.TIME

Note: This could be improved in the future by combining this with the calculated reading complexity for different use-cases: (1 grade & slower reading time)

Examples

On Tuesday, January 10, I’ll go home to Chicago to say my
grateful farewell to you, even if you can’t be there in
person.

I’m just beginning to write my remarks. But I’m thinking
about them as a chance to say thank you for this amazing
journey, to celebrate the ways you’ve changed this country
for the better these past eight years, and to offer some
thoughts on where we all go from here.

Since 2009, we’ve faced our fair share of challenges, and
come through them stronger. That’s because we have never
let go of a belief that has guided us ever since our
founding — our conviction that, together, we can change
this country for the better. So I hope you’ll join me one
last time.

@Textanalysis.base

Thank you. It’s true, and these are the best and the
finest. When Mexico sends its people, they’re not sending
their best. They’re not sending you. They’re not sending
you. They’re sending people that have lots of problems, and
they’re bringing those problems with us. They’re bringing
drugs. They’re bringing crime. They’re rapists. And some,
I assume, are good people.

But I speak to border guards and they tell us what we’re
getting. And it only makes common sense. It only makes
common sense. They’re sending us not the right people.

@Textanalysis.base

Implementation

script:   ./dist/index.js

@Textanalysis.full: @Textanalysis.check(`["words", "syllables", "sentences","fleschReadingEase", "fleschKincaid", "gunningFog", "smog", "automatedReadabilityIndex", "colemanLiau", "linsearWrite", "daleChall", "readabilityconsensus", "readingtime", "speakingtime"]`)

@Textanalysis.FULL: @Textanalysis.check(`["words", "syllables", "sentences","FleschReadingEase", "FleschKincaid", "GunningFog", "Smog", "AutomatedReadabilityIndex", "ColemanLiau", "LinsearWrite", "DaleChall", "Readabilityconsensus", "Readingtime", "Speakingtime"]`)

@Textanalysis.time: @Textanalysis.check(`["words", "syllables", "sentences", "readingtime", "speakingtime"]`)

@Textanalysis.TIME: @Textanalysis.check(`["words", "syllables", "sentences", "Readingtime", "Speakingtime"]`)

@Textanalysis.base: @Textanalysis.check(`["words", "syllables", "sentences", "readabilityconsensus"]`)

@Textanalysis.BASE: @Textanalysis.check(`["words", "syllables", "sentences", "Readabilityconsensus"]`)

@Textanalysis.check
<script>
var checks = @0
var text = `@input`

for(var i=0; i< checks.length; i++) {
  console.html(window.Textanalysis(checks[i], text))
}

""
</script>

@end

textanalysis's People

Contributors

andre-dietrich avatar

Watchers

 avatar  avatar

Forkers

nethiri

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.