diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/leven.c | 14 | ||||
| -rw-r--r-- | src/parse.c | 10 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/leven.c b/src/leven.c index 9ed2ab3..f060929 100644 --- a/src/leven.c +++ b/src/leven.c @@ -176,8 +176,10 @@ void constrained_tree_alignment ( const mat_uint32_t cost, const mat_uint32_t cost_n, // The resulting computed cost matrixes node and forest. Size a.len x b.len const mat_uint32_t cost_f, + // Scratch space mat_uint32_t cost_s, uint32_t *adj_alignment, + mat_uint32_t alignment ) { @@ -198,7 +200,7 @@ void constrained_tree_alignment ( size_t remain = 1; size_t cursor = j-1; while(remain > 0) { - log("ADD %ld", cursor); + log("ADD %ld", cursor+1); size_t adj_len = 0; while(adj_len < b.adj.stride && *imat_nid(b.adj, adj_len, cursor) != 0) adj_len++; @@ -212,7 +214,7 @@ void constrained_tree_alignment ( size_t remain = 1; size_t cursor = i-1; while(remain > 0) { - log("REMOVE %ld", cursor); + log("REMOVE %ld", cursor+1); size_t adj_len = 0; while(adj_len < a.adj.stride && *imat_nid(a.adj, adj_len, cursor) != 0) adj_len++; @@ -293,6 +295,14 @@ void constrained_tree_alignment ( b_cursor--; a_cursor--; } + + while(a_cursor >= 0) { + uint32_t *slot = imat_uint32_t(to_compute, 0, to_compute_head); + to_compute_head++; + slot[0] = *imat_nid(a.adj, a_cursor, i-1); + slot[1] = -1; + a_cursor--; + } } else if(a_adj_len > 0 && *imat_uint32_t(cost_n, i, j) == *imat_uint32_t(cost_n, i, 0) + min_cost_a) { // Remove this node and replace it with one of its children log("REMOVE %ld %ld", i, j); diff --git a/src/parse.c b/src/parse.c index 6ab2007..31a93a6 100644 --- a/src/parse.c +++ b/src/parse.c @@ -5,6 +5,7 @@ #include <ctype.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "log.h" @@ -31,6 +32,10 @@ static bool alnum(struct ParseCtx *ctx) { return isalnum(ctx->cursor[0]); } +static bool wspace(struct ParseCtx *ctx) { + return strchr(" \n\t", ctx->cursor[0]) != NULL; +} + static int read_STag(struct ParseCtx *ctx, bool *self_close, size_t nodeId) { // Record start position of the tag if (ctx->phase == PHASE_BUILD) { @@ -40,7 +45,8 @@ static int read_STag(struct ParseCtx *ctx, bool *self_close, size_t nodeId) { if(*ctx->cursor != '<') return 1; ctx->cursor++; - while(isalnum(*ctx->cursor) || *ctx->cursor == ' ' || *ctx->cursor == '"' || *ctx->cursor == '=') ctx->cursor++; + // @COMP Does xml allow all whitespace in the tag? + while(alnum(ctx) || *ctx->cursor == ' ' || *ctx->cursor == '"' || *ctx->cursor == '=') ctx->cursor++; // Check for self-closing tag if(*ctx->cursor == '/') { @@ -70,7 +76,7 @@ static int read_Content(struct ParseCtx *ctx, size_t nodeId) { *imat_nid(ctx->tree->adj, children, nodeId) = childId+1; children++; - } else if(alnum(ctx)) { + } else if(alnum(ctx) || wspace(ctx)) { ctx->cursor++; } else { break; |
