Updated 2016-07-12 10:13:58 by dkf

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+]
    try {
        puts $fl_fh $text
        chan close $fl_fh write
        return [json::json2dict [read $fl_fh]]
    } finally {
        chan close $fl_fh

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