Sunday, April 28, 2013

Google is reading my (Japanese) mind

Is anyone else seeing Japanese ads on YouTube? I don't mean a YouTube video of a Japanese ad*. I'm actually getting Japanese ads (given the previous link, ironically) for the Japanese coffee brand Georgia (a Coca cola brand).

At first, I thought that maybe YouTube has erroneously got my language as Japanese, but no, its still English. OK, and I still get English ads too. And to top it all, the Japanese ad preceded an English video...

My guess right now is that it has something to do with my posting Japanese into a video I uploaded**, which apart from having a Japanese title, also has Japanese in the subtitles and description (it took far more work than it was worth to make that).

So, of course, YouTube isn't reading my mind, but it damn well feels like it sometimes. I'm kind of impressed that Google's system can (to some degree) be aware of my fluency in Japanese***. On the other hand that is seriously wasteful advertising, given that I'd have to be really, really determined to get hold of that coffee over here... And anyway, my loyalty is with Boss, and that has nothing to do with the taste!

*Gotta love Tommy Lee Jones

** its completely irrelevant here, but here's a link if you're that inquisitive...

*** Or this is happening to everyone, and I don't know it yet. Or it really is a bug.

Saturday, April 27, 2013

Heroes of Imperial Japan?

So, I was thinking earlier in the week about the apparent tendency for Japan to brush the evils of World War II under the carpet, and wondering about the lack of Japanese war heroes.

When I say Japanese war heroes, I don't mean "inflicted n amount of damage on his adversary", what I'm thinking of is Japanese people who risked their lives to stand against the evils of Imperial Japan, first hand.

Doing a Google search on "Japanese world war 2 heroes" doesn't really return a lot, and requires some filtering because it turns out there were lots of Japanese american war heroes. Moreover, since they were almost all military this kind of "heroism" tends to fall under the "inflicted n amount of damage on his adversary" kind of heroism.

Perhaps the problem here is that I'm imagining some sort of Oscar Schindler character; an ordinary person who rises above his surroundings, transcending the pragmatism of his character to keep the dark at bay...

But then again, why shouldn't there be someone like that in Imperial Japan? The Japanese are equally capable of doing good, example: Chiune Sugihara. But while he opposed Japan's actions in Manchuria, he didn't help there in the same way he saved lives in Lithuania. That said, the work he did in Lithuania was spectacular, that link is really worth the read.

Trying a different tact, I tried to find out who Imperial Japan's domestic enemies were. Being a highly militaristic society in WW2, I reasoned that the kind of people getting tried for treason were probably the same people trying to stop Japan's aggression in China.

As it turns out, I had more success than I'd expected with that train of thought, and pulled up the name Sanzo Nosaka. Nosaka heavily criticised Japan's involvement in China, and even went so far as to help setting up a spy network in Japanese-occupied China. The idea of heralding this man as a hero seemed not too far off, until reading that he effectively had his (adulterous) friend murdered. Then there are his links with Stalin's regime... Hmm, perhaps not a brilliant example after all.

But if nothing else, this did introduce me to the fact the Japan's (underground) communist party was opposed to Japan's role in China, and supported the independence of Japan's overseas colonies.

I'm not overly keen on communism myself, it reeks of schoolboy naivety that somehow that 1% of greedy people will stop seeking power (what I like to think of as "floater" politics*), or that the greediness inherent in all of us will just disappear with a change of government. However, it is somehow endearing, and the thought of a hero that wants everyone to be equal in society is poetic, if nothing else.

*Yes, its toilet humour!

Friday, April 26, 2013

Atmospheric effects in openGL

And now for some programming...

Long story short:

Here is a technique for drawing an atmosphere, which is especially useful if you want something that is quick but you're not planning on the camera moving around. Enjoy.

Anyway, some considerable time ago I wrote about making the world in 7 days using openGL and java. Of course, in reality, I'd only synthesised a tiny region, not even the size of an English county... What I'd really love is to have a whole planet to look down on.

