15 ms·
A cool way to use natural language in JavaScript
- oori 10y agonlp.statement('She sells seashells').negate().text() // She doesn't sell seashells nlp.sentence('I fed the dog').replace('the [Noun]', 'the cat').text() // I fed the cat nlp.text("Tony Hawk did a kickflip").people(); // [ Person { text: 'Tony Hawk' ..} ]
- stephenr 10y agoDoes the same thing work if the name is lowercase? Stanford nlp won't recognise "I want to go to sydney" with a location because it expects proper nouns to be capitalised for places (and other similar named entities I believe). I tried to make their case less models work but a lack of time and patience resulted in a more specific fix for what we needed.
- atomwaffel 10y ago> nlp.text('i want to go to sydney.').places()[0].city 'Sydney' > nlp.text('tony hawk did a kickflip.').people()[0].text 'tony' So in the first case, it clearly does recognise that Sydney is a city independent of capitalisation. In the second case, it does recognise the first name but not the last, instead tagging "hawk" as a noun. The same happens with "john smith", however "john thomas" is recognised as a full name.
- mpjme 10y agoTo be fair, I think that my grandmother, not familiar with gaming/skating celebs, would tag it the same way.
- gcr 10y agoThanks for writing this comment. I can't think of a better way to describe what this library does than reading these super simple examples.
- deleted 10y ago[deleted]
- geon 10y agoCheck out the docs. It is chock full of them. https://github.com/nlp-compromise/nlp_compromise/blob/master/docs/api.md https://github.com/nlp-compromise/nlp_compromise/blob/master...
- lilgreenland 10y agoI added this to an example chatbot lesson I made for a high school intro CS class. http://codepen.io/lilgreenland/pen/zqXLeJ?editors=0010 http://codepen.io/lilgreenland/pen/zqXLeJ?editors=0010
- lilgreenland 10y agocan anyone think of some other cool tricks I can do with this to show my class on Monday?
- huj123 10y agoLook up example questions for the Loebner Prize, and see if you can tweak your bot to answer some of them.
- PantaloonFlames 10y agoThanks. Why don't more people write docs like this, leading with examples?
- WhoIsSatoshi 10y agoIt's called README file. It would blink if it could.
- rolfvandekrol 10y agoWhy is NLP these days equivalent of Natural English Language Processing? There are much more languages in the world.
- paradite 10y agoI am surprised to see how an off-topic discussion generated much more comments than the discussion on this cool project per se. It seems to be the norm these days on HN...
- rolfvandekrol 10y agoSurpises me too. I just pointed out that the project at hand hardly even mentions that it is targeted at English, as if NLP is English by definition and that doesn't need any explanation.
- tfm 10y agoShort answer would be availability of tagged data, in turn dependent on historical research, which is a laggy history of who's been funding the research. This is changing, thankfully; check out e.g. the European Language Resources Association's catalogues, http://catalog.elra.info/ http://catalog.elra.info/ or any of the very incomplete list on wikipedia: https://en.wikipedia.org/wiki/List_of_text_corpora https://en.wikipedia.org/wiki/List_of_text_corpora or in fact the various international Wikipediae themselves! As for this particular project being English only ... itch to scratch probably ;-)
- danieldk 10y agoShort answer would be availability of tagged data, Part-of-speech and syntax-annotated corpora have been available for a long time for many other languages than English. E.g. for German: http://www.ims.uni-stuttgart.de/forschung/ressourcen/korpora/tiger.html http://www.ims.uni-stuttgart.de/forschung/ressourcen/korpora... http://www.sfs.uni-tuebingen.de/ascl/ressourcen/corpora/tueba-dz.html http://www.sfs.uni-tuebingen.de/ascl/ressourcen/corpora/tueb... Dutch: https://www.let.rug.nl/vannoord/Lassy/ https://www.let.rug.nl/vannoord/Lassy/ http://lands.let.ru.nl/cgn/ http://lands.let.ru.nl/cgn/ https://www.let.rug.nl/vannoord/trees/ https://www.let.rug.nl/vannoord/trees/ French: http://www.llf.cnrs.fr/en/Gens/Abeille/French-Treebank-fr.php http://www.llf.cnrs.fr/en/Gens/Abeille/French-Treebank-fr.ph... I think that one of the problems is that NLP research of English typically has a higher chance of getting accepted at conferences.
- iamgopal 10y agoWhat a day it would be, when nlp natively supported in browsers and os.
- 0x0 10y agoNSLinguisticTagger has been a part of iOS since iOS5 :) Link: http://nshipster.com/nslinguistictagger/ http://nshipster.com/nslinguistictagger/
- kawera 10y agoThis looks fantastic, thanks! Do you know if there's something similar for OSX ?
- escap 10y agohttps://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSLinguisticTagger_Class/ https://developer.apple.com/library/mac/documentation/Cocoa/... Available in OS X v10.7 and later
- fiatjaf 10y agoHow would I proceed to turn "this library is great." into "all other libraries aren't great." ? https://tonicdev.com/5716bedc1dd0391100f67570/57372d9625c9be1100f23823 https://tonicdev.com/5716bedc1dd0391100f67570/57372d9625c9be...
- hegivor 10y agoPerhaps I am misunderstanding the example but isn't the date parsing result from the API documentation incorrect. nlp.value("I married April for the 2nd time on June 5th 1998 ").date() // [Date object] d.toLocaleString() -> "04/2/1998" https://github.com/nlp-compromise/nlp_compromise/blob/master/docs/api.md#date-parsing https://github.com/nlp-compromise/nlp_compromise/blob/master...
- thomasahle 10y agoMaybe they want to show us the limitations? This makes it seem like they are not doing any fancy grammar parsing.
- userbinator 10y agoNo 4th or February in the string either... yet another example of how unambiguous date parsing in natural languages is very, very difficult. Also an example of why ISO-8601 is awesome.
- petemill 10y agoApril = 4 2nd = 2
- hueving 10y agoApril 2nd.
- themartorana 10y agoEveryone always looks at me funny when I write my dates as `yyyy-mm-dd` - until, that is, I explain that it sorts alphabetically perfectly. That's the moment I can convert people to ISO-8601 converts.
- BinaryIdiot 10y agoThis library is fantastic. I've used in some side projects and while it's far from perfect it hits that "good enough" space pretty well.
- moioci 10y agoSomebody has to point out that the past participle of swim is swum, not swam. (/pedantic-mode)
- rattray 10y agoCan anyone explain how this works?
- marknadal 10y agoWow, this is an excellent README if I have ever seen one. And the project is most excellent as well. Great work.
- guptaneil 10y agoHmm this example is interesting: nlp.person("Tony Hawk").pronoun(); // 'he' I was curious how it handled gender neutral names, since being able to identify gender from a name would be an awesome UX win. I tried a variety of different names, and for gender neutral names (ie "Alex" or "Taylor"), it always picked "he". If it doesn't recognize the name (ie "Alexa"), it returns "they". Unfortunately, it only recognizes very standard American names. Anything remotely ethnic (ie "Anjali") or slightly uncommon (ie "Nate") results in a "they". Not picking on the library, since this would be an impossible task even for a human, but it seems odd to have used pronoun identification as one of the headline examples. Anyway, awesome library overall. This could pair well with a dedicated date parsing library like Sherlock[1] to create some pretty cool conversational UI elements. 1: https://github.com/neilgupta/sherlock https://github.com/neilgupta/sherlock
- daleharvey 10y ago"since being able to identify gender from a name would be an awesome " Way to misgender and insult a number of your users. As you said it is an impossible task and the result is telling "for gender neutral names (ie "Alex" or "Taylor")," The best way is to not care, it almost never matters, and when it does, ask.
- guptaneil 10y agoTotally agree, that was poor phrasing on my part. I meant if it was theoretically possible somehow, it would be awesome, but agree that it is impossible even if the name "Tony". I think this issue on the nlp-compromise project sums it up nicely: https://github.com/nlp-compromise/nlp_compromise/issues/117 https://github.com/nlp-compromise/nlp_compromise/issues/117
- komali2 10y agoI find this absurd. This is natural language processing. What do languages have? Gendered pronouns. Some languages have gendered nouns. We use language to communicate information about our environment. Whether or not someone is male or female may be irrelevant to how they perform in certain tasks, ie, don't judge someone by their race/gender obviously. However, purposely crippling a natural language processor by removing its ability to use language to determine gender is insanity.
- 0b01 10y agoTitle is misleading clickbait. Should be 'to process natural language.' or a cool way to use NLP.
- MrBra 10y agoWow, and why exactly did this make into HN first page? Because it's Javascript?
- MrBra 10y agoExplain the downvotes, anyone? Any good reason this is on the front page, other that: Google made JS faster > Google made their NLP library SyntaxNet open-source > NLP_compromise is a NLP JS library so it has to be top news ? How this library can even appear to be anything new? Have you never explored the NLP field? I guess downvoters never did, I have to other way to understand it.
- cskau 10y agoFrom the HN guidelines: Please don't submit comments complaining that a submission is inappropriate for the site. If you think a story is spam or off-topic, flag it by clicking on its "flag" link. (Not all users will see this; there is a karma threshold.) If you think a comment is egregious, click on its timestamp to go to its page, then click "flag" at the top. Also: Please resist commenting about being downvoted. It never does any good, and it makes boring reading. Please read: https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- MrBra 10y ago> Please don't submit comments complaining that a submission is inappropriate for the site. I never did. I was just questioning on the popularity it got on HN, not on it being inappropriate. > Please resist commenting about being downvoted. Ok, I apologize for that. My mistake. But hey, may I know the reasons why do you think that my opinion is wrong, anyone, and specifically you @cskau, if you do? Eagerly waiting for it but I fear I'll receive no on-context answers :(
- mcbits 10y agoI will speculate: 1. JavaScript is widely known and used. Thus, anything JavaScript attracts more attention than similar projects in other languages, especially if it's outside the box of the usual webby stuff. 2. The API on this library looks very intuitive and utilitarian. It doesn't get much easier than .people(), .topics(), etc. People can see themselves actually using this.
- 58028641 10y agoInstead of trying to train computers to parse our langueges, why don't we improve our languages so that they are unambigious and each word has one meaning and each meaning only has one word. If only there was one universal language that had no exceptions.
- wetmore 10y agoSounds much harder than training computers to me.
- djtriptych 10y agoMissing spec: ...and retrain 8 billion people to use the language
- xaduha 10y agoWell there is Ithkuil. Not exactly an easy language.
- kybernetikos 10y agoThere are constructed languages like that. Lojban is supposed to aim for no ambiguity, I believe that Ithkuil does too. However, it's very hard to allow abstraction without ambiguity. It might be best to think of ambiguity as a form of lossy compression, since it allows us to skip a bunch of thinking and words to say what we want to. Supposedly the creator of Ithkuil has to think for half an hour to get exactly the right word. On top of that, we also use ambiguity for humor and colour. A new humor culture had to grow in Lojban, because typical puns and the like didn't translate. I've grown more interested recently in languages that embrace ambiguity, such as toki pona. With a language like that, you can shrink the necessary vocabulary down to a tiny number of words meaning that nonspecialists can learn the language in a short period of time. Aiming for ease of acquisition seems like the right approach for a constructed language that aims to be practically useful.
- fizzbatter 10y agoAnyone know of any good Rust libraries in the NLP landscape? It seems quite dead in Rust. Only partial libraries, and non-compilable libraries.
- MrBra 10y agoWhat's so cool about this in a way it hasn't been cool before?
- pknerd 10y agoIs there something similar available for PHP || Python?
- gcr 10y agoThis could be great for foreign language learners! Imagine integrating this into Anki: "Please negate this sentence", "Please turn this sentence into past tense", "What's the direct object", and so on. Perhaps "this sentence" could refer to some interesting sentence from an article that you read in Pocket last week, for example!