Giter VIP home page Giter VIP logo

node.inflection's Introduction

DreamersLab official website

node.inflection's People

Contributors

ben-lin avatar bijx avatar brandondewitt avatar ctcpip avatar dmiro avatar eseliger avatar gf3 avatar gregerolsson avatar jasoncrawford avatar kanecohen avatar lancejpollard avatar luk3thomas avatar marcelklehr avatar overlookmotel avatar p-kuen avatar pdehaan avatar pmowrer avatar raymyers avatar sgtpepper43 avatar thedeeno avatar underscorebrody 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node.inflection's Issues

Need to add "If defined" checks to play nice with angularjs and promises

I'm using the (ngInflection) [https://github.com/konsumer/ngInflection] angularjs wrapper for this node.inflection and i'm hitting some problems due to the way angular filters evaluate a variable that is expecting a promise to resolve.

I have a div in an ng-repeat with with a static class plus a dynamic class like this:

dasherize : function ( str ){ return str.replace( space_or_underbar, '-' ); },

After:

dasherize : function ( str ){
    if(str) {
        return str.replace( space_or_underbar, '-' );
    } else {
    return str;
    }
},

This works because when the promise resolves to a value, the filter is fired again.

Plural of business

In line with v1.4.2 of inflection, I believe that in general "business" can be pluralized to "businesses".

Here's an example of the plural use from the good ol' BBC: http://www.bbc.co.uk/news/uk-30008546

"Business" is countable in some uses of the word and uncountable in other uses. But "businesses" is certainly a word you hear often (and correctly!) in common speech.

