You'll likely always be behind the curve with that kind of basic approach I think, wouldn't it make more sense to retrain a transformer to map all possible inputs to the few possible actions?
Zork was originally written in 1977 on a PDP-10, which had a ceiling of about one megabyte of memory; it was ported to microcomputers in three parts from 1980-1982, and had to fit into about 48k of RAM and 85-170k of disc space.
It is approximately forty-five years old. The curve has long since moved on.
Inform6 it's very powerful. You define the actions objects, and it does it very well by default. Objects have atributes (openable, stackable, decoration...lots of them) and you can even set the library messages on these actions after being done (or before).
http://www.penguincentral.com/retrocomputing/zdungeon/
Inform6+Inform6 lib:
http://jxself.org/git/inform http://jxself.org/git/informlib
Inform's Begginer's Guide:
https://rinform.org/docs/IBG.pdf
The advanced one, for advanced Inform programmers:
https://inform-fiction.org/manual/DM4.pdf
EDIT: I found no source for the ZDungeon port of it, but you can get the C version:
https://github.com/devshane/zork