A blog and website by Peter Bengtsson

Filtered home page!
Currently only showing blog entries under the category: Misc. links. Clear filter

How to identify/classify what language a piece of text is

09 August 2016 0 comments   Python, Misc. links

Suppose you have a piece of text but you don't know what language it is. If you speak English and the text looks English, it's easy. But what about "Den snabba bruna räven hoppar över den lata hunden" or "haraka kahawia mbweha anaruka juu ya mbwa wavivu" or "A ligeira raposa marrom ataca o cão preguiçoso"? Can you guess?

MeaningCloud can guess. They have a Language Identification API that you can use for free. Their freemium plan allows for 40,000 API requests per month.

So to get started, you have to register, verify your email and sig in to get your "license key". Now when you have that you simply use it like this:

>>> import requests
>>> url = ''
>>> payload={'key': '',
... 'txt': 'Den snabba bruna räven hoppar över den lata hunden'}
>>>, data=payload).json()
{'status': {'remaining_credits': '39999', 'credits': '1', 'msg': 'OK', 'code': '0'}, 'lang_list': ['sv', 'da', 'no', 'es']}

If you look at the lang_list list, the first one is sv for Swedish.

If you want the full name of a language code, look it up in the "ISO 639-1 Code" table.

Let's do the other ones too:

>>> payload['txt'] = 'A ligeira raposa marrom ataca o cão preguiçoso'
>>> # Portugese
>>>, data=payload).json()
{'status': {'remaining_credits': '39998', 'credits': '1', 'msg': 'OK', 'code': '0'}, 'lang_list': ['pt', 'ro']}
>>> payload['txt'] = 'haraka kahawia mbweha anaruka juu ya mbwa wavivu'
>>> # Swahili
>>>, data=payload).json()
{'status': {'remaining_credits': '37363', 'credits': '1', 'msg': 'OK', 'code': '0'}, 'lang_list': ['sw']}

The service isn't perfect. It struggles on shorter texts using non-western alphabet. But it's pretty easy to use and delivers pretty good results.


Note! If you intend to do this in bulk and you have access to Python and NLTK use this script instead.

I tried it on my nltk install and I have 14 languages that it can detect.


A much better solution than NLTK is guess_language-spirit. It's superfast and I spotchecked a bunch of its outputs and put the non-English text into Google Translate and a it almost always gets it right.

Newsletters I enjoy for work

03 March 2015 0 comments   Misc. links

I'm a web engineer (aka. web developer) and I try my best to keep up with the latest and greatest in my field without minimal effort. I need good resources that pack a big bunch but doesn't take all day to digest.

Here are the newsletters I enjoy and almost depend on for my work (in no particular order):

  1. ng-newsletter
    "The free, weekly newsletter of the best AngularJS content on the web." Comes once a week with about 5 or so links to articles about AngularJS.

  2. Pycoder's Weekly
    "Your weekly dose of all things Python!" A mix of recent new projects that have become available on PyPI or GitHub. Also always a nice list of 3-6 articles revolving around Python.

  3. Web Development Reading List
    "A handcrafted, carefully selected list of web development related resources." Topics are usually split up by News, Generic/Tools, Web Performance, HTML/SVG, Javascript and CSS/Sass. Very high quality despite there being lots of links.

  4. The Changelog Weekly
    "Open Source moves fast. Keep up." They have a podcast too which comes out, I think, once a week too. The topics here are highly technical but often more broader and rather "about the tech" as opposed to "how the tech". They have a crips separation of curated content and sponsored content.

  5. Go Newsletter
    "A weekly newsletter about the Go programming language" This one I'm quite new to. It's jampacked with links to projects and articles.

  6. Explore GitHub
    It's configurable. I have it sent to me on a weekly basis. I get two sections "Trending repositories this week" and "Starred by people you follow this week". It's basically just links to GitHub projects. No articles or curated content. I guess it's maybe not a newsletter but it's so useful that I just have to include it.

Which ones do you depend on/love that I should consider?

My favorite YouTube channels

11 March 2014 0 comments   Misc. links

I do not deny it. I'm a YouTube fiend. I very rarely watch YouTube on my computer but a lot on my Apple TV and only tablet. It's

Here are some of my favorite YouTube channels that I subscribe to and encourage you to do the same if you aren't already and if there's something it appears you'll like too.


1. MinutePhysics

They started as clips that were around 1 minute but are now of variable length. I just adore Henry's voice and the topics he chooses. The animations are cute and even though seasoned with silly cat and dog references they really help to explain some of the most advanced subjects in physics.

Incidentally, this was the first channel I subscribed to once I figured that's the best way to get recurring content from channels I really liked.


2. Numberphile

This is a Brady Haran production that speaks directly to my mathematical aspirations. These aspirations aren't to solve any complex calculus problems but to keep that almost mystic infatuation alive I have with mathematics. There's something wonderfully down to earth and kind about the content which challenge you without patronizing you. By the way, my favorite interviewee, James Grime has his own channel now called singingbanana and also, by the way, and amazingly unattractive website.


3. Veritasium

Derek Muller is a brilliant video maker. Most of his videos are about science and it's mainly Derek holding his camera at arms length filming his pleasant face and talking about the perception or understanding of science. More so than the science itself. Actually some videos are not about how people (miss)understand science but speak directly to you and those are just brilliant. Usually sufficiently advanced to really get reallying thinking hard.

CGP Grey

4. CGP Grey

