1

I have a big text file which contains many English words. However it contains German and French words as well. I need to capture all English words in it.

I reckon, firstly I read all file from the disk and convert it into an array, second I match the all words against unix English word dictionary like here, yet it is not a good solution because of the size of each file. If I do in that way, complexity will be high, and I don't want that.

Do you have any idea how I can do it with Ruby in a simple way?

4

1 に答える 1

1

最初にできることは、英語の辞書を(配列ではなく)セットに入れることです。このように、ルックアップは O(1) であり、全体的な複雑さは O(NxM) ではなく O(N) です。

于 2013-04-04T07:56:01.667 に答える