Actually, this is a much, much simpler task, so long as you don't want to visit anywhere on the surface, as from 300km up, everything looks flat anyway (approximately).

The real trick to making a planet look lovely is the atmosphere (and bump mapping*).

Lately I've been using libGDX for my graphical work (I'm a softy for portability, and when I adopted it, it was probably the most portable graphics library around), but hopefully what I attempt here will be fairly universal.

The basic layout for me is like this:

1)Earth = sphere with earth texture in centre of screen
2)Starmap = sphere centred on camera with star texture
3)Clouds = sphere surrounding earth with cloud texture
4)Atmosphere = cone extending from the horizon of sphere (1) to behind the camera

And now for a pretty diagram:

... What can I say... I'm a biologist.

Long story short, the key is to have the cone completely transparent, but draw it with fog. You end up with something that looks a bit like this:

Which is (I think) a reasonable approximation of Earth from ~300 km up. OK, so this is a bit hacky, but it is really quick and conceptually simple**.

If you want more detail, here are the components in more detail:


Since I personally never plan to leave orbit, instead of using a sphere, I've cheated and used a convex shape to reduce the number of triangles rendered. Thus, instead of having a sphere rotating, I've had to move the texture coordinates instead. But honestly, that is simple enough. It also means that I don't need to have the whole earth texture loaded into memory, I only have a thin strip for a texture that corresponds to the area over which the viewpoint travels, assuming that I always pass the same terrain***.

I use a night (city lights) texture too, which is only visible when the sun starts sinking below the horizon.


You can't see it so well in the screenshot, but at night I make the stars more vivid by increasing the brightness. The stars are another NASA freebie (I love NASA). There's not much else to say here


Just a png texture of clouds mapped onto another convex shape with a slightly different speed of rotation, so that the same area isn't always covered by the same clouds.


As mentioned earlier, the atmosphere is just a transparent cone that extends from behind the camera to the horizon. To make it appear as the atmosphere all you do is enable fog, then draw the cone. Finally, you draw the planet in front of all that.

The density of the atmosphere can be changed by modifying the opengl fog density/fog start parameters.

If I recall correctly, the draw order was important: stars, then atmosphere cone, then planet.

Of course there are major caveats with this method:
1) if the camera moves relative to the planet, the cone has to distort accordingly
2) if the camera moves, the fog density/fog start parameters must be adapted otherwise the atmosphere will appear to grow as you move away from the planet

Which is one reason why I haven't bothered allowing the camera to move! But it makes a lovely background ;)

*Sorry, I won't be discussing bump mapping as I don't use it yet. I have reasons for this, but I advise that you use bump mapping if you can, because it looks great! But anyway, bump mapping is a fairly standard practice nowadays (here's what google thinks is the best site on the matter, but because I'm too busy to see if it actually is, here is what it thinks is the second best site on the matter. In the very least I've used NeHe's site before, and liked it...)

**Bearing in mind this is all designed to run on mobile phones...

***Yes, I've cheated and have my viewpoint make the impossible orbit along a constant longitude in the Northern hemisphere. I should have put the orbit around the equator. Sorry about that. I like the Northern hemisphere.

Thursday, April 25, 2013

Hanwriting reevaluation

Having used hanwriting for android a little more extensively, I've decided that its physical keyboard support is terrible after all. I was already dubious about it, but what really kills it for me is the way it provides suggestions.

For English, hanwriting's suggestions are OK, and although a bit fiddly, you can kind of get around stupid suggestions by simply dismissing them.

For Japanese however, you need the suggestions to convert your hiragana into kanji, and the only way to do this is to either accept the default suggestion, or physically press the kanji that you want to use. In other words, there is no way to select the kanji using a physical keyboard.

In essence this means that writing Japanese text will sound like "hack hack hack - tap - hack hack hack - tap - " etc. Not that the noise annoys me, its the constant flipping between typing and poking that I can't get used to. After all, once you've taken your fingers off the keyboard to poke the screen, you've got to get your hands back into the typing position by finding the F and J buttons, which somehow feels like a huge impediment to the fluidity to writing something.

