Giter VIP home page Giter VIP logo

namecase's Introduction

NameCase

https://rubygems.org/gems/namecase

Description

NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for converting strings to be properly cased. This is good for converting denormalized data to human friendly data.

Example Usage

NameCase("RON BURGUNDY")  # => Ron Burgundy
NameCase("MCDONALDS")     # => McDonalds

Acknowledgements

This library is a port of the Perl library, and owes most of its functionality to the Perl version by Mark Summerfield. Any bugs in the Ruby port are my fault.

Author

Original Version: Copyright (c) Mark Summerfield 1998-2002. [email protected] All Rights Reserved

Ruby Version: Copyright (c) Aaron Patterson 2006

License

NameCase is distributed under the GPL license. Please see the LICENSE file.

namecase's People

Contributors

bobjflong avatar danxexe avatar joshuapinter avatar juanitofatas avatar khoffma4 avatar mustmodify avatar tenderlove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

namecase's Issues

Repeated "Mc" prefix leads to incorrect duplication

I'm not sure if this is actually a bug, given possible real-world inputs, but it certainly seems wrong.

>> NameCase("mcfoo mcbar")
=> "McFoo McFoo"
>> NameCase("MCFOO MCBAR")
=> "McFoo McFoo"

The "McBar" has been clobbered by "McFoo" because the replacement is global across the whole string. This gem seems to support passing a full first+last name input, so this looks like a bug to me.

Note this working case, though:

>> NameCase("McFoo McBar")
=> "McFoo McBar"

Arabic definite article correction may not be current standard.

Hello, @tenderlove! Thank you for porting this library!

While using this library, I received feedback that the way it handle the Arabic definite article 'al-' is not quite right.

Currently the rule looks like:

localstring.gsub!(/\bAl(?=\s+\w)/, 'al')  # al Arabic or forename Al.

The corresponding test asserts al Fahd is the accepted standard.

It seems common to hyphenate the definite article (al-Fahd).

"Al-" and its variants (ash-, ad-, ar-, etc.) are always written in lower case (unless beginning a sentence), and a hyphen separates it from the following word.

https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Arabic#Definite_article

Looking closer at the regular expressions fixing "son (daughter) of" etc
, they seem to have different terminators based on whether the prefix can also be a 'forename' (Ben, Al, or Van). In those cases, rather than using \b, it uses (?=\s+\w). If \b(?=.+\w) were used instead, I think it would fix the Arabic issue.

Hebrew seems to also be not quite up to the current standard, as the test case 'ben Gurion' is actually more commonly seen as Ben-Gurion:
screen shot 2017-06-27 at 00 00 08

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.