Version 0 of Natural Language Processing with FreeLing

Updated 2016-07-11 20:10:33 by zashi

I have not been able to find any ready-made interfaces/libraries for doing Natural Language Processing (NLP) with Tcl.

Luckily, FreeLing is a pretty complete NLP pipeline and comes with a binary executable for interfacing with the library that makes writing a simple Tcl interface very easy:

This requires tcllib for the json module.

package require json

proc freeling_analyze {text} {
    set fl_fh [open "|fl_analyze -f /usr/share/freeling/config/en.cfg --output json --outlv dep" r+]
    puts $fl_fh $text
    chan close $fl_fh write
    set data [read $fl_fh]
    return [json::json2dict $data]
}

Set your desired options within the open command. Your freeling binary maybe named analyze rather than fl_analyze.

Sample usage:

set dep [freeling_analyze {The quick brown fox jumps over the lazy dog}]

puts $dep ;# dump dict of json output