|
From: Robert K. <cr...@al...> - 2003-09-28 10:40:06
|
Hey all,
Now that I've got myself a really useful classify(), which reports the
winning file (thanks for that, Bill!), I'm facing another small problem:
converting the winning number to an actual filename.
At the moment, my code for this looks like this:
# get filenames
isolate (:FILES:)
syscall () (:FILES:) /ls -1 :*:_env_CSSBASE:\/*.css/
# classify message against each file
isolate (:stats:)
{
classify <nocase> (:*:FILES:) (:stats:) [:message:] /:*:lcr:/
}
{
match (:dummy: :winningIndex:) [:stats:] /Best match to file #([[:digit:]]+)/
isolate (:winningFile:)
syscall (:*:FILES:) (:winningFile:) /head -$((1 + :*:winningIndex:)) | tail -1/
}
Notice the shelltrickery '$(( 1 + ... ))' to convert 0-based to 1-based.
Would it be too much of a problem to put the winning file's name in :stats:
somewhere?
Also, on a somewhat different note: are there any people interested in
a VIM 6 syntax file for .crm files? I've hacked one up, and it's quite
usable.
robert
|