add comments on what we should be doing
This commit is contained in:
parent
ea0de2f4d2
commit
febc14be32
2 changed files with 20 additions and 2 deletions
17
src/main.zig
17
src/main.zig
|
@ -321,6 +321,23 @@ fn processCommand(allocator: std.mem.Allocator, sentence: [:0]const u8, parser:
|
|||
};
|
||||
defer tree.deinit();
|
||||
|
||||
// Bracketed words are "null"
|
||||
// words with [?] are "unknown"
|
||||
// If we have unknowns, I think we want to replace (or if no replacement
|
||||
// is available, strip) them. Then re-parse immediately, because we're
|
||||
// in a bad enough state that we might screw something else up
|
||||
//
|
||||
// If there are nulls, then we should walk those nulls and look for
|
||||
// replacement values. If any replacements have been performed, then
|
||||
// try re-parsing at that point.
|
||||
//
|
||||
// This might all be best done in the library itself. Pass in the
|
||||
// map of replacement words and let it churn.
|
||||
//
|
||||
// For null words, I think we can use this replacement loop
|
||||
// if (tree.hasUnknowns()) // then what?
|
||||
// {}
|
||||
|
||||
const action_words = tree.sentenceAction() catch |err| {
|
||||
if (!builtin.is_test)
|
||||
std.log.err("Failed to extract action: {}\nParse tree: {f}", .{ err, tree });
|
||||
|
|
|
@ -151,8 +151,9 @@ pub const ParseTree = struct {
|
|||
node = node.child.?;
|
||||
|
||||
// We need the next node, which should be our PP node
|
||||
if (node.next == null) @panic("VP node must have a child with two members");
|
||||
node = node.next.?;
|
||||
if (node.next == null) @panic("VP node must have a child with at least two members");
|
||||
while (node.next != null) // fast forward to the very last node at this level
|
||||
node = node.next.?;
|
||||
|
||||
// https://opencog.github.io/link-grammar-website/dict/section-PP.html
|
||||
if (!std.mem.startsWith(u8, node.label, "PP"))
|
||||
|
|
Loading…
Add table
Reference in a new issue