npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

latin-scanner

v1.2.1

Published

API for scanning latin poetry

Downloads

10

Readme

Latin-Scanner

Latin-scanner is a javascript libarary that can scan latin poetry.

What is scansion?

take a look at the github repo

and the package on npm

Installation

Use npm to install latin-scanner

npm install latin-scanner

Usage

This API provides all of its functionality via named exports. There are 4:

  1. scanLine
  2. scanParagraph
  3. defaultSettings
  4. replaceForcedQuantities

functions

There are three user-facing functions in the latin-scanner libarary. One of these is the replaceForcedQuantities function, which takes in a string as an input and will replace _[VOWEL] with a spondee and @[vowel] with a dactyl.

The other two functions scan latin. Both of these accept a settings object and a string as arguments.

scanLine(settings, line) will assume that its string input is a line of poetry. It returns a scannedLine object which contains the solutions found as well as meta data about the scan.

scanParagraph(settings, paragraph) will break its string input on lineBreaks ("\n") and pass each line into the scanLine function. It returns the results as an array of scannedLine objects.

Settings Object

The scanSettings object is how settings are passed to the analyser functions, and it is the same for both functions described above. There are two properties on the object:

  • meter:

    The meter (a string with the value of "Hexameter" or "Pentameter") of the content to be scanned.

  • elegaic:

    A boolean that denotes weather the paragraph should be scanned in Elegaic;

    Elegaic poetry is multi-line by nature and therefore it is ony supported within the scanParagraph function. The elegaic property has no effect on the scanLine function.

    When this is true, the meter declared in the meter property will be used for the first "line", and it will cycle back and forth for each consecutive non-null line.

The defaultSettings export is an instantiation of this interface, configured to handle Hexameter poetry.

scannedLine object

The results for the scanner functions are returned with an interfaced called scannedLineObject. There are 5 data properties on this object, and 3 further properties which can help access the data.

  • status:

    Takes on a value of either "Warning", "OK" or "Plus". This indicates weather the algoithm was able to produce a single scan (OK) multiple scans (Plus) or no scan (Warning).

  • statusMessage:

    Additional information pertaining to the status of the scan. This is most obviously useful when the status is Warning, as it is sometimes used to pass back data about why the line is failing to scan. NB that error information is also passed back in the error property of objects in the "output" property.

  • meter:

    Returns the meter the line was scanned with.

  • line:

    The input line provided.

  • output:

    An array of outputObjects. See the definition

The following properties do not contain any new data; instead, they provide useful ways to access the data we have already discussed.

  • flat:

    Flattens the scan data into a single array. The first entry is the input, and then each output object is flattened wth the raw scan first followed by its solutions.

  • solutions:

    An array only of the solutions - the full scans of the line. NB the difference between flat and solutions; flat contains input and raw scans as well.

  • numberOfSolutions:

    Contains the number of solutions (full scans) found.

outputObject


A single line can often be scanned in more than one way. What's more, there are times when there is more than one way to pick out the vowels in that line; consider how the EU in the words "Deus" and "Teucri" are read differently, despite there being no visible difference. It is useful therefore to organise the soulutions to the line in a more structured manner than a simple array.

The output object is the way such structure is provided. Each output object in the output array represents one way to select the vowels in a line. There are three properties on this interface:

  • raw:

    A string which has the "known quantites" written in; a representation of how the vowels have been selected.

  • full:

    An array of strings, each one representing a full scan or solution to the line.

  • error:

    A string containing information about how this particular vowel set has scanned. This is most often useful when the vowelset produces no results. However, even when the line does scan, this property can still be non-null.

    For instance, in hexameter the last 5 vowels have fixed quantity, so it is assumed that the scan will fit without explicitly checking these syllables. But these syllables are still checked for Long-Short-Long patterns, and if one is found a message will be placed in the error property. This is intended to improve the experience for composers of poetry.

Contributing

If you're interested in things as weird and niche as this, you're certainly welcome to email me and and get involved in the project.

License

MIT