For the sake of being able to actually write an email to my wife without going insane, hanwriting is no longer my default IME.

That said, if you spend much time looking up complicated Japanese characters, hanwriting still has its handy kanjipad.

EDIT: Got an email back from the developer, apparently the next version will be clear of these bugs! On the other hand, that means I might be obliged to write a rereevaluation post... I've really done it to death already.

Looking forward to that update though!

Wednesday, April 24, 2013

Forgetting the East Japan Earthquake

I was thinking the other day that you don't hear much about the East Japan Earthquake any more. This makes sense, in that as the immediate danger has subsided and other things happen in the world.

You can even graph the international sentiment ebbing away:

Above is a graph of UK google searches for "Japan earthquake". Below is the same for Japanese searches for "日本 地震":

You can see that, even in Japan, the public eye has wandered onto other issues a surprisingly comparable amount. Us people are great at forgetting about things, but the next time something like this happens, bear in mind that the situation is constantly unfolding, and when you remember it n years from now, it will still be unfolding. Remember that, and how lucky it was you weren't involved.

Monday, April 22, 2013

Ignoring Japanese war atrocities

Having read this news article about the recent visit of Japan's PM Shinzo Abe to the Yasukuni shrine, and the corresponding conversation with my dad, it reminded me of a strange conversation I had with my wife some time ago.

First, some context, if you're unfamiliar with the Yasukuni shrine, you should in the very least know that it houses the "spirits" of a number of World War II war criminals, I also recommend reading at least this section of the almighty wiki.

A year or two ago, I was watching the film "City of Life and Death" (or "Nanjing! Nanjing!"), on the recommendation of a Chinese friend. The film is centred on the life & death struggle of people caught in the infamous "Rape of Nanking".

My wife asked what I was watching, and I tried to explain it to her. I wasn't entirely surprised (considering the infamy of the Japanese history education) that she didn't seem to know what the Rape of Nanking was, so I explained that to her as well. To me, her response was astonishing:
"Yes, but you can't really know these things, since you weren't there"

To be honest, I was so taken aback by that response (and kind of still am) that I forget how I responded. I think the thing that surprises me most is that there is absolutely no reason at all anyone should come up with an answer like that. You can't simply "fake" a horror on the scale of the Rape of Nanking, but then how the hell do you respond to a statement like hers? Its not like I'm in a great position to start rummaging through the evidence and prove it to her, all I can do is say "I've read this and that", and explain that its the prevailing view of events through the rest of the world...

Having been to Germany and seen plaques honouring those who defied the Nazi regime, a kind of solemn celebration that even in the midst of a terrible regime there exist those willing to fight Evil. It seems very strange then, to see the Japanese brushing events under the carpet. Where are Schindler's lists of Japan?

The closest example I know of is Admiral Isoroku, but as much as he didn't want to go to war with America, he still masterminded a good deal of it... No. I don't have a good example, and it worries me that Japan doesn't seem to have it's own heroes who fought against the Evil of the Japanese Empire*.

If Japan isn't going to educate about its war atrocities, its people aren't going to understand properly why its neighbours are so cold towards them, and if they don't debate the Goods and Evils that occurred, what is to stop them making the same mistake in the future?**

*Although, my knowledge of Japanese history is still very lacking.

**Though I doubt things will escalate enough to really warrant this fear..

Saturday, April 20, 2013

Japanese kanji with Hanwriting, again

So, I've had a good long while playing with hanwriting  now, and I think its worth mentioning a couple of points:

First, a little tip on hard keyboards:
It can be annoying when using a hardware keyboard to type, when hanwriting decides to autocorrect the word you typed in (hanwriting will become "handwriting"). However, you can circumvent this problem by pressing an arrow key instead of the spacebar or punctuation, and this immediately dismisses the suggestions.

