Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tail pointer is not needed #1407

Merged
merged 3 commits into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/python/linkgrammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def new_init(self_, *args, **kwargs):
class ParseOptions(object):
@kwargs_only
def __init__(self, verbosity=0,
linkage_limit=100,
linkage_limit=1000,
min_null_count=0,
max_null_count=0,
islands_ok=False,
Expand Down
32 changes: 7 additions & 25 deletions link-grammar/parse/extract-links.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ struct Parse_choice_struct
* tracons l_id and r_id on words lw and rw, correspondingly. */
struct Parse_set_struct
{
Parse_choice *first;
Connector *le, *re;
uint8_t lw, rw; /* left and right word index */
uint8_t null_count; /* number of island words */
int32_t l_id, r_id; /* tracons on words lw, rw */
Connector *le, *re;

count_t count; /* The number of ways to parse. */
#ifdef RECOUNT
Expand All @@ -63,8 +64,6 @@ struct Parse_set_struct
#else
#define RECOUNT(X) /* Make it disappear... */
#endif
Parse_choice * first;
Parse_choice * tail;
};

typedef struct Pset_bucket_struct Pset_bucket;
Expand Down Expand Up @@ -116,32 +115,16 @@ make_choice(Parse_set *lset, Connector * lrc,
return pc;
}

/**
* Put this parse_choice into a given set. The tail pointer is always
* left pointing to the end of the list.
*/
static void put_choice_in_set(Parse_set *s, Parse_choice *pc)
{
if (s->first == NULL)
{
s->first = pc;
}
else
{
s->tail->next = pc;
}
s->tail = pc;
pc->next = NULL;
}

static void record_choice(
Parse_set *lset, Connector * lrc,
Parse_set *rset, Connector * rlc,
Disjunct *md, Parse_set *s, extractor_t* pex)
{
put_choice_in_set(s, make_choice(lset, lrc,
rset, rlc,
md, pex));
Parse_choice *pc = make_choice(lset, lrc, rset, rlc, md, pex);

// Chain it into the parse set.
pc->next = s->first;
s->first = pc;
}

/**
Expand Down Expand Up @@ -278,7 +261,6 @@ static Pset_bucket * x_table_store(int lw, int rw,
n->set.re = re;
n->set.count = 0;
n->set.first = NULL;
n->set.tail = NULL;

h = pair_hash(lw, rw, n->set.l_id, n->set.r_id, null_count);
t = &pex->x_table[h & (pex->x_table_size -1)];
Expand Down