2020-12-13 01:08:32 +00:00
|
|
|
cimport libcpp
|
2023-06-14 15:48:41 +00:00
|
|
|
from cpython.exc cimport PyErr_CheckSignals, PyErr_SetFromErrno
|
|
|
|
from cython.operator cimport dereference as deref
|
|
|
|
from cython.operator cimport preincrement as incr
|
|
|
|
from libc.stdint cimport uint32_t, uint64_t
|
|
|
|
from libc.stdlib cimport calloc, free
|
|
|
|
from libc.string cimport memcpy, memset
|
|
|
|
from libcpp.set cimport set
|
2022-01-13 09:33:30 +00:00
|
|
|
from libcpp.unordered_map cimport unordered_map
|
2020-12-13 01:08:32 +00:00
|
|
|
from libcpp.vector cimport vector
|
2017-03-11 12:19:52 +00:00
|
|
|
from murmurhash.mrmr cimport hash64
|
|
|
|
|
2020-07-30 21:30:54 +00:00
|
|
|
from ...attrs cimport IS_SPACE
|
2023-06-14 15:48:41 +00:00
|
|
|
from ...lexeme cimport Lexeme
|
|
|
|
from ...structs cimport SpanC, TokenC
|
2020-07-30 21:30:54 +00:00
|
|
|
from ...typedefs cimport attr_t
|
2023-06-14 15:48:41 +00:00
|
|
|
from ...vocab cimport EMPTY_LEXEME
|
2016-02-01 00:09:21 +00:00
|
|
|
|
|
|
|
|
2016-04-13 13:28:28 +00:00
|
|
|
cdef inline bint is_space_token(const TokenC* token) nogil:
|
|
|
|
return Lexeme.c_check_flag(token.lex, IS_SPACE)
|
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef struct ArcC:
|
|
|
|
int head
|
|
|
|
int child
|
|
|
|
attr_t label
|
2017-10-03 10:43:48 +00:00
|
|
|
|
2016-04-13 13:28:28 +00:00
|
|
|
|
2016-02-01 00:09:21 +00:00
|
|
|
cdef cppclass StateC:
|
2020-12-13 01:08:32 +00:00
|
|
|
int* _heads
|
|
|
|
const TokenC* _sent
|
|
|
|
vector[int] _stack
|
|
|
|
vector[int] _rebuffer
|
|
|
|
vector[SpanC] _ents
|
2022-01-13 09:33:30 +00:00
|
|
|
unordered_map[int, vector[ArcC]] _left_arcs
|
|
|
|
unordered_map[int, vector[ArcC]] _right_arcs
|
2020-12-13 01:08:32 +00:00
|
|
|
vector[libcpp.bool] _unshiftable
|
|
|
|
set[int] _sent_starts
|
2016-02-01 00:09:21 +00:00
|
|
|
TokenC _empty_token
|
|
|
|
int length
|
2017-05-15 19:46:08 +00:00
|
|
|
int offset
|
2016-02-01 00:09:21 +00:00
|
|
|
int _b_i
|
|
|
|
|
|
|
|
__init__(const TokenC* sent, int length) nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
this._sent = sent
|
|
|
|
this._heads = <int*>calloc(length, sizeof(int))
|
|
|
|
if not (this._sent and this._heads):
|
2017-10-24 10:40:47 +00:00
|
|
|
with gil:
|
|
|
|
PyErr_SetFromErrno(MemoryError)
|
|
|
|
PyErr_CheckSignals()
|
2017-08-18 20:23:03 +00:00
|
|
|
this.offset = 0
|
2016-02-01 00:09:21 +00:00
|
|
|
this.length = length
|
|
|
|
this._b_i = 0
|
|
|
|
for i in range(length):
|
2020-12-13 01:08:32 +00:00
|
|
|
this._heads[i] = -1
|
|
|
|
this._unshiftable.push_back(0)
|
2016-02-06 12:34:38 +00:00
|
|
|
memset(&this._empty_token, 0, sizeof(TokenC))
|
2016-02-01 00:09:21 +00:00
|
|
|
this._empty_token.lex = &EMPTY_LEXEME
|
|
|
|
|
|
|
|
__dealloc__():
|
2020-12-13 01:08:32 +00:00
|
|
|
free(this._heads)
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2017-05-22 22:58:12 +00:00
|
|
|
void set_context_tokens(int* ids, int n) nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef int i, j
|
2019-11-19 14:03:14 +00:00
|
|
|
if n == 1:
|
|
|
|
if this.B(0) >= 0:
|
|
|
|
ids[0] = this.B(0)
|
|
|
|
else:
|
|
|
|
ids[0] = -1
|
|
|
|
elif n == 2:
|
2017-10-06 02:54:12 +00:00
|
|
|
ids[0] = this.B(0)
|
|
|
|
ids[1] = this.S(0)
|
2019-11-19 14:03:14 +00:00
|
|
|
elif n == 3:
|
|
|
|
if this.B(0) >= 0:
|
|
|
|
ids[0] = this.B(0)
|
|
|
|
else:
|
|
|
|
ids[0] = -1
|
|
|
|
# First word of entity, if any
|
|
|
|
if this.entity_is_open():
|
|
|
|
ids[1] = this.E(0)
|
|
|
|
else:
|
|
|
|
ids[1] = -1
|
|
|
|
# Last word of entity, if within entity
|
|
|
|
if ids[0] == -1 or ids[1] == -1:
|
|
|
|
ids[2] = -1
|
|
|
|
else:
|
|
|
|
ids[2] = ids[0] - 1
|
|
|
|
elif n == 8:
|
2017-08-18 20:38:59 +00:00
|
|
|
ids[0] = this.B(0)
|
|
|
|
ids[1] = this.B(1)
|
|
|
|
ids[2] = this.S(0)
|
|
|
|
ids[3] = this.S(1)
|
2018-03-27 17:23:02 +00:00
|
|
|
ids[4] = this.S(2)
|
2017-08-18 20:38:59 +00:00
|
|
|
ids[5] = this.L(this.B(0), 1)
|
2017-10-28 23:01:35 +00:00
|
|
|
ids[6] = this.L(this.S(0), 1)
|
2017-08-18 20:38:59 +00:00
|
|
|
ids[7] = this.R(this.S(0), 1)
|
|
|
|
elif n == 13:
|
2017-05-22 22:58:12 +00:00
|
|
|
ids[0] = this.B(0)
|
|
|
|
ids[1] = this.B(1)
|
|
|
|
ids[2] = this.S(0)
|
|
|
|
ids[3] = this.S(1)
|
|
|
|
ids[4] = this.S(2)
|
|
|
|
ids[5] = this.L(this.S(0), 1)
|
|
|
|
ids[6] = this.L(this.S(0), 2)
|
|
|
|
ids[6] = this.R(this.S(0), 1)
|
|
|
|
ids[7] = this.L(this.B(0), 1)
|
|
|
|
ids[8] = this.R(this.S(0), 2)
|
|
|
|
ids[9] = this.L(this.S(1), 1)
|
|
|
|
ids[10] = this.L(this.S(1), 2)
|
|
|
|
ids[11] = this.R(this.S(1), 1)
|
|
|
|
ids[12] = this.R(this.S(1), 2)
|
|
|
|
elif n == 6:
|
2020-12-13 01:08:32 +00:00
|
|
|
for i in range(6):
|
|
|
|
ids[i] = -1
|
2017-05-30 20:12:19 +00:00
|
|
|
if this.B(0) >= 0:
|
|
|
|
ids[0] = this.B(0)
|
2020-12-13 01:08:32 +00:00
|
|
|
if this.entity_is_open():
|
|
|
|
ent = this.get_ent()
|
|
|
|
j = 1
|
|
|
|
for i in range(ent.start, this.B(0)):
|
|
|
|
ids[j] = i
|
|
|
|
j += 1
|
|
|
|
if j >= 6:
|
|
|
|
break
|
2017-05-22 22:58:12 +00:00
|
|
|
else:
|
|
|
|
# TODO error =/
|
|
|
|
pass
|
|
|
|
for i in range(n):
|
|
|
|
if ids[i] >= 0:
|
2017-09-14 14:59:25 +00:00
|
|
|
ids[i] += this.offset
|
2017-09-14 14:18:02 +00:00
|
|
|
else:
|
2017-09-14 14:59:25 +00:00
|
|
|
ids[i] = -1
|
2017-05-22 22:58:12 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
int S(int i) nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
if i >= this._stack.size():
|
2016-02-01 00:09:21 +00:00
|
|
|
return -1
|
2020-12-13 01:08:32 +00:00
|
|
|
elif i < 0:
|
|
|
|
return -1
|
|
|
|
return this._stack.at(this._stack.size() - (i+1))
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
int B(int i) nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
if i < 0:
|
2016-02-01 00:09:21 +00:00
|
|
|
return -1
|
2020-12-13 01:08:32 +00:00
|
|
|
elif i < this._rebuffer.size():
|
|
|
|
return this._rebuffer.at(this._rebuffer.size() - (i+1))
|
|
|
|
else:
|
|
|
|
b_i = this._b_i + (i - this._rebuffer.size())
|
|
|
|
if b_i >= this.length:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return b_i
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
const TokenC* B_(int i) nogil const:
|
2016-02-01 00:09:21 +00:00
|
|
|
return this.safe_get(this.B(i))
|
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
const TokenC* E_(int i) nogil const:
|
2016-02-01 00:09:21 +00:00
|
|
|
return this.safe_get(this.E(i))
|
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
const TokenC* safe_get(int i) nogil const:
|
2016-02-01 00:09:21 +00:00
|
|
|
if i < 0 or i >= this.length:
|
|
|
|
return &this._empty_token
|
|
|
|
else:
|
|
|
|
return &this._sent[i]
|
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
void map_get_arcs(const unordered_map[int, vector[ArcC]] &heads_arcs, vector[ArcC]* out) nogil const:
|
|
|
|
cdef const vector[ArcC]* arcs
|
|
|
|
head_arcs_it = heads_arcs.const_begin()
|
|
|
|
while head_arcs_it != heads_arcs.const_end():
|
|
|
|
arcs = &deref(head_arcs_it).second
|
|
|
|
arcs_it = arcs.const_begin()
|
|
|
|
while arcs_it != arcs.const_end():
|
|
|
|
arc = deref(arcs_it)
|
|
|
|
if arc.head != -1 and arc.child != -1:
|
|
|
|
out.push_back(arc)
|
|
|
|
incr(arcs_it)
|
|
|
|
incr(head_arcs_it)
|
|
|
|
|
|
|
|
void get_arcs(vector[ArcC]* out) nogil const:
|
|
|
|
this.map_get_arcs(this._left_arcs, out)
|
|
|
|
this.map_get_arcs(this._right_arcs, out)
|
2020-12-13 01:08:32 +00:00
|
|
|
|
|
|
|
int H(int child) nogil const:
|
|
|
|
if child >= this.length or child < 0:
|
2016-02-01 00:09:21 +00:00
|
|
|
return -1
|
2020-12-13 01:08:32 +00:00
|
|
|
else:
|
|
|
|
return this._heads[child]
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
int E(int i) nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
if this._ents.size() == 0:
|
2017-09-14 14:18:02 +00:00
|
|
|
return -1
|
2020-12-13 01:08:32 +00:00
|
|
|
else:
|
|
|
|
return this._ents.back().start
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
int nth_child(const unordered_map[int, vector[ArcC]]& heads_arcs, int head, int idx) nogil const:
|
|
|
|
if idx < 1:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
head_arcs_it = heads_arcs.const_find(head)
|
|
|
|
if head_arcs_it == heads_arcs.const_end():
|
2016-02-01 00:09:21 +00:00
|
|
|
return -1
|
2022-01-13 08:03:55 +00:00
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
cdef const vector[ArcC]* arcs = &deref(head_arcs_it).second
|
|
|
|
|
|
|
|
# Work backwards through arcs to find the arc at the
|
2022-01-13 08:03:55 +00:00
|
|
|
# requested index more quickly.
|
|
|
|
cdef size_t child_index = 0
|
2022-01-13 09:33:30 +00:00
|
|
|
arcs_it = arcs.const_rbegin()
|
|
|
|
while arcs_it != arcs.const_rend() and child_index != idx:
|
|
|
|
arc = deref(arcs_it)
|
|
|
|
if arc.child != -1:
|
2022-01-13 08:03:55 +00:00
|
|
|
child_index += 1
|
|
|
|
if child_index == idx:
|
|
|
|
return arc.child
|
2022-01-13 09:33:30 +00:00
|
|
|
incr(arcs_it)
|
2022-01-13 08:03:55 +00:00
|
|
|
|
|
|
|
return -1
|
2017-03-11 12:19:52 +00:00
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
int L(int head, int idx) nogil const:
|
|
|
|
return this.nth_child(this._left_arcs, head, idx)
|
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
int R(int head, int idx) nogil const:
|
2022-01-13 09:33:30 +00:00
|
|
|
return this.nth_child(this._right_arcs, head, idx)
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
bint empty() nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
return this._stack.size() == 0
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
bint eol() nogil const:
|
2016-02-01 00:09:21 +00:00
|
|
|
return this.buffer_length() == 0
|
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
bint is_final() nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
return this.stack_depth() <= 0 and this.eol()
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
int cannot_sent_start(int word) nogil const:
|
|
|
|
if word < 0 or word >= this.length:
|
|
|
|
return 0
|
|
|
|
elif this._sent[word].sent_start == -1:
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
int is_sent_start(int word) nogil const:
|
|
|
|
if word < 0 or word >= this.length:
|
|
|
|
return 0
|
|
|
|
elif this._sent[word].sent_start == 1:
|
|
|
|
return 1
|
|
|
|
elif this._sent_starts.count(word) >= 1:
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
void set_sent_start(int word, int value) nogil:
|
|
|
|
if value >= 1:
|
|
|
|
this._sent_starts.insert(word)
|
|
|
|
|
|
|
|
bint has_head(int child) nogil const:
|
|
|
|
return this._heads[child] >= 0
|
|
|
|
|
|
|
|
int l_edge(int word) nogil const:
|
|
|
|
return word
|
|
|
|
|
|
|
|
int r_edge(int word) nogil const:
|
|
|
|
return word
|
2022-01-13 09:33:30 +00:00
|
|
|
|
|
|
|
int n_arcs(const unordered_map[int, vector[ArcC]] &heads_arcs, int head) nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef int n = 0
|
2022-01-13 09:33:30 +00:00
|
|
|
head_arcs_it = heads_arcs.const_find(head)
|
|
|
|
if head_arcs_it == heads_arcs.const_end():
|
|
|
|
return n
|
|
|
|
|
|
|
|
cdef const vector[ArcC]* arcs = &deref(head_arcs_it).second
|
|
|
|
arcs_it = arcs.const_begin()
|
|
|
|
while arcs_it != arcs.end():
|
|
|
|
arc = deref(arcs_it)
|
|
|
|
if arc.child != -1:
|
2020-12-13 01:08:32 +00:00
|
|
|
n += 1
|
2022-01-13 09:33:30 +00:00
|
|
|
incr(arcs_it)
|
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
return n
|
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
int n_L(int head) nogil const:
|
|
|
|
return n_arcs(this._left_arcs, head)
|
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
int n_R(int head) nogil const:
|
2022-01-13 09:33:30 +00:00
|
|
|
return n_arcs(this._right_arcs, head)
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
bint stack_is_connected() nogil const:
|
2016-02-01 00:09:21 +00:00
|
|
|
return False
|
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
bint entity_is_open() nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
if this._ents.size() == 0:
|
2016-02-01 00:09:21 +00:00
|
|
|
return False
|
2020-12-13 01:08:32 +00:00
|
|
|
else:
|
|
|
|
return this._ents.back().end == -1
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
int stack_depth() nogil const:
|
2020-12-13 01:08:32 +00:00
|
|
|
return this._stack.size()
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2016-02-01 01:58:14 +00:00
|
|
|
int buffer_length() nogil const:
|
2021-02-14 02:38:13 +00:00
|
|
|
return (this.length - this._b_i) + this._rebuffer.size()
|
2017-03-11 12:19:52 +00:00
|
|
|
|
2016-02-01 00:09:21 +00:00
|
|
|
void push() nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
b0 = this.B(0)
|
|
|
|
if this._rebuffer.size():
|
|
|
|
b0 = this._rebuffer.back()
|
|
|
|
this._rebuffer.pop_back()
|
|
|
|
else:
|
|
|
|
b0 = this._b_i
|
|
|
|
this._b_i += 1
|
|
|
|
this._stack.push_back(b0)
|
2016-02-01 00:09:21 +00:00
|
|
|
|
|
|
|
void pop() nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
this._stack.pop_back()
|
2017-03-11 12:19:52 +00:00
|
|
|
|
2019-03-10 13:53:03 +00:00
|
|
|
void force_final() nogil:
|
|
|
|
# This should only be used in desperate situations, as it may leave
|
|
|
|
# the analysis in an unexpected state.
|
2020-12-13 01:08:32 +00:00
|
|
|
this._stack.clear()
|
2019-03-10 13:53:03 +00:00
|
|
|
this._b_i = this.length
|
|
|
|
|
2016-02-01 00:09:21 +00:00
|
|
|
void unshift() nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
s0 = this._stack.back()
|
|
|
|
this._unshiftable[s0] = 1
|
|
|
|
this._rebuffer.push_back(s0)
|
|
|
|
this._stack.pop_back()
|
|
|
|
|
|
|
|
int is_unshiftable(int item) nogil const:
|
|
|
|
if item >= this._unshiftable.size():
|
|
|
|
return 0
|
|
|
|
else:
|
|
|
|
return this._unshiftable.at(item)
|
|
|
|
|
|
|
|
void set_reshiftable(int item) nogil:
|
|
|
|
if item < this._unshiftable.size():
|
|
|
|
this._unshiftable[item] = 0
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2017-05-28 16:09:27 +00:00
|
|
|
void add_arc(int head, int child, attr_t label) nogil:
|
2016-02-01 00:09:21 +00:00
|
|
|
if this.has_head(child):
|
|
|
|
this.del_arc(this.H(child), child)
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef ArcC arc
|
|
|
|
arc.head = head
|
|
|
|
arc.child = child
|
|
|
|
arc.label = label
|
|
|
|
if head > child:
|
2022-01-13 09:33:30 +00:00
|
|
|
this._left_arcs[arc.head].push_back(arc)
|
2016-02-01 00:09:21 +00:00
|
|
|
else:
|
2022-01-13 09:33:30 +00:00
|
|
|
this._right_arcs[arc.head].push_back(arc)
|
2020-12-13 01:08:32 +00:00
|
|
|
this._heads[child] = head
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
void map_del_arc(unordered_map[int, vector[ArcC]]* heads_arcs, int h_i, int c_i) nogil:
|
|
|
|
arcs_it = heads_arcs.find(h_i)
|
|
|
|
if arcs_it == heads_arcs.end():
|
|
|
|
return
|
|
|
|
|
|
|
|
arcs = &deref(arcs_it).second
|
2020-12-13 01:08:32 +00:00
|
|
|
if arcs.size() == 0:
|
|
|
|
return
|
2022-01-13 09:33:30 +00:00
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
arc = arcs.back()
|
|
|
|
if arc.head == h_i and arc.child == c_i:
|
|
|
|
arcs.pop_back()
|
|
|
|
else:
|
|
|
|
for i in range(arcs.size()-1):
|
|
|
|
arc = arcs.at(i)
|
|
|
|
if arc.head == h_i and arc.child == c_i:
|
|
|
|
arc.head = -1
|
|
|
|
arc.child = -1
|
|
|
|
arc.label = 0
|
|
|
|
break
|
|
|
|
|
2022-01-13 09:33:30 +00:00
|
|
|
void del_arc(int h_i, int c_i) nogil:
|
|
|
|
if h_i > c_i:
|
|
|
|
this.map_del_arc(&this._left_arcs, h_i, c_i)
|
|
|
|
else:
|
|
|
|
this.map_del_arc(&this._right_arcs, h_i, c_i)
|
|
|
|
|
2020-12-13 01:08:32 +00:00
|
|
|
SpanC get_ent() nogil const:
|
|
|
|
cdef SpanC ent
|
|
|
|
if this._ents.size() == 0:
|
|
|
|
ent.start = 0
|
|
|
|
ent.end = 0
|
|
|
|
ent.label = 0
|
|
|
|
return ent
|
2016-02-01 00:09:21 +00:00
|
|
|
else:
|
2020-12-13 01:08:32 +00:00
|
|
|
return this._ents.back()
|
2016-02-01 00:09:21 +00:00
|
|
|
|
2017-05-28 16:09:27 +00:00
|
|
|
void open_ent(attr_t label) nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef SpanC ent
|
|
|
|
ent.start = this.B(0)
|
|
|
|
ent.label = label
|
|
|
|
ent.end = -1
|
|
|
|
this._ents.push_back(ent)
|
2016-02-01 00:09:21 +00:00
|
|
|
|
|
|
|
void close_ent() nogil:
|
2020-12-13 01:08:32 +00:00
|
|
|
this._ents.back().end = this.B(0)+1
|
2016-02-01 00:09:21 +00:00
|
|
|
|
|
|
|
void clone(const StateC* src) nogil:
|
2017-05-27 20:49:37 +00:00
|
|
|
this.length = src.length
|
2020-12-13 01:08:32 +00:00
|
|
|
this._sent = src._sent
|
|
|
|
this._stack = src._stack
|
|
|
|
this._rebuffer = src._rebuffer
|
|
|
|
this._sent_starts = src._sent_starts
|
|
|
|
this._unshiftable = src._unshiftable
|
|
|
|
memcpy(this._heads, src._heads, this.length * sizeof(this._heads[0]))
|
|
|
|
this._ents = src._ents
|
|
|
|
this._left_arcs = src._left_arcs
|
|
|
|
this._right_arcs = src._right_arcs
|
2016-02-01 00:09:21 +00:00
|
|
|
this._b_i = src._b_i
|
2017-05-26 16:31:23 +00:00
|
|
|
this.offset = src.offset
|
2017-05-27 20:49:37 +00:00
|
|
|
this._empty_token = src._empty_token
|