Secondly a new gripe of mine:
I've noticed that, despite hanwriting's superb ability at recognising complicated characters, there are some face-palmingly easy characters that it seems to have trouble with:

千 柔

perhaps unsurprisingly the first of those was quite easy in aedict's kanjipad, though there is something about the second one that I just can't seem to get right in either program.

Also, for a program that professes to be a handwriting app, its pretty appalling at hiragana.

That said, hanwriting is STILL my default IME at the moment; to me, the advantages still outweigh the drawbacks, and by a fair margin too.

Friday, April 19, 2013

Katanas: were they any good?

I've often spouted the virtues of the katana (just how I got into those conversations to start with is something of a puzzle, now I look back on it): the dedication of its craftsmen, the sharpness of its blade, and its ability to cut through all sorts of unlikely things...

However, apart from what I've heard on the TV and radio, it turns out I'm not really all that clued up on the "mighty" katana.

It wasn't until I happened upon this video that I realised the limits of my education in sword-crafting (which, as you might imagine, are very limited).

The guy makes some excellent points; most of the dirty-work on a Japanese battlefield would have been done with the spear or other weapons,  and the functional aspects of the craftsmanship that went into the swords was in no way unique to Japan.

The first point I should really have been aware of from Jansen's "The Making of Modern Japan", and other things I've read. As with Europe, technological advancements often came in the form "if we've got a longer spear than the enemy, we'll be able to hit them before they can hit us", and alongside firearms, the spear was a staple of weaponry as the warring kingdoms period drew to an end.

That said, I'm certain that if you're a foot soldier with a massive pike, and concentrating on hitting the enemy in front of you, several hundred men in heavy armour wielding katanas running into your flank is going to ruin your day.

What confuses me about historical Japanese warfare is the failure to adopt the shield. Even a katana is going to stop against a well made shield, and while you block the blow, you could be eyeing up your opponent for somewhere to stick your own short-sword. A quick search on internet forums suggests that the lack of shields was down to 1) lack of supply of metals, 2) the historic preference of samurai for horse archery [which kind of precluded the use of a shield], 3) the possible lack of honour associated with hiding behind a shield, 4) the Japanese armour plating, particularly on the shoulder (the sode), was functional as a small shield. 5) "shield? You must be referring to the peasants"

which of those reasons are actually relevant, I've no idea. number 4 seems somewhat dubious to me, as I've never seen a sode large enough to be really protective; there always seems to be an opening in the armour around the elbow joint. Plus how are you to deflect blows below your waist? You'd have to use your sword, which makes counter attacking more difficult...

That said, my weapons of choice would be the firearm with a katana as back up. Or, if I'm lucky the commander will decide to simply not fight.

EDIT: Oh, and for what its worth, I actually own a katana. Considering I only paid 70 quid for it, I'm guessing its not authentic, but it looks cool, and lets face it, that's the only reason you're going to own a sword these days... I hope...

Thursday, April 18, 2013

Japan Radio Review: FM Hirakata

So I mentioned some time back how I'd been fiddling with getting internet Radio working with Android, but I've also been doing some tinkering and made a website with links to live stations in japan. More on that another time, perhaps.

Principally I've been listening to FM Hirakata. My goal here is to learn Japanese while doing other things (usually work, programming or translating*).

FM Hirakata is a fairly good mix between talk and music, and here in the UK, my listening times often coincide with the Hirakata top 30, which generally airs from about 1pm GMT and again at around 7pm GMT, but check the link for the exact JST times if you're interested, as it varies.

You might be thinking that if you're keen on learning Japanese that picking a station so heavy on music isn't terribly helpful... To an extent, you'd be right, music is a terrible, terrible way of learning Japanese. Obscure language and concepts that you're almost never going to use in conversation litter music.

What I would argue (and this may well just go for me) is that I really can't passively take in that much Japanese in one go. After a few minutes my brain has completely blocked the radio out. Its at times like this I switch over to FM hirakata, and like pickled ginger cleansing the palate, my brain is able to take on Japanese again.