I notice someone else has raised an issue about the plural of "access" (#31). That's similar in that it's a word which has both countable and uncountable uses, but I think the uncountable uses are far more common.

I guess it's arguable either way, but I suspect I won't be the only one to update to inflection v1.5 and find that my code breaks due to the disappearance of "businesses"!

What unexpected behaviors?

Hey there,

Maybe in the readme you could explain what sort of issues come up when you extend the prototype. Is it specific to Node?

rb

Inflection 1.3.7 "meta" => "metum"

Howdy,

Seems like v1.3.7 translates 'meta' to 'metum' -- presumably following 'data' to 'datum' logic. Previous behavior was 'meta' => 'metas'.

Singularize "address" produces "addres"

I just added this to the singular_rules array and it fixes it:

    [ new RegExp( '(quiz)zes$', 'gi' ),                                                   '$1' ],
    [ new RegExp( 'ss$', 'gi' ),                                                          'ss' ],
    [ new RegExp( 's$', 'gi' ),                                                           '' ]

.underscore returns wrong values

inflection.underscore("Apple Tree Lake"); // "apple _tree _lake" should be "apple_tree_lake"
inflection.underscore("Apple 20 Tree Lake"); // "apple 20 _tree _lake" should be "apple_20_tree_lake"

Wrong pluralization of "nucleus"

The plural of "nucleus" should be "nuclei". The rare plural form "nucleuses" should also be recognized to be singularized correctly.

Current behavior:

inflection.singularize("nucleus") // "nucleu" (wrong)
inflection.singularize("nucleuses") // "nucleuse" (wrong)
inflection.singularize("nuclei") // "nuclei" (wrong)
inflection.pluralize("nucleus") // "nucleus" (wrong)
inflection.pluralize("nucleuses") // "nucleuses" (correct)
inflection.pluralize("nuclei") // "nucleis" (wrong)

AST error when parsing your module with browserify

The specific line in question is in file lib/inflection.js line 141 and the error is:

Error: Parsing file /home/...../lib/inflection.js: Line 141: Comprehension Error

I suspect it's because of their parser and its improperly parsing the list of words which look like JavaScript keywords. I confirmed and the package.json is refering to the latest npm version.

I know that this is not technically your issue, but it could easily be resolved by concatenating strings that contain keywords on that line.

Thoughts?

api.use underscore

Getting this error:


W20130926-16:57:37.896(4)? (STDERR) /home/bline/.meteor/tools/3cba50c44a/lib/node_modules/fibers/future.js:173
W20130926-16:57:37.897(4)? (STDERR)                         throw(ex);
W20130926-16:57:37.897(4)? (STDERR)                               ^
W20130926-16:57:37.899(4)? (STDERR) TypeError: object is not a function
W20130926-16:57:37.900(4)? (STDERR)     at Object.inflector.resetInflections (packages/underscore-inflection/lib/underscore.inflection.js:161)

I modified package.js and added

api.use('underscore', where);

just above the api.add_files line and that seems to have fixed the issue.

This is with meteor 0.6.5.1

funky underscore result

This is not what I expected:

> require('inflection').underscore('Table of Contents')
'table of _contents'

`data` being singularized to `data`

correct result should be datum

pluralize('datum') // data
singularize('data') // data

the pluralize module handles this case correctly, if that helps

Focuses > focu

Currently, inflection.singularize('focus') == "focu".

Focus should remain singular, and "foci" and "focuses" should probably be added as exceptions for the plural.

Fish is pluralized as Fishes!

The plural of fish is fish!

I see fish on the list of "unaccountable" words commented out... A little help please.

dasherize of camelCase word

Expected

expect(dasherize('TestMe')).to.equal('test-me')

Actual

expect(dasherize('TestMe')).to.equal('TestMe')

Add to Bower?

Hey would you mind adding your inflection library to Bower?

http://twitter.github.com/bower/

All you need to do is run this command in your project root:

bower register inflection git://github.com/dreamerslab/node.inflection

Then it should be possible to install with:

bower install inflection

Bower should use your package.json to find the right file to download, but if you want to get more specific you could add this component.json file to the root of your project:

{
  "name": "inflection",
  "version": "x",
  "main": "./lib/inflection.js"
}

Cheers.

dashcase to camelcase

I noticed camelize does not support converting dashcase to camelcase, should it?

Example:

const inflection = require('inflection')

inflection.camelize('foo-bar') // 'Foo-bar'

I expected the example above to return FooBar.

"whereas" is inflected

I'd be happy to do a pr to fix. not sure where to best make the change though. uncountable_words is described as being nouns, but it seems a good fit for that array. thoughts?

undescore removes _

Hey there!

I just found inflection.underscore('_') returns '' (an empty string).

I bet it's a bug since this method should add, not remove, underscores.

Once confirmed by the author, I'm happy to implement a fix.

Question regarding expected behaviour when singularizing a word which is already singular

Hi there, sequelize/sequelize reporting in. We recently switched from lingo to inflection for internal pluralization and singularization. So far it has been working out great, but version 1.4.1 gives an error in our test suite.

inflection.singularize('street');

In version 1.3.8 it gave street, while 1.4.1 gives stroot. Singularization of streets works fine, so the problem only occurs when singularizing an already singular word. Is there any defined behaviour for that?

Method to convert all characters to UPPERCASE

It seems a method is missing from this tool that would make all of the characters UPPERCASE.

I didn't see anything in the readme about this, and please forgive me if I've overlooked some explanation as to why this hasn't already been included.

camelize strings with _ prefix

Strings that are prefixed with an underscore for some reason make the low_first_letter flag unusable.
Is this the desired effect or a bug?

inflection.camelize('_foo_bar', false);
// FooBar

inflection.camelize('_foo_bar', true);
// FooBar

plural of about

There is no singular or plural for the word 'about'. I guess for such cases it should return the word as it is.
@ben-lin Please look into it and notify if this is worth considering.

humen

Incorrect pluralization for: human, aircraft.

Spelling s/seperate/separate/

Correct the spelling of "seperate" to "separate" wherever found. In particular, in Readme.md.
(Mnemonic: there is "a rat" in separate.)

Detect if word is singular or plural

I've come across a use case where it would be helpful to know if a word is either singular or plural. I couldn't see an immediate way to do this with the library. How could we implement this? Would this be in the scope of the library?

Wrong pluralization of 'grammar'

var inflection = require('inflection');
console.log(inflection.pluralize('grammar'));
// "grammar" instead of expected "grammars"

I've seen that this package is based on wiktionary.
The grammar page does mention: grammar (countable and uncountable, plural grammars)

I noticed this when defining a 'grammar' model with the ORM Sequelize which has inflection as a dependency. Also, it seems that the issue comes from this package itself and not from rails.

Titleize does not work on words with dashes

Example:

inflection.titleize("x-men:-the-last-stand")
"X-Men:-the-Last-Stand"

For comparison on Rails 4.2:

Loading development environment (Rails 4.2.7.1)
irb(main):001:0> ActiveSupport::Inflector.titleize("x-men:-the-last-stand")
=> "X Men: The Last Stand"

And Rails 5:

Loading development environment (Rails 5.1.1)
irb(main):001:0> ActiveSupport::Inflector.titleize("x-men:-the-last-stand")
=> "X Men: The Last Stand"

Camelize shouldn't convert everything to lower case

Hey,

Camelizing an already camelcased variable shouldn't convert every character to lower case. I imagine it does that because FOO_BAR might be expected to camelize as fooBar. But still, the camelized version of fooBar_Baz should be fooBarBaz, not foobarBaz as it is now.

Unexpected result when using "canvas"

Code
var name = 'canvas' var pluralName = inflections.pluralize(name) var singularName = inflections.singularize(name)
expect
pluralName -> canvasses
singularName -> canvas

result
pluralName -> canvas
singularName -> canva

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.