Sunday 17 February 2013

Literally Vikings

One thing that quite a lot of people get annoyed about is using "literally" to mean "figuratively". Fortunately, these Vikings know how to use the word correctly.

Watch "Horrible Histories - Literally: The Viking Song" on YouTube

(Of course, they're not literally Vikings. They're really actors playing Vikings in Horrible Histories, but you knew that, didn't you?)

I'm off to York for a few days, and it just happens that the Viking Festival is on, so I might post some more Viking-related stuff.

Wednesday 13 February 2013

Whosoever shall draw…

My DVD player broke down, and I had to take it apart to retrieve a disc that was stuck in it.

It turned out to be The Sword In The Stone

Saturday 9 February 2013

Custom Sorting For Conlangs again

I've just revised that Python code I posted a while back for sorting lists of strings in customized alphabetical orders. I realized that it would be more efficient to implement it as a key function (which is evaluated once per item) rather than a cmp funtion (which is evaluated for each pair of items). Fortunately Python compares lists in a similar way to strings, thus making it possible.
 class CustomSorter(object):
    def __init__(self,alphabet):
        self.alphabet=alphabet

    def __call__(self,word):
        head,tail=self.separate(word1)
        key=[self.alphabet.index(head1)]
        if len(tail):
            key.extend(self(tail))
        return key

    def separate(self,word):
        candidates=self.Candidates(word)
        while candidates==[]:
            word=word[1:]
            candidates=self.Candidates(word)
        candidates.sort(key=len)
        head=candidates.pop()
        tail=word[len(head):]
        return head,tail

        def Candidates(self,word):
            return [letter for letter in self.alphabet if word.startswith(letter)]