With that in mind, the fact that I find most J-pop pretty... Well, terrible... Doesn't really matter all that much. Though I can imagine there are lots of people out there who would be totally horrified by the idea of switching over to a Japanese chart show**. Then, I also quite like to have an idea of what is going on culturally in Japan, which also takes an edge off of it.

*You might be thinking that it is strange that I differentiate between "work" and "translating"... Ironically, the reason for this is that I get paid for freelance translating, whereas my "work" is my PhD, for which my funding has run out.. Nevertheless, I spend far more time on my PhD than translating.

**Indeed, even for me, the very mention of AKB48 is enough to warrant a scramble to change station, find the mute button, or failing that, run screaming from the room.

Wednesday, April 17, 2013

Handwriting with "Hanwriting"

Summary of hanwriting with multiling for the impatient:

  • handwriting function has very good specificity!
  • reasonable dictionaries
  • switching between languages is easy
  • some minor, infrequent bugs with inputing strokes
  • compatibility with hardware keyboards not that great
  • compatibility with hardware keyboards is terrible! (See edit)
  • setting up for the first time requires some patience (if you have the patience to read the rest of this article, I'm guessing you'll do fine, however)

The weather was lovely yesterday evening, so I used that as an excuse to go outside and open up "二十四の瞳" (or "24 eyes". Incidently, amazed that it was for sale on, thus I had the opportunity for a good play with Hanwriting yesterday, while translating the book.

That said, 二十四の瞳 isn't the hardest going of books, with most difficult words written in hiragana (its somewhat a refreshing change from Natsume Soseki's Bocchan, which had me stumped pretty much every couple of lines). And so it is that I didn't really get to test out hanwriting's kanji pad very much. However, I got a good feel for its other functionalities.

To start, let's talk hardware keyboards! I love my bluetooth keyboard, and use it more often than I use the software keyboard. However, multiling (which Hanwriting plugs into) is pretty poor at integrating it. Setting hardware keyboard to ON in the Android input method menu turns the software keyboard OFF. That's all fine and dandy, but there is no way of switching multiling's language quickly between English and Japanese when the software keyboard is off.

Fortunately there is a work-around (at least for my setup): I find that by turning the hardware keyboard OFF in the Android input method menu that I can still use the hardware keyboard, but because the software keyboard doesn't disappear, I can also swipe the software spacebar to change languages quickly. I'd still rather have a handy "あa" button like on Google's Japanese IME though...

I also found that set up was a bit arduous. Nothing too taxing, but it is necessary to download multiling, the Japanese plugin for multling and the hanwriting plugin, and I also decided I'd need the English dictionary plugin too... 4 packages to set up a keyboard? Seems a bit much, but then again, I think multiling needs this modularity. I did find, however that its best to install all those plugins BEFORE running the multiling program, or setting the keyboard to multiling, otherwise the plugins aren't recognised.

As for the dictionaries themselves, they don't appear to be as comprehensive as Google's (which are pretty spectacular, I think). However, I think the multiling dictionaries are passable.

In my opinion, these issues are all adequately offset by the handwriting function, which is really invaluable. Though it is worthwhile to be aware that (somewhat infrequently) the kanji pad will not recognise when your finger has moved, and the next time you press the kanji pad a straight line will be drawn from your finger to where your previous swipe started. This is pretty annoying, but you can usually tell it is about to happen, and just redo your last stroke.

Overall then, multiling & hanwriting has some pretty rough edges, but it is definitely functional, and I get the feeling that I will be using it extensively from now on.

EDIT [25/04/2013]: Having used this IME more extensively, I've come across some major usability issues, see here and here.

Tuesday, April 16, 2013

Android: Writing Japanese Characters (esp. Kanji)

Up until now I've not made much use of Nikolay Elenkov's Kanji Recognizer. I've had the general hunch that it was better than aedict's stock drawing recognition. However, since I primarily use the Japanese dictionary on the way to work, or otherwise wifi-less, I've not gotten much use out of Nikolay's WWWJDIC dictionary.

