Giter VIP home page Giter VIP logo

indefinite-article.js's Introduction

#Overview

indefinite-article.js is a JavaScript function that returns the indefinite articles "a" or "an" based on a given word or phrase. The code is a port from the Lingua::EN::Inflect Perl module found on this stackoverflow question

#Credit

indefinite-article.js was developed by @rigoneri

indefinite-article.js's People

Contributors

rigoneri avatar

Stargazers

KIRILL GOLIKOV avatar Kevin Bloch avatar Safwan Shaheer avatar Zalman Lew avatar Donald Chatelain avatar ENKR | Jing Hui PANG | 彭竞辉 avatar Aaron Lee Kwang Siong avatar Cserei Zoltán avatar Haolin Wu avatar Mark Allen avatar Agustin Mulet avatar Nick Mortensen avatar Xander Luciano avatar Matthew Kuehn avatar azu avatar Mark McFarlane avatar Andrew Branch avatar  avatar Scott Harsla avatar Will McNeilly avatar Tim Herby avatar Dustin Coates avatar Brian Canzanella avatar  avatar Andrius Každailis avatar Daniel Cardoso avatar Steve Workman avatar  avatar Lance Kidwell avatar James Spencer avatar Bryan English avatar Paul (xobb) Chubatyy avatar Zachary Mayberry avatar Peter Robinett avatar  avatar Mathew Davies avatar Robert Velasquez avatar Viktors Rotanovs avatar

Watchers

 avatar  avatar

indefinite-article.js's Issues

Small typo

Two occurrences of "aedhilmnorsx" should be "aefhilmnorsx" instead.

Syntax issue in regex iteration

In the "Special cases where a word that begins with a vowel should be preceeded by 'a' " for-loop iteration

for(var i in regexes) //line ~55-60

gives this error in IE: "Syntax error in regular expression"

It seems like for-in iterates through not only the contents of the array but also other array properties.

When changed to this, the error is gone
for (var i=0; i < regexes.length; i++)

PS. This is my first time writing error report in GitHub (a new student), so pardon any mistakes. Thanks in advance.

Regex not anchored

This regex is not anchored:

    if (word.match(/(?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z]/)) {
        return "an";
    }

It looks to me like this was intended:

    if (word.match(/^(?!FJO|[HLMNS]Y.|RY[EO]|SQU|(F[LR]?|[HL]|MN?|N|RH?|S[CHKLMNPTVW]?|X(YL)?)[AEIOU])[FHLMNRSX][A-Z]/)) {
        return "an";
    }

As it is, this matches "SR" in "GDSR applicant" and returns "an" for "an GDSR applicant".

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.