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

diacritical

v0.1.6

Published

Implment HTML corrections of Baha'i terms using the 'accents' database

Downloads

8

Readme

Diacriṭícál

Bahá’í Term Suggestion Script

Home Page: http://chadananda.github.io/diacritical

The big idea:

Formatting Bahá’í electronic texts is a pain. Even the best quality electronic texts from the BWC contain thousands of errors. And by far the most common type of error is the darned diacritcals on all those transliterated Arabic and Persian terms.

This project attempts to address that fundamental problem by providing an automated replacement and suggestion system which can utilize a dictionary of authoritatively spelled terms.

Some Examples:

See how many errors the current dictionary can find in some reference.bahai.org books:

  • http://chadananda.github.io/diacritical/html/report-Dawn-Breakers.html
  • http://chadananda.github.io/diacritical/html/report-GPB.html
  • http://chadananda.github.io/diacritical/html/report-Advent.html
  • http://chadananda.github.io/diacritical/html/report-Gleanings.html
  • http://chadananda.github.io/diacritical/html/report-Kitab-i-Iqan.html
  • http://chadananda.github.io/diacritical/html/report-PDC.html
  • http://chadananda.github.io/diacritical/html/report-WOB.html
  • http://chadananda.github.io/diacritical/html/report-Summons.html

Get involved, help build the dictionary!

The project to actually gather that massive correct dictionary is over here: https://github.com/chadananda/accents

To get involved, simply contact me at [email protected]. I'll set up user credentials for you which allow you to log in and start adding words to the dictionary.

A JSON object containing the current wordlist can be pulled down using this REST URL:

  • http://diacritics.iriscouch.com/accents/_design/terms_list/_view/terms_list

Using the Library

After adding diacritical.js to a web page simply provide a dictionary of UTF-8 terms as a Javascript array. For example:

var diacrital = New Diacritical();
var dictionary = [
    'Abu’l-Faḍl',
    'Aḥmad',
    'Aḥmad',
    'Aḥmad',
    'Ahmad',
    'aḥmad',
    'Aḥsanu’l-Qiṣaṣ',
    'Ba_ghdád',
    'Baqí‘',
    'Báqir-i-Ra_shtí',
    'Dalílu’l-Mutaḥayyirín',
    'Fatḥ-‘Alí',
];
var bad_text = "This is some sample text with bad diacriticals: Ahmad, Baghdad, "+
  "Fath-Ali and Baqi. Notice that the dictionary uses _sh to indicate an "+
  "underscore. Also, notice that the dictionary is case sensitive but the "+
  "replacement system is still smart enough to deal with all-caps like AHMAD. "+
  "Moreover, the dictionary ideally should have multiple versions of each word in "+
  "order to help weed out misspellings. (Notice one of the spellings of Ahmad is "+
  "wrong in the dictionary but the word is still corrected correctly.)";

var fixed_text = diacritical.replaceText(bad_text, dictionary);

Using the Library as a node module

Diacritical is now a node module so you can simply install it in your node project with:

npm install diacritical

Then instantiate a new diacritical object with:

var Diacritical = require('diacritical'),
    diacritical = new Diacritical;

You'll have to fetch a wordlist like this:

  var accents_url = 'http://diacritics.iriscouch.com/accents/_design/terms_list/_view/terms_list';
  var dictionary = [];
  request(accents_url, function (error, response, body) {
    if (!error && response.statusCode == 200) {
      var data = JSON.parse(body);
      for (i = 0; i < data.rows.length; ++i) dictionary.push(data.rows[i]['key']);    
    } else {
      console.log("Error Response: " + error);
    }
  });

Test harness: http://chadananda.github.io/diacritical/tests