I'm not sure which recognition engine aedict uses, but Kanji Recognizer apparently uses the Zinnia engine with the Tomoe dataset, which is something that I've fiddled with in the past.

My hunch that Kanji Recognizer is superior has been kind of muted by the fact that with my old HTC Tattoo, changing applications was a bit tedious. Now I tend to use my Nexus 7 for translating (its so much faster!), which has a much quicker switch windows function, the idea of switching app every time I come across an annoying character doesn't put me off like it used to.

I thought I'd further test Kanji Recognizer by pitting it against aedict's drawing recognition. Using aedict as the benchmark (because I love that app), any character aedict failed to reproduce, I would attempt in Kanji Recognizer. Here is a list of some characters that Kanji Recognizer managed that aedict failed at*:

頸 腕 割 適 堅

OK, so that's not a particularly big list, which actually goes to show that aedict still fares pretty well, because I tested an awful lot of characters.

Now that I think about it, I also talked about an app called Hanwriting some time back. It was pretty awful for Japanese when I tried it, but it appears to have developed a lot since then. Now it is the hanwriting plugin integrated in the the multiling keyboard.

I tried all of the above characters without any trouble, and it even came up with some that neither aedict or Kanji Recognizer could manage*, such as 梟.

Since I've only just tried this, I'm not going to rave too much about how great that is, but it could be nice to have an IME like this that means I don't need to switch apps, and can stay in aedict for my dictionary needs, even when writing complicated characters. My first impression is good, but I also noticed that its significantly more difficult to draw characters in the smaller space they give you (though, of course, this is less of a problem now I'm using a Nexus 7).

Its nice to see such a broad range of support for Japanese getting well established on Android. I'm interested to see where it will all go from here!

*(or rather, I failed to input correctly into aedict that Kanji Recognizer identified regardless)

Monday, April 15, 2013

Japanese Radio & Android (AKA My Tattoo is Getting Old)

Lately I've been listening to a lot of Japanese radio. Not only does it alleviate some of the tedium of work, but it also helps improve my Japanese simultaneously. Brilliant.

Of course, support for doing this on Android is excellent. I believe I only downloaded a couple of programs before settling on TuneIn (that's not to say that TuneIn is the best... Just that it took me almost no time at all to find a decent internet radio program). The internet radio has a search function which can be very quickly used to identify Japanese radio stations (I primarily use FM Hirakata and BanBan Radio, perhaps a discussion for another time).

My rapidly ageing HTC Tattoo, however, was an altogether uglier case. The HTC Tattoo still runs Android 1.6, and virtually no one makes apps for it anymore (myself included, for the most part). I downloaded a variety of music players and other apps in the hope of simply being able to stream from the station's URL...

Eventually I settled on mediaU, which has all the functionality that I use with tuneIn (station search and favourites). It's a bit ugly, but it works on my elderly Tattoo, and that's good enough for me!

Unfortunately, I'd intended to use this set up to listen to the radio on the way to Southampton over the weekend, and didn't realise how much mobile network eats the Tattoo's battery (which, by the way, tends only to last a day after a couple of years of use). I think I got about 30 minutes of radio out of it before deciding that I'd best conserve the battery... But it was a good 30 minutes with only occasional cut-outs, and better quality that I'd expect considering I was travelling by car. This really is a testament to the stability of mediaU and the HTC Tattoo... And to some extent the network coverage Orange offer in Dorset...

Much as I've enjoyed my Tattoo over the last couple of years, it seems it is reaching the end of its useful life... Android 1.6 is becoming increasingly neglected by developers, and I wonder how long it will be before I lose some "critical" functionality like aedict.

That said, I'm more inclined to get a new battery than dispose of it. Then, perhaps when it finally does die, I'll frame it to show my grandchildren...

"Back when I was a young'n, we had to lug these bricks around! The batteries only lasted a coupl'o' days and you couldn't even plug them into your brain!"