The only, of my top favorite channels, that is not about natural science. These videos are on social science subjects you might never have thought to think about and not only that, but each and every one digs deep and misses very few facts. Similarly to SciShow, these videos require your full attention. Because what you learn from them is often so very valuable, I've revisited many videos. Some more than twice.


5. MinuteEarth

This is Henry Reich's (see above about MinutePhysics) second channel and the name of the channels fully describes what the videos are about. The animations are really magnificantly simple and rich at the same time. The subject matters in this videos are generally less advanced that those in MinutePhysics but often full of really interesting factoids to keep up your sleeve for dinner parties.


6. SciShow

Hang Green is a gem! His geeky and passionate mannerisms is worth it just on its own. But you have to pay full attention because Hank speaks very fast. There is though an important undertone that isn't immediately obvious. There is this feeling of deeply researched facts. Even though you only understand a small part of it all (not to mention how little you remember!) it's inspiring that someone takes the time to do all the research.
A lot of subject matters are science oriented but more popular sciencey.

Sixty Symbols

7. Sixty Symbols

Another Brady Haran production, but this time more about physics and than Numberphile which is more about mathematics. Almost all videos are Brady interviewing doctors and professors in physics at the University of Nottingham. All very humble and approachable interviewees that, perhaps thanks to Brady's brilliant questions, the subjects are understandable but also very exciting because they're usually on matters that are very advanced and something more to look forward to than to enjoy in the moment.

PHD Comics

8. Piled Higher and Deeper (PHD Comics)

This is a newcomer and I include it because they're of such high quality and adorable animations. To be honest I don't think I really understand what the various videos have in common. For example, one recent video is on quantum entanglement and another on the Dead Sea scrolls. Either way, every video is professional and highly enjoyable.

There are more channels I subscribe to and enjoy very much but the above list are my favorite ones. For example, I watch Jamie Oliver's Food Tube videos just as often but that's somehow more "obvious".

Actually I have many more channels on science and a bunch of computers and programming but I'm just simply not as passionate about them as I are with the channels mentioned above.

I really hope that by writing this it will inspire one or two fellow science nerdy readers to also discover some of the channels mentioned here.

Beach volleyball bums

02 August 2012 2 comments   Misc. links

My good friend @jonanmary brought this very amusing tweet to my attention:

I know you've all seen this, but it's awesome anyway: Photographing other sports like beach volleyball


That's brilliant! The thing is, if you didn't already know it, beach volleyball gals are mandated to wear those speedos looking things they wear. What's even more funny is something another good friend, @trollkip on twitter point:

@jonanmary @peterbe out of interest, earlier, I looked up who makes these rules. Governing body: Yeah.


Apparently, the rule about what beach volleyball players have to wear changed recently
I love me some tanned sexy lady-skin but don't be an asshole about it. Let her choose.

Cateechee golf pictures

27 September 2011 0 comments   Misc. links

Cateechee golf pictures My friend Josh Ziff has uploaded pictures from the little golf tournament (we played scrambles) at Cateechee in Hartwell, Georgia a couple of weeks ago.

Check out the pictures here

Chinese tea sampler pack now on sale

16 June 2011 0 comments   Misc. links

Chinese tea sampler pack now on sale My good friend Chris who runs the Min River Tea Farm has this week launched a new product: Sampler Pack Chinese tea

This is brilliant because if you, like me, love some good green teas but don't want to buy a whole bag yet, then get a cute little sampler and decide which of his teas you like the most. Or, for £9 you can buy a couple of these cute little tubs and give away as gifts. That's what I'm going to do.

At the moment you have to be in Europe to be able to order these (delivery done by Amazon UK) but if you're outside of Europe ping them and ask if something can be arrange.

Google teething problems still with duplicated content

03 June 2011 0 comments   Misc. links

Google teething problems still with duplicated content Since Google doesn't really have a bug tracker where I can report bugs I blog about it instead.

Here's a typical example that Google's strife to get rid of duplicate content still needs some work. About 10 different mailing list archive sites have indexed the same email thread. Not very helpful.

I just ordered tea from the Min River Tea Farm

27 February 2011 0 comments   Misc. links

I just ordered tea from the Min River Tea Farm I just ordered myself one bag of Jasmine Pearls from The Min River Tea Farm that my friend Chris has recently launched.

As soon as I get my tea I'm going to take a picture of myself drinking it and send in my pic so that £1 gets donated, by Chris, to the Mind UK charity.

If you live in the UK and love genuine sourced Chinese teas do check it out. The ordering process is lovingly easy and safe. Although I'm an Earl Grey fan myself, I love having some good jasmine tea available at home without having to worry about the caffeine in Earl Grey tea keeping me awake.

Best of luck to Chris and his new site! Please take the time to browse and read about his teas. If you're outside the UK and you want a bag, just send him and email.

Worst Flash site of the year 2010

08 November 2010 2 comments   Misc. links

Worst Flash site of the year 2010 If you ever wonder, how do I make a website that is just wrong on every front: Turn up your volume and tune into Oh yeaaaahhh...

It's got it all.

I just discovered wikiHow

08 September 2010 0 comments   Misc. links

I just discovered wikiHow I can't believe I haven't seen this before. wikiHow is a great site. Just look at this article about how to spice up waffles for example.

Interestingly though, gone are the days of surfing. People don't take what's offered, they take what the search for. However, with wikiHow I'm eager to pop back in, throw a few articles on my Instapaper and then read them later on my Kindle.

Now I'm going to read about How to Be a Slacker Mom. Very relevant.