/* Generated by Cython 0.25.2 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "discodop/macros.h"
        ],
        "extra_compile_args": [
            "-O3",
            "-march=native",
            "-DNDEBUG",
            "-Wno-strict-prototypes",
            "-Wno-unused-function",
            "-Wno-unreachable-code",
            "-DPY2=0"
        ],
        "extra_link_args": [
            "-DNDEBUG"
        ]
    },
    "module_name": "discodop.coarsetofine"
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_25_2"
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_FASTCALL
  #define METH_FASTCALL 0x80
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
                                              Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__discodop__coarsetofine
#define __PYX_HAVE_API__discodop__coarsetofine
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "macros.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "discodop/coarsetofine.pyx",
  "array.pxd",
  "discodop/containers.pxd",
  "type.pxd",
};

/* "containers.pxd":11
 * 
 * # NB: For PCFG parsing sentences longer than 256 words, change this to uint16_t
 * ctypedef uint8_t Idx             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef uint8_t __pyx_t_8discodop_10containers_Idx;

/*--- Type declarations ---*/
#ifndef _ARRAYARRAY_H
struct arrayobject;
typedef struct arrayobject arrayobject;
#endif
struct __pyx_obj_8discodop_10containers_Grammar;
struct __pyx_obj_8discodop_10containers_Chart;
struct __pyx_obj_8discodop_10containers_LexicalRule;
struct __pyx_obj_8discodop_10containers_ChartItem;
struct __pyx_obj_8discodop_10containers_SmallChartItem;
struct __pyx_obj_8discodop_10containers_FatChartItem;
struct __pyx_obj_8discodop_10containers_Edges;
struct __pyx_obj_8discodop_10containers_RankedEdge;
struct __pyx_obj_8discodop_10containers_Ctrees;
struct __pyx_obj_8discodop_10containers_Vocabulary;
struct __pyx_obj_8discodop_10containers_FixedVocabulary;
struct __pyx_t_8discodop_10containers_ProbRule;
union __pyx_t_8discodop_10containers_Position;
struct __pyx_t_8discodop_10containers_Edge;
struct __pyx_t_8discodop_10containers_EdgesStruct;
struct __pyx_t_8discodop_10containers_MoreEdges;
struct __pyx_t_8discodop_10containers_Node;
struct __pyx_t_8discodop_10containers_NodeArray;
struct __pyx_t_8discodop_10containers_Rule;
union __pyx_t_8discodop_10containers_ItemType;
struct __pyx_t_8discodop_10containers_DArray;

/* "containers.pxd":103
 * 
 * 
 * cdef struct ProbRule:  # total: 32 bytes.             # <<<<<<<<<<<<<<
 * 	double prob  # 8 bytes
 * 	uint32_t lhs  # 4 bytes
 */
struct __pyx_t_8discodop_10containers_ProbRule {
  double prob;
  uint32_t lhs;
  uint32_t rhs1;
  uint32_t rhs2;
  uint32_t args;
  uint32_t lengths;
  uint32_t no;
};

/* "containers.pxd":142
 * 
 * 
 * cdef union Position:  # 8 bytes             # <<<<<<<<<<<<<<
 * 	short mid  # CFG, end index of left child
 * 	uint64_t lvec  # LCFRS, bit vector of left child
 */
union __pyx_t_8discodop_10containers_Position {
  short mid;
  uint64_t lvec;
  uint64_t *lvec_fat;
};

/* "containers.pxd":149
 * 
 * 
 * cdef struct Edge:  # 16 bytes             # <<<<<<<<<<<<<<
 * 	ProbRule *rule  # ruleno may take less space than pointer, but not convenient
 * 	Position pos
 */
struct __pyx_t_8discodop_10containers_Edge {
  struct __pyx_t_8discodop_10containers_ProbRule *rule;
  union __pyx_t_8discodop_10containers_Position pos;
};

/* "containers.pxd":160
 * 
 * 
 * cdef struct EdgesStruct:             # <<<<<<<<<<<<<<
 * 	short len  # the number of edges in the head of the linked list
 * 	MoreEdges *head  # head of linked list
 */
struct __pyx_t_8discodop_10containers_EdgesStruct {
  short len;
  struct __pyx_t_8discodop_10containers_MoreEdges *head;
};

/* "containers.pxd":165
 * 
 * 
 * cdef struct MoreEdges:  # An unrolled linked list             # <<<<<<<<<<<<<<
 * 	MoreEdges *prev
 * 	Edge data[EDGES_SIZE]
 */
struct __pyx_t_8discodop_10containers_MoreEdges {
  struct __pyx_t_8discodop_10containers_MoreEdges *prev;
  struct __pyx_t_8discodop_10containers_Edge data[15];
};

/* "containers.pxd":220
 * # start fragments stuff
 * 
 * cdef struct Node:  # a node of a binary tree             # <<<<<<<<<<<<<<
 * 	int prod  # non-negative, ID of a phrasal or lexical production
 * 	short left  # >= 0: array idx to child Node; <0: idx sent[-left - 1];
 */
struct __pyx_t_8discodop_10containers_Node {
  int prod;
  short left;
  short right;
};

/* "containers.pxd":226
 * 
 * 
 * cdef struct NodeArray:  # a tree as an array of Node structs             # <<<<<<<<<<<<<<
 * 	unsigned int offset  # index to Node array where this tree starts
 * 	short len, root  # number of nodes, index to root node
 */
struct __pyx_t_8discodop_10containers_NodeArray {
  unsigned int offset;
  short len;
  short root;
};

/* "containers.pxd":246
 * 
 * 
 * cdef struct Rule:             # <<<<<<<<<<<<<<
 * 	uint32_t lhs, rhs1, rhs2, lengths, args
 * 
 */
struct __pyx_t_8discodop_10containers_Rule {
  uint32_t lhs;
  uint32_t rhs1;
  uint32_t rhs2;
  uint32_t lengths;
  uint32_t args;
};

/* "containers.pxd":250
 * 
 * 
 * cdef union ItemType:             # <<<<<<<<<<<<<<
 * 	void *ptr
 * 	char *aschar
 */
union __pyx_t_8discodop_10containers_ItemType {
  void *ptr;
  char *aschar;
  uint32_t *asint;
};

/* "containers.pxd":256
 * 
 * 
 * cdef struct DArray:             # <<<<<<<<<<<<<<
 * 	uint8_t itemsize
 * 	uint32_t len
 */
struct __pyx_t_8discodop_10containers_DArray {
  uint8_t itemsize;
  uint32_t len;
  uint32_t capacity;
  union __pyx_t_8discodop_10containers_ItemType d;
};

/* "containers.pxd":29
 * 
 * @cython.final
 * cdef class Grammar:             # <<<<<<<<<<<<<<
 * 	cdef ProbRule **bylhs
 * 	cdef ProbRule **unary
 */
struct __pyx_obj_8discodop_10containers_Grammar {
  PyObject_HEAD
  struct __pyx_vtabstruct_8discodop_10containers_Grammar *__pyx_vtab;
  struct __pyx_t_8discodop_10containers_ProbRule **bylhs;
  struct __pyx_t_8discodop_10containers_ProbRule **unary;
  struct __pyx_t_8discodop_10containers_ProbRule **lbinary;
  struct __pyx_t_8discodop_10containers_ProbRule **rbinary;
  uint32_t *mapping;
  uint32_t *revmap;
  uint32_t **splitmapping;
  uint8_t *fanout;
  uint64_t *chainvec;
  uint64_t *mask;
  int currentmodel;
  size_t nonterminals;
  size_t phrasalnonterminals;
  size_t numrules;
  size_t numunary;
  size_t numbinary;
  size_t maxfanout;
  int logprob;
  int bitpar;
  int binarized;
  PyObject *models;
  PyObject *origrules;
  PyObject *origlexicon;
  PyObject *start;
  PyObject *tolabel;
  PyObject *lexical;
  PyObject *modelnames;
  PyObject *rulemapping;
  PyObject *toid;
  PyObject *lexicalbyword;
  PyObject *lexicalbylhs;
  PyObject *lexicalbynum;
  PyObject *rulenos;
};


/* "containers.pxd":78
 * # 		to pack the parse forest?
 * # [ ] is it useful to have a recognition phase before making parse forest?
 * cdef class Chart:             # <<<<<<<<<<<<<<
 * 	cdef readonly dict rankededges  # [item][n] => DoubleEntry(RankedEdge, prob)
 * 	cdef object itemsinorder  # array or list
 */
struct __pyx_obj_8discodop_10containers_Chart {
  PyObject_HEAD
  struct __pyx_vtabstruct_8discodop_10containers_Chart *__pyx_vtab;
  PyObject *rankededges;
  PyObject *itemsinorder;
  PyObject *inside;
  PyObject *outside;
  struct __pyx_obj_8discodop_10containers_Grammar *grammar;
  PyObject *sent;
  short lensent;
  uint32_t start;
  int logprob;
  int viterbi;
};


/* "containers.pxd":114
 * 
 * @cython.final
 * cdef class LexicalRule:             # <<<<<<<<<<<<<<
 * 	cdef readonly double prob
 * 	cdef readonly uint32_t lhs
 */
struct __pyx_obj_8discodop_10containers_LexicalRule {
  PyObject_HEAD
  double prob;
  uint32_t lhs;
  PyObject *word;
};


/* "containers.pxd":121
 * 
 * @cython.freelist(1000)
 * cdef class ChartItem:             # <<<<<<<<<<<<<<
 * 	cdef uint32_t label
 * 	cdef double prob
 */
struct __pyx_obj_8discodop_10containers_ChartItem {
  PyObject_HEAD
  uint32_t label;
  double prob;
};


/* "containers.pxd":127
 * 
 * @cython.final
 * cdef class SmallChartItem(ChartItem):             # <<<<<<<<<<<<<<
 * 	cdef uint64_t vec
 * 	cdef copy(self)
 */
struct __pyx_obj_8discodop_10containers_SmallChartItem {
  struct __pyx_obj_8discodop_10containers_ChartItem __pyx_base;
  struct __pyx_vtabstruct_8discodop_10containers_SmallChartItem *__pyx_vtab;
  uint64_t vec;
};


/* "containers.pxd":133
 * 
 * @cython.final
 * cdef class FatChartItem(ChartItem):             # <<<<<<<<<<<<<<
 * 	cdef uint64_t vec[SLOTS]
 * 	cdef copy(self)
 */
struct __pyx_obj_8discodop_10containers_FatChartItem {
  struct __pyx_obj_8discodop_10containers_ChartItem __pyx_base;
  struct __pyx_vtabstruct_8discodop_10containers_FatChartItem *__pyx_vtab;
  uint64_t vec[4];
};


/* "containers.pxd":155
 * 
 * @cython.final
 * cdef class Edges:             # <<<<<<<<<<<<<<
 * 	cdef short len  # the number of edges in the head of the linked list
 * 	cdef MoreEdges *head  # head of linked list
 */
struct __pyx_obj_8discodop_10containers_Edges {
  PyObject_HEAD
  short len;
  struct __pyx_t_8discodop_10containers_MoreEdges *head;
};


/* "containers.pxd":173
 * 
 * @cython.final
 * cdef class RankedEdge:             # <<<<<<<<<<<<<<
 * 	# NB: 'head' is unnecessary because the head will also be the dictionary
 * 	# key for a ranked edge, but having it as part of the object is convenient.
 */
struct __pyx_obj_8discodop_10containers_RankedEdge {
  PyObject_HEAD
  struct __pyx_t_8discodop_10containers_Edge *edge;
  PyObject *head;
  int left;
  int right;
};


/* "containers.pxd":232
 * 
 * @cython.final
 * cdef class Ctrees:             # <<<<<<<<<<<<<<
 * 	cdef Node *nodes
 * 	cdef NodeArray *trees
 */
struct __pyx_obj_8discodop_10containers_Ctrees {
  PyObject_HEAD
  struct __pyx_vtabstruct_8discodop_10containers_Ctrees *__pyx_vtab;
  struct __pyx_t_8discodop_10containers_Node *nodes;
  struct __pyx_t_8discodop_10containers_NodeArray *trees;
  long nodesleft;
  long max;
  size_t numnodes;
  size_t numwords;
  short maxnodes;
  int len;
  PyObject *prodindex;
  PyObject *_state;
};


/* "containers.pxd":263
 * 
 * 
 * cdef class Vocabulary:             # <<<<<<<<<<<<<<
 * 	cdef readonly dict prods  # production str. => int
 * 	cdef readonly dict labels  # label/word str => int
 */
struct __pyx_obj_8discodop_10containers_Vocabulary {
  PyObject_HEAD
  struct __pyx_vtabstruct_8discodop_10containers_Vocabulary *__pyx_vtab;
  PyObject *prods;
  PyObject *labels;
  struct __pyx_t_8discodop_10containers_DArray prodbuf;
  struct __pyx_t_8discodop_10containers_DArray labelbuf;
  struct __pyx_t_8discodop_10containers_DArray labelidx;
};


/* "containers.pxd":280
 * 
 * 
 * cdef class FixedVocabulary(Vocabulary):             # <<<<<<<<<<<<<<
 * 	cdef object state  # to keep buffer alive
 * 
 */
struct __pyx_obj_8discodop_10containers_FixedVocabulary {
  struct __pyx_obj_8discodop_10containers_Vocabulary __pyx_base;
  PyObject *state;
};



/* "containers.pxd":29
 * 
 * @cython.final
 * cdef class Grammar:             # <<<<<<<<<<<<<<
 * 	cdef ProbRule **bylhs
 * 	cdef ProbRule **unary
 */

struct __pyx_vtabstruct_8discodop_10containers_Grammar {
  PyObject *(*_convertrules)(struct __pyx_obj_8discodop_10containers_Grammar *, PyObject *, PyObject *);
  PyObject *(*_indexrules)(struct __pyx_obj_8discodop_10containers_Grammar *, struct __pyx_t_8discodop_10containers_ProbRule **, int, int);
  PyObject *(*rulestr)(struct __pyx_obj_8discodop_10containers_Grammar *, int, int __pyx_skip_dispatch);
  PyObject *(*yfstr)(struct __pyx_obj_8discodop_10containers_Grammar *, struct __pyx_t_8discodop_10containers_ProbRule);
};
static struct __pyx_vtabstruct_8discodop_10containers_Grammar *__pyx_vtabptr_8discodop_10containers_Grammar;


/* "containers.pxd":78
 * # 		to pack the parse forest?
 * # [ ] is it useful to have a recognition phase before making parse forest?
 * cdef class Chart:             # <<<<<<<<<<<<<<
 * 	cdef readonly dict rankededges  # [item][n] => DoubleEntry(RankedEdge, prob)
 * 	cdef object itemsinorder  # array or list
 */

struct __pyx_vtabstruct_8discodop_10containers_Chart {
  double (*subtreeprob)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *);
  int (*lexidx)(struct __pyx_obj_8discodop_10containers_Chart *, struct __pyx_t_8discodop_10containers_Edge *);
  double (*lexprob)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *, struct __pyx_t_8discodop_10containers_Edge *);
  PyObject *(*edgestr)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *, struct __pyx_t_8discodop_10containers_Edge *);
  PyObject *(*_left)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *, struct __pyx_t_8discodop_10containers_Edge *);
  PyObject *(*_right)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *, struct __pyx_t_8discodop_10containers_Edge *);
  PyObject *(*left)(struct __pyx_obj_8discodop_10containers_Chart *, struct __pyx_obj_8discodop_10containers_RankedEdge *);
  PyObject *(*right)(struct __pyx_obj_8discodop_10containers_Chart *, struct __pyx_obj_8discodop_10containers_RankedEdge *);
  PyObject *(*copy)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *);
  uint32_t (*label)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *);
  struct __pyx_obj_8discodop_10containers_ChartItem *(*asChartItem)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *);
  size_t (*asCFGspan)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *, size_t);
  struct __pyx_obj_8discodop_10containers_Edges *(*getedges)(struct __pyx_obj_8discodop_10containers_Chart *, PyObject *);
};
static struct __pyx_vtabstruct_8discodop_10containers_Chart *__pyx_vtabptr_8discodop_10containers_Chart;


/* "containers.pxd":127
 * 
 * @cython.final
 * cdef class SmallChartItem(ChartItem):             # <<<<<<<<<<<<<<
 * 	cdef uint64_t vec
 * 	cdef copy(self)
 */

struct __pyx_vtabstruct_8discodop_10containers_SmallChartItem {
  PyObject *(*copy)(struct __pyx_obj_8discodop_10containers_SmallChartItem *);
};
static struct __pyx_vtabstruct_8discodop_10containers_SmallChartItem *__pyx_vtabptr_8discodop_10containers_SmallChartItem;


/* "containers.pxd":133
 * 
 * @cython.final
 * cdef class FatChartItem(ChartItem):             # <<<<<<<<<<<<<<
 * 	cdef uint64_t vec[SLOTS]
 * 	cdef copy(self)
 */

struct __pyx_vtabstruct_8discodop_10containers_FatChartItem {
  PyObject *(*copy)(struct __pyx_obj_8discodop_10containers_FatChartItem *);
};
static struct __pyx_vtabstruct_8discodop_10containers_FatChartItem *__pyx_vtabptr_8discodop_10containers_FatChartItem;


/* "containers.pxd":232
 * 
 * @cython.final
 * cdef class Ctrees:             # <<<<<<<<<<<<<<
 * 	cdef Node *nodes
 * 	cdef NodeArray *trees
 */

struct __pyx_vtabstruct_8discodop_10containers_Ctrees {
  PyObject *(*alloc)(struct __pyx_obj_8discodop_10containers_Ctrees *, int, long, int __pyx_skip_dispatch);
  PyObject *(*realloc)(struct __pyx_obj_8discodop_10containers_Ctrees *, int, int);
  PyObject *(*addnodes)(struct __pyx_obj_8discodop_10containers_Ctrees *, struct __pyx_t_8discodop_10containers_Node *, int, int);
};
static struct __pyx_vtabstruct_8discodop_10containers_Ctrees *__pyx_vtabptr_8discodop_10containers_Ctrees;


/* "containers.pxd":263
 * 
 * 
 * cdef class Vocabulary:             # <<<<<<<<<<<<<<
 * 	cdef readonly dict prods  # production str. => int
 * 	cdef readonly dict labels  # label/word str => int
 */

struct __pyx_vtabstruct_8discodop_10containers_Vocabulary {
  PyObject *(*idtolabel)(struct __pyx_obj_8discodop_10containers_Vocabulary *, uint32_t);
  PyObject *(*getlabel)(struct __pyx_obj_8discodop_10containers_Vocabulary *, int);
  PyObject *(*getword)(struct __pyx_obj_8discodop_10containers_Vocabulary *, int);
  int (*islexical)(struct __pyx_obj_8discodop_10containers_Vocabulary *, int);
  int (*getprod)(struct __pyx_obj_8discodop_10containers_Vocabulary *, PyObject *, PyObject *);
  int (*_getprodid)(struct __pyx_obj_8discodop_10containers_Vocabulary *, PyObject *);
  int (*_getlabelid)(struct __pyx_obj_8discodop_10containers_Vocabulary *, PyObject *);
};
static struct __pyx_vtabstruct_8discodop_10containers_Vocabulary *__pyx_vtabptr_8discodop_10containers_Vocabulary;


/* "containers.pxd":280
 * 
 * 
 * cdef class FixedVocabulary(Vocabulary):             # <<<<<<<<<<<<<<
 * 	cdef object state  # to keep buffer alive
 * 
 */

struct __pyx_vtabstruct_8discodop_10containers_FixedVocabulary {
  struct __pyx_vtabstruct_8discodop_10containers_Vocabulary __pyx_base;
};
static struct __pyx_vtabstruct_8discodop_10containers_FixedVocabulary *__pyx_vtabptr_8discodop_10containers_FixedVocabulary;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* ArgTypeTest.proto */
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact);

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto */
static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** value1, PyObject** value2,
                                             int is_tuple, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* SliceTupleAndList.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* tp_new.proto */
#define __Pyx_tp_new(type_obj, args) __Pyx_tp_new_kwargs(type_obj, args, NULL)
static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
    return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs));
}

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, int inplace);
#else
#define __Pyx_PyFloat_AddCObj(op1, op2, floatval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value);

/* ArrayAPI.proto */
#ifndef _ARRAYARRAY_H
#define _ARRAYARRAY_H
typedef struct arraydescr {
    int typecode;
    int itemsize;
    PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
    int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
#if PY_MAJOR_VERSION >= 3
    char *formats;
#endif
} arraydescr;
struct arrayobject {
    PyObject_HEAD
    Py_ssize_t ob_size;
    union {
        char *ob_item;
        float *as_floats;
        double *as_doubles;
        int *as_ints;
        unsigned int *as_uints;
        unsigned char *as_uchars;
        signed char *as_schars;
        char *as_chars;
        unsigned long *as_ulongs;
        long *as_longs;
        short *as_shorts;
        unsigned short *as_ushorts;
        Py_UNICODE *as_pyunicodes;
        void *as_voidptr;
    } data;
    Py_ssize_t allocated;
    struct arraydescr *ob_descr;
    PyObject *weakreflist;
#if PY_MAJOR_VERSION >= 3
        int ob_exports;
#endif
};
#ifndef NO_NEWARRAY_INLINE
static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t size,
    struct arraydescr *descr) {
    arrayobject *op;
    size_t nbytes;
    if (size < 0) {
        PyErr_BadInternalCall();
        return NULL;
    }
    nbytes = size * descr->itemsize;
    if (nbytes / descr->itemsize != (size_t)size) {
        return PyErr_NoMemory();
    }
    op = (arrayobject *) type->tp_alloc(type, 0);
    if (op == NULL) {
        return NULL;
    }
    op->ob_descr = descr;
    op->allocated = size;
    op->weakreflist = NULL;
    op->ob_size = size;
    if (size <= 0) {
        op->data.ob_item = NULL;
    }
    else {
        op->data.ob_item = PyMem_NEW(char, nbytes);
        if (op->data.ob_item == NULL) {
            Py_DECREF(op);
            return PyErr_NoMemory();
        }
    }
    return (PyObject *) op;
}
#else
PyObject* newarrayobject(PyTypeObject *type, Py_ssize_t size,
    struct arraydescr *descr);
#endif
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
    void *items = (void*) self->data.ob_item;
    PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
    if (items == NULL) {
        PyErr_NoMemory();
        return -1;
    }
    self->data.ob_item = (char*) items;
    self->ob_size = n;
    self->allocated = n;
    return 0;
}
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
    void *items = (void*) self->data.ob_item;
    Py_ssize_t newsize;
    if (n < self->allocated && n*4 > self->allocated) {
        self->ob_size = n;
        return 0;
    }
    newsize = n + (n / 2) + 1;
    if (newsize <= n) {
        PyErr_NoMemory();
        return -1;
    }
    PyMem_Resize(items, char, (size_t)(newsize * self->ob_descr->itemsize));
    if (items == NULL) {
        PyErr_NoMemory();
        return -1;
    }
    self->data.ob_item = (char*) items;
    self->ob_size = n;
    self->allocated = newsize;
    return 0;
}
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* PyIdentifierFromString.proto */
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

/* ModuleImport.proto */
static PyObject *__Pyx_ImportModule(const char *name);

/* TypeImport.proto */
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

/* VoidPtrImport.proto */
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);


/* Module declarations from 'libc.stdint' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'array' */

/* Module declarations from 'cpython.array' */
static PyTypeObject *__pyx_ptype_7cpython_5array_array = 0;
static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *, char *, Py_ssize_t); /*proto*/

/* Module declarations from 'cython' */

/* Module declarations from 'discodop.containers' */
static PyTypeObject *__pyx_ptype_8discodop_10containers_Grammar = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_Chart = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_LexicalRule = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_ChartItem = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_SmallChartItem = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_FatChartItem = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_Edges = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_RankedEdge = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_Ctrees = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_Vocabulary = 0;
static PyTypeObject *__pyx_ptype_8discodop_10containers_FixedVocabulary = 0;
static PyObject **__pyx_vp_8discodop_10containers_log1e200 = 0;
#define __pyx_v_8discodop_10containers_log1e200 (*__pyx_vp_8discodop_10containers_log1e200)
static struct __pyx_obj_8discodop_10containers_SmallChartItem *(*__pyx_f_8discodop_10containers_CFGtoSmallChartItem)(uint32_t, __pyx_t_8discodop_10containers_Idx, __pyx_t_8discodop_10containers_Idx); /*proto*/
static struct __pyx_obj_8discodop_10containers_FatChartItem *(*__pyx_f_8discodop_10containers_CFGtoFatChartItem)(uint32_t, __pyx_t_8discodop_10containers_Idx, __pyx_t_8discodop_10containers_Idx); /*proto*/
static CYTHON_INLINE size_t __pyx_f_8discodop_10containers_cellidx(short, short, short, uint32_t); /*proto*/
static CYTHON_INLINE size_t __pyx_f_8discodop_10containers_compactcellidx(short, short, short, uint32_t); /*proto*/

/* Module declarations from 'discodop.coarsetofine' */
#define __Pyx_MODULE_NAME "discodop.coarsetofine"
int __pyx_module_is_main_discodop__coarsetofine = 0;

/* Implementation of 'discodop.coarsetofine' */
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_min;
static PyObject *__pyx_builtin_max;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_print;
static PyObject *__pyx_builtin_bin;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_MemoryError;
static const char __pyx_k_a[] = "a";
static const char __pyx_k_k[] = "k";
static const char __pyx_k_l[] = "l";
static const char __pyx_k_m[] = "m";
static const char __pyx_k_n[] = "n";
static const char __pyx_k_p[] = "p";
static const char __pyx_k_s[] = "s";
static const char __pyx_k_t[] = "t";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_y[] = "y";
static const char __pyx_k__5[] = "";
static const char __pyx_k__7[] = " ";
static const char __pyx_k__8[] = ":";
static const char __pyx_k__9[] = "!";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_re[] = "re";
static const char __pyx_k_yf[] = "yf";
static const char __pyx_k_0_9[] = "@[-0-9]+$";
static const char __pyx_k__25[] = "_";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_all[] = "__all__";
static const char __pyx_k_bin[] = "bin";
static const char __pyx_k_d_d[] = "%d:%d";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_exp[] = "exp";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_log[] = "log";
static const char __pyx_k_map[] = "map";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_min[] = "min";
static const char __pyx_k_mpp[] = "mpp";
static const char __pyx_k_msg[] = "msg";
static const char __pyx_k_vec[] = "vec";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_Tree[] = "Tree";
static const char __pyx_k_copy[] = "copy";
static const char __pyx_k_edge[] = "edge";
static const char __pyx_k_fine[] = "fine";
static const char __pyx_k_fsum[] = "fsum";
static const char __pyx_k_item[] = "item";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_math[] = "math";
static const char __pyx_k_prob[] = "prob";
static const char __pyx_k_root[] = "root";
static const char __pyx_k_sent[] = "sent";
static const char __pyx_k_tags[] = "tags";
static const char __pyx_k_test[] = "test";
static const char __pyx_k_time[] = "time";
static const char __pyx_k_tree[] = "tree";
static const char __pyx_k_word[] = "word";
static const char __pyx_k_begin[] = "begin";
static const char __pyx_k_chart[] = "chart";
static const char __pyx_k_clock[] = "clock";
static const char __pyx_k_deriv[] = "deriv";
static const char __pyx_k_edges[] = "edges";
static const char __pyx_k_fine1[] = "fine1";
static const char __pyx_k_isinf[] = "isinf";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_kbest[] = "kbest";
static const char __pyx_k_label[] = "label";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_parse[] = "parse";
static const char __pyx_k_print[] = "print";
static const char __pyx_k_pyexp[] = "pyexp";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_sents[] = "sents";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_train[] = "train";
static const char __pyx_k_trees[] = "trees";
static const char __pyx_k_bitpar[] = "bitpar";
static const char __pyx_k_chart2[] = "chart2";
static const char __pyx_k_coarse[] = "coarse";
static const char __pyx_k_corpus[] = "corpus";
static const char __pyx_k_derivs[] = "derivs";
static const char __pyx_k_dtrees[] = "dtrees";
static const char __pyx_k_fanout[] = "fanout";
static const char __pyx_k_filter[] = "filter";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_leaves[] = "leaves";
static const char __pyx_k_normal[] = "normal";
static const char __pyx_k_parent[] = "parent";
static const char __pyx_k_plcfrs[] = "plcfrs";
static const char __pyx_k_splitg[] = "splitg";
static const char __pyx_k_switch[] = "switch";
static const char __pyx_k_test_2[] = "__test__";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_F_I_N_E[] = " F I N E ";
static const char __pyx_k_cftrees[] = "cftrees";
static const char __pyx_k_compile[] = "compile";
static const char __pyx_k_enabled[] = "enabled";
static const char __pyx_k_entries[] = "entries";
static const char __pyx_k_fine999[] = "fine999";
static const char __pyx_k_finecfg[] = "finecfg";
static const char __pyx_k_grammar[] = "grammar";
static const char __pyx_k_logprob[] = "logprob";
static const char __pyx_k_tolabel[] = "tolabel";
static const char __pyx_k_verbose[] = "verbose";
static const char __pyx_k_binarize[] = "binarize";
static const char __pyx_k_cf_split[] = "cf-split";
static const char __pyx_k_edgelist[] = "edgelist";
static const char __pyx_k_fatitems[] = "fatitems";
static const char __pyx_k_fine999x[] = "fine999x";
static const char __pyx_k_finespan[] = "finespan";
static const char __pyx_k_fromkeys[] = "fromkeys";
static const char __pyx_k_getitems[] = "getitems";
static const char __pyx_k_leftitem[] = "leftitem";
static const char __pyx_k_no_match[] = "no match";
static const char __pyx_k_no_parse[] = "no parse";
static const char __pyx_k_numitems[] = "numitems";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_sentprob[] = "sentprob";
static const char __pyx_k_subtrees[] = "subtrees";
static const char __pyx_k_treebank[] = "treebank";
static const char __pyx_k_chartitem[] = "chartitem";
static const char __pyx_k_childchar[] = "childchar";
static const char __pyx_k_doctftest[] = "doctftest";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_finelabel[] = "finelabel";
static const char __pyx_k_getinside[] = "getinside";
static const char __pyx_k_lazykbest[] = "lazykbest";
static const char __pyx_k_numremain[] = "numremain";
static const char __pyx_k_posterior[] = "posterior";
static const char __pyx_k_rightitem[] = "rightitem";
static const char __pyx_k_threshold[] = "threshold";
static const char __pyx_k_whitelist[] = "\nwhitelist:";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_addbitsets[] = "addbitsets";
static const char __pyx_k_getmapping[] = "getmapping";
static const char __pyx_k_getoutside[] = "getoutside";
static const char __pyx_k_horzmarkov[] = "horzmarkov";
static const char __pyx_k_kbestspans[] = "kbestspans";
static const char __pyx_k_markorigin[] = "markorigin";
static const char __pyx_k_parentchar[] = "parentchar";
static const char __pyx_k_prunechart[] = "prunechart";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_splitprune[] = "splitprune";
static const char __pyx_k_tailmarker[] = "tailmarker";
static const char __pyx_k_testmaxlen[] = "testmaxlen";
static const char __pyx_k_unbinarize[] = "unbinarize";
static const char __pyx_k_unfiltered[] = "unfiltered";
static const char __pyx_k_vertmarkov[] = "vertmarkov";
static const char __pyx_k_C_O_A_R_S_E[] = " C O A R S E ";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_coarsechart[] = "coarsechart";
static const char __pyx_k_derivations[] = "derivations";
static const char __pyx_k_exact_match[] = "exact match";
static const char __pyx_k_marginalize[] = "marginalize";
static const char __pyx_k_normallcfrs[] = "normallcfrs";
static const char __pyx_k_origlogprob[] = "origlogprob";
static const char __pyx_k_outsideprob[] = "outsideprob";
static const char __pyx_k_parentannot[] = "parentannot";
static const char __pyx_k_parenttrees[] = "parenttrees";
static const char __pyx_k_rankededges[] = "rankededges";
static const char __pyx_k_whitelist_2[] = "whitelist";
static const char __pyx_k_canonicalize[] = "canonicalize";
static const char __pyx_k_cfgwhitelist[] = "cfgwhitelist";
static const char __pyx_k_dopreduction[] = "dopreduction";
static const char __pyx_k_tagged_sents[] = "tagged_sents";
static const char __pyx_k_time_elapsed[] = "time elapsed";
static const char __pyx_k_leftmostunary[] = "leftmostunary";
static const char __pyx_k_subsetgrammar[] = "subsetgrammar";
static const char __pyx_k_coarse_grammar[] = "coarse grammar:";
static const char __pyx_k_disambiguation[] = "disambiguation";
static const char __pyx_k_getderivations[] = "getderivations";
static const char __pyx_k_mergediscnodes[] = "mergediscnodes";
static const char __pyx_k_splitdiscnodes[] = "splitdiscnodes";
static const char __pyx_k_treetransforms[] = "treetransforms";
static const char __pyx_k_treebankgrammar[] = "treebankgrammar";
static const char __pyx_k_addfanoutmarkers[] = "addfanoutmarkers";
static const char __pyx_k_bitparkbestitems[] = "bitparkbestitems";
static const char __pyx_k_no_parse_problem[] = "no parse. problem.";
static const char __pyx_k_NegraCorpusReader[] = "NegraCorpusReader";
static const char __pyx_k_posteriorthreshold[] = "posteriorthreshold";
static const char __pyx_k_alpinosample_export[] = "alpinosample.export";
static const char __pyx_k_removefanoutmarkers[] = "removefanoutmarkers";
static const char __pyx_k_discodop_coarsetofine[] = "discodop.coarsetofine";
static const char __pyx_k_DOP_grammar_is_a_superset[] = "DOP grammar is a superset";
static const char __pyx_k_DOP_grammar_is_NOT_a_superset[] = "DOP grammar is NOT a superset!";
static const char __pyx_k_datastore_avcrane1_disco_dop_di[] = "/datastore/avcrane1/disco-dop/discodop/coarsetofine.pyx";
static const char __pyx_k_items_in_50_best_of_coarse_char[] = "\nitems in 50-best of coarse chart";
static const char __pyx_k_probability_threshold_should_be[] = "probability threshold should be between 0 and 1.";
static const char __pyx_k_Project_selected_items_from_a_ch[] = "Project selected items from a chart to corresponding items in next grammar.\n";
static const char __pyx_k_coarse_items_before_pruning_d_af[] = "coarse items before pruning: %d; after: %d, based on %d/%d derivations";
static const char __pyx_k_coarse_items_before_pruning_d_fi[] = "coarse items before pruning=%d; filtered: %d; pruned: %d; sentprob=%g";
static const char __pyx_k_need_list_of_chart_items_in_topo[] = "need list of chart items in topological order.";
static const char __pyx_k_need_to_call_fine_getmapping_coa[] = "need to call fine.getmapping(coarse, ...).";
static const char __pyx_k_sentence_has_zero_posterior_prob[] = "sentence has zero posterior prob.: %g";
static PyObject *__pyx_kp_u_0_9;
static PyObject *__pyx_kp_u_C_O_A_R_S_E;
static PyObject *__pyx_kp_u_DOP_grammar_is_NOT_a_superset;
static PyObject *__pyx_kp_u_DOP_grammar_is_a_superset;
static PyObject *__pyx_kp_u_F_I_N_E;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_n_s_NegraCorpusReader;
static PyObject *__pyx_n_s_Tree;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s__25;
static PyObject *__pyx_n_s__5;
static PyObject *__pyx_kp_u__5;
static PyObject *__pyx_kp_u__7;
static PyObject *__pyx_kp_u__8;
static PyObject *__pyx_kp_u__9;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_addbitsets;
static PyObject *__pyx_n_s_addfanoutmarkers;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_kp_u_alpinosample_export;
static PyObject *__pyx_n_s_begin;
static PyObject *__pyx_n_s_bin;
static PyObject *__pyx_n_s_binarize;
static PyObject *__pyx_n_s_bitpar;
static PyObject *__pyx_n_s_bitparkbestitems;
static PyObject *__pyx_n_u_bitparkbestitems;
static PyObject *__pyx_n_s_canonicalize;
static PyObject *__pyx_kp_u_cf_split;
static PyObject *__pyx_n_s_cfgwhitelist;
static PyObject *__pyx_n_s_cftrees;
static PyObject *__pyx_n_s_chart;
static PyObject *__pyx_n_s_chart2;
static PyObject *__pyx_n_s_chartitem;
static PyObject *__pyx_n_s_childchar;
static PyObject *__pyx_n_s_clock;
static PyObject *__pyx_n_s_coarse;
static PyObject *__pyx_kp_u_coarse_grammar;
static PyObject *__pyx_kp_u_coarse_items_before_pruning_d_af;
static PyObject *__pyx_kp_u_coarse_items_before_pruning_d_fi;
static PyObject *__pyx_n_s_coarsechart;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_n_s_corpus;
static PyObject *__pyx_kp_u_d_d;
static PyObject *__pyx_kp_s_datastore_avcrane1_disco_dop_di;
static PyObject *__pyx_n_s_deriv;
static PyObject *__pyx_n_s_derivations;
static PyObject *__pyx_n_s_derivs;
static PyObject *__pyx_n_s_disambiguation;
static PyObject *__pyx_n_s_discodop_coarsetofine;
static PyObject *__pyx_n_s_doctftest;
static PyObject *__pyx_n_s_dopreduction;
static PyObject *__pyx_n_s_dtrees;
static PyObject *__pyx_n_s_edge;
static PyObject *__pyx_n_s_edgelist;
static PyObject *__pyx_n_s_edges;
static PyObject *__pyx_n_s_enabled;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_entries;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_kp_u_exact_match;
static PyObject *__pyx_n_s_exp;
static PyObject *__pyx_n_s_fanout;
static PyObject *__pyx_n_s_fatitems;
static PyObject *__pyx_n_s_filter;
static PyObject *__pyx_n_s_fine;
static PyObject *__pyx_n_s_fine1;
static PyObject *__pyx_n_s_fine999;
static PyObject *__pyx_n_s_fine999x;
static PyObject *__pyx_n_s_finecfg;
static PyObject *__pyx_n_s_finelabel;
static PyObject *__pyx_n_s_finespan;
static PyObject *__pyx_n_s_fromkeys;
static PyObject *__pyx_n_s_fsum;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_getderivations;
static PyObject *__pyx_n_s_getinside;
static PyObject *__pyx_n_u_getinside;
static PyObject *__pyx_n_s_getitems;
static PyObject *__pyx_n_s_getmapping;
static PyObject *__pyx_n_s_getoutside;
static PyObject *__pyx_n_u_getoutside;
static PyObject *__pyx_n_s_grammar;
static PyObject *__pyx_n_s_horzmarkov;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_isinf;
static PyObject *__pyx_n_s_item;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_kp_u_items_in_50_best_of_coarse_char;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_kbest;
static PyObject *__pyx_n_s_kbestspans;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_n_s_label;
static PyObject *__pyx_n_s_lazykbest;
static PyObject *__pyx_n_s_leaves;
static PyObject *__pyx_n_s_leftitem;
static PyObject *__pyx_n_s_leftmostunary;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_logprob;
static PyObject *__pyx_n_s_m;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_map;
static PyObject *__pyx_n_s_marginalize;
static PyObject *__pyx_n_s_markorigin;
static PyObject *__pyx_n_s_math;
static PyObject *__pyx_n_s_max;
static PyObject *__pyx_n_s_mergediscnodes;
static PyObject *__pyx_n_s_min;
static PyObject *__pyx_n_s_mpp;
static PyObject *__pyx_n_u_mpp;
static PyObject *__pyx_n_s_msg;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_kp_u_need_list_of_chart_items_in_topo;
static PyObject *__pyx_kp_u_need_to_call_fine_getmapping_coa;
static PyObject *__pyx_kp_u_no_match;
static PyObject *__pyx_kp_u_no_parse;
static PyObject *__pyx_kp_u_no_parse_problem;
static PyObject *__pyx_n_s_normal;
static PyObject *__pyx_n_u_normal;
static PyObject *__pyx_n_s_normallcfrs;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numitems;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_numremain;
static PyObject *__pyx_n_s_origlogprob;
static PyObject *__pyx_n_s_outsideprob;
static PyObject *__pyx_n_s_p;
static PyObject *__pyx_n_s_parent;
static PyObject *__pyx_n_u_parentannot;
static PyObject *__pyx_n_s_parentchar;
static PyObject *__pyx_n_s_parenttrees;
static PyObject *__pyx_n_s_parse;
static PyObject *__pyx_n_s_plcfrs;
static PyObject *__pyx_n_s_posterior;
static PyObject *__pyx_n_s_posteriorthreshold;
static PyObject *__pyx_n_u_posteriorthreshold;
static PyObject *__pyx_n_s_print;
static PyObject *__pyx_n_s_prob;
static PyObject *__pyx_kp_u_probability_threshold_should_be;
static PyObject *__pyx_n_s_prunechart;
static PyObject *__pyx_n_u_prunechart;
static PyObject *__pyx_n_s_pyexp;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_rankededges;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_removefanoutmarkers;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_rightitem;
static PyObject *__pyx_n_s_root;
static PyObject *__pyx_n_s_s;
static PyObject *__pyx_n_u_s;
static PyObject *__pyx_n_s_sent;
static PyObject *__pyx_kp_u_sentence_has_zero_posterior_prob;
static PyObject *__pyx_n_s_sentprob;
static PyObject *__pyx_n_s_sents;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_splitdiscnodes;
static PyObject *__pyx_n_s_splitg;
static PyObject *__pyx_n_s_splitprune;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_subsetgrammar;
static PyObject *__pyx_n_s_subtrees;
static PyObject *__pyx_n_s_switch;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_n_s_tagged_sents;
static PyObject *__pyx_n_s_tags;
static PyObject *__pyx_n_s_tailmarker;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_test_2;
static PyObject *__pyx_n_s_testmaxlen;
static PyObject *__pyx_n_s_threshold;
static PyObject *__pyx_n_s_time;
static PyObject *__pyx_kp_u_time_elapsed;
static PyObject *__pyx_n_s_tolabel;
static PyObject *__pyx_n_s_train;
static PyObject *__pyx_n_s_tree;
static PyObject *__pyx_n_s_treebank;
static PyObject *__pyx_n_s_treebankgrammar;
static PyObject *__pyx_n_s_trees;
static PyObject *__pyx_n_s_treetransforms;
static PyObject *__pyx_n_s_unbinarize;
static PyObject *__pyx_n_s_unfiltered;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_vec;
static PyObject *__pyx_n_s_verbose;
static PyObject *__pyx_n_s_vertmarkov;
static PyObject *__pyx_kp_u_whitelist;
static PyObject *__pyx_n_s_whitelist_2;
static PyObject *__pyx_n_s_word;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_yf;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_8discodop_12coarsetofine_prunechart(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_coarsechart, struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_fine, PyObject *__pyx_v_k, int __pyx_v_splitprune, int __pyx_v_markorigin, int __pyx_v_finecfg, int __pyx_v_bitpar); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_2bitparkbestitems(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart, int __pyx_v_k, int __pyx_v_finecfg); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_4posteriorthreshold(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart, double __pyx_v_threshold); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_6getinside(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_8getoutside(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_10doctftest(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coarse, PyObject *__pyx_v_fine, PyObject *__pyx_v_sent, PyObject *__pyx_v_tree, PyObject *__pyx_v_k, PyObject *__pyx_v_split, PyObject *__pyx_v_verbose); /* proto */
static PyObject *__pyx_pf_8discodop_12coarsetofine_12test(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */
static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_460;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_codeobj__27;
static PyObject *__pyx_codeobj__29;
static PyObject *__pyx_codeobj__31;
static PyObject *__pyx_codeobj__33;
static PyObject *__pyx_codeobj__35;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__39;

/* "discodop/coarsetofine.pyx":20
 * 
 * 
 * def prunechart(Chart coarsechart, Grammar fine, k,             # <<<<<<<<<<<<<<
 * 		bint splitprune, bint markorigin, bint finecfg, bint bitpar):
 * 	"""Produce a white list of selected chart items.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_1prunechart(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_prunechart[] = "prunechart(Chart coarsechart, Grammar fine, k, bool splitprune, bool markorigin, bool finecfg, bool bitpar)\nProduce a white list of selected chart items.\n\n\tThe criterion is that they occur in the `k`-best derivations of ``chart``,\n\tor with posterior probability > `k`. Labels ``X`` in ``coarse.toid`` are\n\tprojected to the labels in the mapping of the fine grammar, e.g., to ``X``\n\tand ``X@n-m`` for a DOP reduction.\n\n\t:param coarsechart: a Chart object produced by the PCFG or PLCFRS parser,\n\t\tor derivations from bitpar.\n\t:param fine: the grammar to map labels to after pruning. must have a\n\t\tmapping to the coarse grammar established by ``fine.getmapping()``.\n\t:param k: when ``k >= 1``: number of `k`-best derivations to consider;\n\t\twhen ``k==0``, the chart is not pruned but filtered to contain only\n\t\titems that contribute to a complete derivation;\n\t\twhen ``0 < k < 1``, inside-outside probabilities are computed and items\n\t\twith a posterior probabilities < `k` are pruned.\n\t:param splitprune: coarse stage used a split-PCFG where discontinuous node\n\t\tappear as multiple CFG nodes. Every discontinuous node will result\n\t\tin multiple lookups into whitelist to see whether it should be\n\t\tallowed on the agenda.\n\t:param markorigin: in combination with splitprune, coarse labels include an\n\t\tinteger to distinguish components; e.g., CFG nodes NP*0 and NP*1\n\t\tmap to the discontinuous node NP_2.\n\t:param bitpar: prune from bitpar derivations instead of actual chart\n\t:returns: ``(whitelist, items, msg)``\n\n\tFor LCFRS, the white list is indexed as follows:\n\t\t\t:whitelisted: ``whitelist[label][item] == None``\n\t\t\t:blocked: ``item not in whitelist[label]``\n\n\tFor a CFG, indexing is as follows:\n\t\t:whitelisted: ``whitelist[span][label] == None``\n\t\t:blocked: ``label not in whitelist[cell]``\n\t";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_1prunechart = {"prunechart", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_1prunechart, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8discodop_12coarsetofine_prunechart};
static PyObject *__pyx_pw_8discodop_12coarsetofine_1prunechart(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_coarsechart = 0;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_fine = 0;
  PyObject *__pyx_v_k = 0;
  int __pyx_v_splitprune;
  int __pyx_v_markorigin;
  int __pyx_v_finecfg;
  int __pyx_v_bitpar;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("prunechart (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_coarsechart,&__pyx_n_s_fine,&__pyx_n_s_k,&__pyx_n_s_splitprune,&__pyx_n_s_markorigin,&__pyx_n_s_finecfg,&__pyx_n_s_bitpar,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_coarsechart)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fine)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 1); __PYX_ERR(0, 20, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 2); __PYX_ERR(0, 20, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_splitprune)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 3); __PYX_ERR(0, 20, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_markorigin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 4); __PYX_ERR(0, 20, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_finecfg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 5); __PYX_ERR(0, 20, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bitpar)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, 6); __PYX_ERR(0, 20, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "prunechart") < 0)) __PYX_ERR(0, 20, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_coarsechart = ((struct __pyx_obj_8discodop_10containers_Chart *)values[0]);
    __pyx_v_fine = ((struct __pyx_obj_8discodop_10containers_Grammar *)values[1]);
    __pyx_v_k = values[2];
    __pyx_v_splitprune = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_splitprune == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
    __pyx_v_markorigin = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_markorigin == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
    __pyx_v_finecfg = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_finecfg == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
    __pyx_v_bitpar = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_bitpar == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("prunechart", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 20, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("discodop.coarsetofine.prunechart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coarsechart), __pyx_ptype_8discodop_10containers_Chart, 1, "coarsechart", 0))) __PYX_ERR(0, 20, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fine), __pyx_ptype_8discodop_10containers_Grammar, 1, "fine", 0))) __PYX_ERR(0, 20, __pyx_L1_error)
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_prunechart(__pyx_self, __pyx_v_coarsechart, __pyx_v_fine, __pyx_v_k, __pyx_v_splitprune, __pyx_v_markorigin, __pyx_v_finecfg, __pyx_v_bitpar);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_prunechart(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_coarsechart, struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_fine, PyObject *__pyx_v_k, int __pyx_v_splitprune, int __pyx_v_markorigin, int __pyx_v_finecfg, int __pyx_v_bitpar) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_whitelist = 0;
  struct __pyx_obj_8discodop_10containers_ChartItem *__pyx_v_chartitem = 0;
  PyObject *__pyx_v_msg = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_cfgwhitelist = NULL;
  PyObject *__pyx_v_item = NULL;
  size_t __pyx_v_label;
  size_t __pyx_v_finespan;
  size_t __pyx_v_finelabel;
  PyObject *__pyx_v_kbestspans = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  size_t __pyx_t_11;
  size_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  int __pyx_t_16;
  uint32_t __pyx_t_17;
  uint8_t __pyx_t_18;
  uint8_t __pyx_t_19;
  __Pyx_RefNannySetupContext("prunechart", 0);

  /* "discodop/coarsetofine.pyx":59
 * 	cdef list whitelist
 * 	cdef ChartItem chartitem
 * 	if fine.mapping is NULL:             # <<<<<<<<<<<<<<
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:
 */
  __pyx_t_1 = ((__pyx_v_fine->mapping == NULL) != 0);
  if (__pyx_t_1) {

    /* "discodop/coarsetofine.pyx":60
 * 	cdef ChartItem chartitem
 * 	if fine.mapping is NULL:
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')             # <<<<<<<<<<<<<<
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 60, __pyx_L1_error)

    /* "discodop/coarsetofine.pyx":59
 * 	cdef list whitelist
 * 	cdef ChartItem chartitem
 * 	if fine.mapping is NULL:             # <<<<<<<<<<<<<<
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:
 */
  }

  /* "discodop/coarsetofine.pyx":61
 * 	if fine.mapping is NULL:
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:             # <<<<<<<<<<<<<<
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 */
  __pyx_t_3 = (__pyx_v_splitprune != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_markorigin != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "discodop/coarsetofine.pyx":62
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:             # <<<<<<<<<<<<<<
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	# prune coarse chart and collect items
 */
    __pyx_t_3 = ((__pyx_v_fine->splitmapping == NULL) != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_1 = __pyx_t_3;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = (((__pyx_v_fine->splitmapping[0]) == NULL) != 0);
    __pyx_t_1 = __pyx_t_3;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_1) {

      /* "discodop/coarsetofine.pyx":63
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')             # <<<<<<<<<<<<<<
 * 	# prune coarse chart and collect items
 * 	if 0 < k < 1:  # threshold on posterior probabilities
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_ERR(0, 63, __pyx_L1_error)

      /* "discodop/coarsetofine.pyx":62
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:             # <<<<<<<<<<<<<<
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	# prune coarse chart and collect items
 */
    }

    /* "discodop/coarsetofine.pyx":61
 * 	if fine.mapping is NULL:
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	if splitprune and markorigin:             # <<<<<<<<<<<<<<
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 */
  }

  /* "discodop/coarsetofine.pyx":65
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	# prune coarse chart and collect items
 * 	if 0 < k < 1:  # threshold on posterior probabilities             # <<<<<<<<<<<<<<
 * 		items, msg = posteriorthreshold(coarsechart, k)
 * 	else:  # construct a list of the k-best nonterminals to prune with
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_k, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_k, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "discodop/coarsetofine.pyx":66
 * 	# prune coarse chart and collect items
 * 	if 0 < k < 1:  # threshold on posterior probabilities
 * 		items, msg = posteriorthreshold(coarsechart, k)             # <<<<<<<<<<<<<<
 * 	else:  # construct a list of the k-best nonterminals to prune with
 * 		if bitpar:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_posteriorthreshold); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_coarsechart), __pyx_v_k};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_coarsechart), __pyx_v_k};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_coarsechart));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_coarsechart));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_coarsechart));
      __Pyx_INCREF(__pyx_v_k);
      __Pyx_GIVEREF(__pyx_v_k);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_k);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 66, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_8(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_7 = __pyx_t_8(__pyx_t_5); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_5), 2) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 66, __pyx_L1_error)
      __pyx_L12_unpacking_done:;
    }
    if (!(likely(PySet_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 66, __pyx_L1_error)
    __pyx_v_items = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_msg = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "discodop/coarsetofine.pyx":65
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')
 * 	# prune coarse chart and collect items
 * 	if 0 < k < 1:  # threshold on posterior probabilities             # <<<<<<<<<<<<<<
 * 		items, msg = posteriorthreshold(coarsechart, k)
 * 	else:  # construct a list of the k-best nonterminals to prune with
 */
    goto __pyx_L10;
  }

  /* "discodop/coarsetofine.pyx":68
 * 		items, msg = posteriorthreshold(coarsechart, k)
 * 	else:  # construct a list of the k-best nonterminals to prune with
 * 		if bitpar:             # <<<<<<<<<<<<<<
 * 			items = bitparkbestitems(coarsechart, k, finecfg)
 * 		elif k == 0:
 */
  /*else*/ {
    __pyx_t_1 = (__pyx_v_bitpar != 0);
    if (__pyx_t_1) {

      /* "discodop/coarsetofine.pyx":69
 * 	else:  # construct a list of the k-best nonterminals to prune with
 * 		if bitpar:
 * 			items = bitparkbestitems(coarsechart, k, finecfg)             # <<<<<<<<<<<<<<
 * 		elif k == 0:
 * 			coarsechart.filter()
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_bitparkbestitems); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_finecfg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_6 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_coarsechart), __pyx_v_k, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_coarsechart), __pyx_v_k, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (__pyx_t_5) {
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_coarsechart));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_coarsechart));
        PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, ((PyObject *)__pyx_v_coarsechart));
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_v_k);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_6, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(PySet_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 69, __pyx_L1_error)
      __pyx_v_items = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":68
 * 		items, msg = posteriorthreshold(coarsechart, k)
 * 	else:  # construct a list of the k-best nonterminals to prune with
 * 		if bitpar:             # <<<<<<<<<<<<<<
 * 			items = bitparkbestitems(coarsechart, k, finecfg)
 * 		elif k == 0:
 */
      goto __pyx_L13;
    }

    /* "discodop/coarsetofine.pyx":70
 * 		if bitpar:
 * 			items = bitparkbestitems(coarsechart, k, finecfg)
 * 		elif k == 0:             # <<<<<<<<<<<<<<
 * 			coarsechart.filter()
 * 			items = set(coarsechart.getitems())
 */
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_k, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_1) {

      /* "discodop/coarsetofine.pyx":71
 * 			items = bitparkbestitems(coarsechart, k, finecfg)
 * 		elif k == 0:
 * 			coarsechart.filter()             # <<<<<<<<<<<<<<
 * 			items = set(coarsechart.getitems())
 * 		else:
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_coarsechart), __pyx_n_s_filter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":72
 * 		elif k == 0:
 * 			coarsechart.filter()
 * 			items = set(coarsechart.getitems())             # <<<<<<<<<<<<<<
 * 		else:
 * 			_ = lazykbest(coarsechart, k, derivs=False)
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_coarsechart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PySet_New(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_items = ((PyObject*)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "discodop/coarsetofine.pyx":70
 * 		if bitpar:
 * 			items = bitparkbestitems(coarsechart, k, finecfg)
 * 		elif k == 0:             # <<<<<<<<<<<<<<
 * 			coarsechart.filter()
 * 			items = set(coarsechart.getitems())
 */
      goto __pyx_L13;
    }

    /* "discodop/coarsetofine.pyx":74
 * 			items = set(coarsechart.getitems())
 * 		else:
 * 			_ = lazykbest(coarsechart, k, derivs=False)             # <<<<<<<<<<<<<<
 * 			items = set(coarsechart.rankededges)
 * 		msg = ('coarse items before pruning: %d; after: %d, '
 */
    /*else*/ {
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_lazykbest); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 74, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_coarsechart));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_coarsechart));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_coarsechart));
      __Pyx_INCREF(__pyx_v_k);
      __Pyx_GIVEREF(__pyx_v_k);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_k);
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 74, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_derivs, Py_False) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v__ = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "discodop/coarsetofine.pyx":75
 * 		else:
 * 			_ = lazykbest(coarsechart, k, derivs=False)
 * 			items = set(coarsechart.rankededges)             # <<<<<<<<<<<<<<
 * 		msg = ('coarse items before pruning: %d; after: %d, '
 * 				'based on %d/%d derivations' % (
 */
      __pyx_t_4 = PySet_New(__pyx_v_coarsechart->rankededges); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_items = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L13:;

    /* "discodop/coarsetofine.pyx":78
 * 		msg = ('coarse items before pruning: %d; after: %d, '
 * 				'based on %d/%d derivations' % (
 * 				len(coarsechart.getitems()), len(items),             # <<<<<<<<<<<<<<
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))
 * 	# project items to fine grammar
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_coarsechart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_v_items == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 78, __pyx_L1_error)
    }
    __pyx_t_10 = PySet_GET_SIZE(__pyx_v_items); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "discodop/coarsetofine.pyx":79
 * 				'based on %d/%d derivations' % (
 * 				len(coarsechart.getitems()), len(items),
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))             # <<<<<<<<<<<<<<
 * 	# project items to fine grammar
 * 	if finecfg:
 */
    if (unlikely(__pyx_v_coarsechart->rankededges == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 79, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_coarsechart), __pyx_n_s_root); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_coarsechart->rankededges, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_7, 0, 0, NULL, &__pyx_v_k, NULL, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_10 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 79, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);

    /* "discodop/coarsetofine.pyx":78
 * 		msg = ('coarse items before pruning: %d; after: %d, '
 * 				'based on %d/%d derivations' % (
 * 				len(coarsechart.getitems()), len(items),             # <<<<<<<<<<<<<<
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))
 * 	# project items to fine grammar
 */
    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_k);
    __pyx_t_4 = 0;
    __pyx_t_9 = 0;
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":77
 * 			items = set(coarsechart.rankededges)
 * 		msg = ('coarse items before pruning: %d; after: %d, '
 * 				'based on %d/%d derivations' % (             # <<<<<<<<<<<<<<
 * 				len(coarsechart.getitems()), len(items),
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))
 */
    __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_coarse_items_before_pruning_d_af, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_msg = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L10:;

  /* "discodop/coarsetofine.pyx":81
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))
 * 	# project items to fine grammar
 * 	if finecfg:             # <<<<<<<<<<<<<<
 * 		cfgwhitelist = [set() for _ in range(compactcellidx(
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 */
  __pyx_t_1 = (__pyx_v_finecfg != 0);
  if (__pyx_t_1) {

    /* "discodop/coarsetofine.pyx":82
 * 	# project items to fine grammar
 * 	if finecfg:
 * 		cfgwhitelist = [set() for _ in range(compactcellidx(             # <<<<<<<<<<<<<<
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 * 				coarsechart.lensent, 1) + 1)]
 */
    { /* enter inner scope */
      CYTHON_UNUSED size_t __pyx_7genexpr__pyx_v__;
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

      /* "discodop/coarsetofine.pyx":84
 * 		cfgwhitelist = [set() for _ in range(compactcellidx(
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 * 				coarsechart.lensent, 1) + 1)]             # <<<<<<<<<<<<<<
 * 		for item in items:
 * 			label = coarsechart.label(item)
 */
      __pyx_t_11 = (__pyx_f_8discodop_10containers_compactcellidx((__pyx_v_coarsechart->lensent - 1), __pyx_v_coarsechart->lensent, __pyx_v_coarsechart->lensent, 1) + 1);

      /* "discodop/coarsetofine.pyx":82
 * 	# project items to fine grammar
 * 	if finecfg:
 * 		cfgwhitelist = [set() for _ in range(compactcellidx(             # <<<<<<<<<<<<<<
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 * 				coarsechart.lensent, 1) + 1)]
 */
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
        __pyx_7genexpr__pyx_v__ = __pyx_t_12;
        __pyx_t_7 = PySet_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 82, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 82, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    } /* exit inner scope */
    __pyx_v_cfgwhitelist = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":85
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 * 				coarsechart.lensent, 1) + 1)]
 * 		for item in items:             # <<<<<<<<<<<<<<
 * 			label = coarsechart.label(item)
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 */
    __pyx_t_2 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 85, __pyx_L1_error)
    for (;;) {
      {
        __pyx_t_7 = __pyx_t_13(__pyx_t_2);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 85, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "discodop/coarsetofine.pyx":86
 * 				coarsechart.lensent, 1) + 1)]
 * 		for item in items:
 * 			label = coarsechart.label(item)             # <<<<<<<<<<<<<<
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 * 			for finelabel in range(1, fine.nonterminals):
 */
      __pyx_v_label = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_coarsechart->__pyx_vtab)->label(__pyx_v_coarsechart, __pyx_v_item);

      /* "discodop/coarsetofine.pyx":87
 * 		for item in items:
 * 			label = coarsechart.label(item)
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)             # <<<<<<<<<<<<<<
 * 			for finelabel in range(1, fine.nonterminals):
 * 				if (fine.mapping[finelabel] == 0
 */
      __pyx_v_finespan = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_coarsechart->__pyx_vtab)->asCFGspan(__pyx_v_coarsechart, __pyx_v_item, __pyx_v_fine->nonterminals);

      /* "discodop/coarsetofine.pyx":88
 * 			label = coarsechart.label(item)
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 * 			for finelabel in range(1, fine.nonterminals):             # <<<<<<<<<<<<<<
 * 				if (fine.mapping[finelabel] == 0
 * 						or fine.mapping[finelabel] == label):
 */
      __pyx_t_11 = __pyx_v_fine->nonterminals;
      for (__pyx_t_12 = 1; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
        __pyx_v_finelabel = __pyx_t_12;

        /* "discodop/coarsetofine.pyx":89
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 * 			for finelabel in range(1, fine.nonterminals):
 * 				if (fine.mapping[finelabel] == 0             # <<<<<<<<<<<<<<
 * 						or fine.mapping[finelabel] == label):
 * 					cfgwhitelist[finespan].add(finelabel)
 */
        __pyx_t_3 = (((__pyx_v_fine->mapping[__pyx_v_finelabel]) == 0) != 0);
        if (!__pyx_t_3) {
        } else {
          __pyx_t_1 = __pyx_t_3;
          goto __pyx_L22_bool_binop_done;
        }

        /* "discodop/coarsetofine.pyx":90
 * 			for finelabel in range(1, fine.nonterminals):
 * 				if (fine.mapping[finelabel] == 0
 * 						or fine.mapping[finelabel] == label):             # <<<<<<<<<<<<<<
 * 					cfgwhitelist[finespan].add(finelabel)
 * 		return cfgwhitelist, None, msg
 */
        __pyx_t_3 = (((__pyx_v_fine->mapping[__pyx_v_finelabel]) == __pyx_v_label) != 0);
        __pyx_t_1 = __pyx_t_3;
        __pyx_L22_bool_binop_done:;

        /* "discodop/coarsetofine.pyx":89
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 * 			for finelabel in range(1, fine.nonterminals):
 * 				if (fine.mapping[finelabel] == 0             # <<<<<<<<<<<<<<
 * 						or fine.mapping[finelabel] == label):
 * 					cfgwhitelist[finespan].add(finelabel)
 */
        if (__pyx_t_1) {

          /* "discodop/coarsetofine.pyx":91
 * 				if (fine.mapping[finelabel] == 0
 * 						or fine.mapping[finelabel] == label):
 * 					cfgwhitelist[finespan].add(finelabel)             # <<<<<<<<<<<<<<
 * 		return cfgwhitelist, None, msg
 * 	else:
 */
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_cfgwhitelist, __pyx_v_finespan), __pyx_n_s_add); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 91, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_finelabel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_5)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
            }
          }
          if (!__pyx_t_5) {
            __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_7);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
              __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
              PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
              __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else
            #endif
            {
              __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 91, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
              __Pyx_GIVEREF(__pyx_t_4);
              PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_4);
              __pyx_t_4 = 0;
              __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "discodop/coarsetofine.pyx":89
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 * 			for finelabel in range(1, fine.nonterminals):
 * 				if (fine.mapping[finelabel] == 0             # <<<<<<<<<<<<<<
 * 						or fine.mapping[finelabel] == label):
 * 					cfgwhitelist[finespan].add(finelabel)
 */
        }
      }

      /* "discodop/coarsetofine.pyx":85
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 * 				coarsechart.lensent, 1) + 1)]
 * 		for item in items:             # <<<<<<<<<<<<<<
 * 			label = coarsechart.label(item)
 * 			finespan = coarsechart.asCFGspan(item, fine.nonterminals)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":92
 * 						or fine.mapping[finelabel] == label):
 * 					cfgwhitelist[finespan].add(finelabel)
 * 		return cfgwhitelist, None, msg             # <<<<<<<<<<<<<<
 * 	else:
 * 		whitelist = [None] * fine.nonterminals
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_cfgwhitelist);
    __Pyx_GIVEREF(__pyx_v_cfgwhitelist);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_cfgwhitelist);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_msg);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "discodop/coarsetofine.pyx":81
 * 				len(coarsechart.rankededges[coarsechart.root()][:k]), k))
 * 	# project items to fine grammar
 * 	if finecfg:             # <<<<<<<<<<<<<<
 * 		cfgwhitelist = [set() for _ in range(compactcellidx(
 * 				coarsechart.lensent - 1, coarsechart.lensent,
 */
  }

  /* "discodop/coarsetofine.pyx":94
 * 		return cfgwhitelist, None, msg
 * 	else:
 * 		whitelist = [None] * fine.nonterminals             # <<<<<<<<<<<<<<
 * 		kbestspans = [set() for _ in coarsechart.grammar.toid]
 * 		kbestspans[0] = None
 */
  /*else*/ {
    __pyx_t_2 = PyList_New(1 * (__pyx_v_fine->nonterminals)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_fine->nonterminals; __pyx_temp++) {
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        PyList_SET_ITEM(__pyx_t_2, __pyx_temp, Py_None);
      }
    }
    __pyx_v_whitelist = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":95
 * 	else:
 * 		whitelist = [None] * fine.nonterminals
 * 		kbestspans = [set() for _ in coarsechart.grammar.toid]             # <<<<<<<<<<<<<<
 * 		kbestspans[0] = None
 * 		# uses ids of labels in coarse chart
 */
    { /* enter inner scope */
      CYTHON_UNUSED PyObject *__pyx_8genexpr1__pyx_v__ = NULL;
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L26_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = 0;
      if (unlikely(__pyx_v_coarsechart->grammar->toid == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 95, __pyx_L26_error)
      }
      __pyx_t_9 = __Pyx_dict_iterator(__pyx_v_coarsechart->grammar->toid, 1, ((PyObject *)NULL), (&__pyx_t_15), (&__pyx_t_6)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L26_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_7);
      __pyx_t_7 = __pyx_t_9;
      __pyx_t_9 = 0;
      while (1) {
        __pyx_t_16 = __Pyx_dict_iter_next(__pyx_t_7, __pyx_t_15, &__pyx_t_10, &__pyx_t_9, NULL, NULL, __pyx_t_6);
        if (unlikely(__pyx_t_16 == 0)) break;
        if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 95, __pyx_L26_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v__, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_9 = PySet_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 95, __pyx_L26_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 95, __pyx_L26_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_8genexpr1__pyx_v__);
      goto __pyx_L29_exit_scope;
      __pyx_L26_error:;
      __Pyx_XDECREF(__pyx_8genexpr1__pyx_v__);
      goto __pyx_L1_error;
      __pyx_L29_exit_scope:;
    } /* exit inner scope */
    __pyx_v_kbestspans = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":96
 * 		whitelist = [None] * fine.nonterminals
 * 		kbestspans = [set() for _ in coarsechart.grammar.toid]
 * 		kbestspans[0] = None             # <<<<<<<<<<<<<<
 * 		# uses ids of labels in coarse chart
 * 		for item in items:
 */
    if (unlikely(__Pyx_SetItemInt(__pyx_v_kbestspans, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 96, __pyx_L1_error)

    /* "discodop/coarsetofine.pyx":98
 * 		kbestspans[0] = None
 * 		# uses ids of labels in coarse chart
 * 		for item in items:             # <<<<<<<<<<<<<<
 * 			# we can use coarsechart here because we only use the item to
 * 			# define a span, which is the same for the fine chart.
 */
    __pyx_t_2 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 98, __pyx_L1_error)
    for (;;) {
      {
        __pyx_t_7 = __pyx_t_13(__pyx_t_2);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 98, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
      __pyx_t_7 = 0;

      /* "discodop/coarsetofine.pyx":101
 * 			# we can use coarsechart here because we only use the item to
 * 			# define a span, which is the same for the fine chart.
 * 			chartitem = coarsechart.asChartItem(item)             # <<<<<<<<<<<<<<
 * 			label = chartitem.label
 * 			chartitem.label = 0
 */
      __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_coarsechart->__pyx_vtab)->asChartItem(__pyx_v_coarsechart, __pyx_v_item)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 101, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_XDECREF_SET(__pyx_v_chartitem, ((struct __pyx_obj_8discodop_10containers_ChartItem *)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "discodop/coarsetofine.pyx":102
 * 			# define a span, which is the same for the fine chart.
 * 			chartitem = coarsechart.asChartItem(item)
 * 			label = chartitem.label             # <<<<<<<<<<<<<<
 * 			chartitem.label = 0
 * 			kbestspans[label].add(chartitem)
 */
      __pyx_t_17 = __pyx_v_chartitem->label;
      __pyx_v_label = __pyx_t_17;

      /* "discodop/coarsetofine.pyx":103
 * 			chartitem = coarsechart.asChartItem(item)
 * 			label = chartitem.label
 * 			chartitem.label = 0             # <<<<<<<<<<<<<<
 * 			kbestspans[label].add(chartitem)
 * 		# now construct a list which references these coarse items:
 */
      __pyx_v_chartitem->label = 0;

      /* "discodop/coarsetofine.pyx":104
 * 			label = chartitem.label
 * 			chartitem.label = 0
 * 			kbestspans[label].add(chartitem)             # <<<<<<<<<<<<<<
 * 		# now construct a list which references these coarse items:
 * 		for label in range(fine.nonterminals):
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(PyList_GET_ITEM(__pyx_v_kbestspans, __pyx_v_label), __pyx_n_s_add); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_14 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_chartitem)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_chartitem)};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_chartitem)};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_7);
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_14); __pyx_t_14 = NULL;
          __Pyx_INCREF(((PyObject *)__pyx_v_chartitem));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_chartitem));
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_chartitem));
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 104, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "discodop/coarsetofine.pyx":98
 * 		kbestspans[0] = None
 * 		# uses ids of labels in coarse chart
 * 		for item in items:             # <<<<<<<<<<<<<<
 * 			# we can use coarsechart here because we only use the item to
 * 			# define a span, which is the same for the fine chart.
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":106
 * 			kbestspans[label].add(chartitem)
 * 		# now construct a list which references these coarse items:
 * 		for label in range(fine.nonterminals):             # <<<<<<<<<<<<<<
 * 			if splitprune and markorigin and fine.fanout[label] != 1:
 * 				if fine.splitmapping[label] is not NULL:
 */
    __pyx_t_11 = __pyx_v_fine->nonterminals;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_label = __pyx_t_12;

      /* "discodop/coarsetofine.pyx":107
 * 		# now construct a list which references these coarse items:
 * 		for label in range(fine.nonterminals):
 * 			if splitprune and markorigin and fine.fanout[label] != 1:             # <<<<<<<<<<<<<<
 * 				if fine.splitmapping[label] is not NULL:
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]
 */
      __pyx_t_3 = (__pyx_v_splitprune != 0);
      if (__pyx_t_3) {
      } else {
        __pyx_t_1 = __pyx_t_3;
        goto __pyx_L35_bool_binop_done;
      }
      __pyx_t_3 = (__pyx_v_markorigin != 0);
      if (__pyx_t_3) {
      } else {
        __pyx_t_1 = __pyx_t_3;
        goto __pyx_L35_bool_binop_done;
      }
      __pyx_t_3 = (((__pyx_v_fine->fanout[__pyx_v_label]) != 1) != 0);
      __pyx_t_1 = __pyx_t_3;
      __pyx_L35_bool_binop_done:;
      if (__pyx_t_1) {

        /* "discodop/coarsetofine.pyx":108
 * 		for label in range(fine.nonterminals):
 * 			if splitprune and markorigin and fine.fanout[label] != 1:
 * 				if fine.splitmapping[label] is not NULL:             # <<<<<<<<<<<<<<
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]
 * 							for n in range(fine.fanout[label])]
 */
        __pyx_t_1 = (((__pyx_v_fine->splitmapping[__pyx_v_label]) != NULL) != 0);
        if (__pyx_t_1) {

          /* "discodop/coarsetofine.pyx":109
 * 			if splitprune and markorigin and fine.fanout[label] != 1:
 * 				if fine.splitmapping[label] is not NULL:
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]             # <<<<<<<<<<<<<<
 * 							for n in range(fine.fanout[label])]
 * 			else:
 */
          { /* enter inner scope */
            uint8_t __pyx_8genexpr2__pyx_v_n;
            __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);

            /* "discodop/coarsetofine.pyx":110
 * 				if fine.splitmapping[label] is not NULL:
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]
 * 							for n in range(fine.fanout[label])]             # <<<<<<<<<<<<<<
 * 			else:
 * 				if fine.mapping[label] != 0:
 */
            __pyx_t_18 = (__pyx_v_fine->fanout[__pyx_v_label]);
            for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
              __pyx_8genexpr2__pyx_v_n = __pyx_t_19;

              /* "discodop/coarsetofine.pyx":109
 * 			if splitprune and markorigin and fine.fanout[label] != 1:
 * 				if fine.splitmapping[label] is not NULL:
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]             # <<<<<<<<<<<<<<
 * 							for n in range(fine.fanout[label])]
 * 			else:
 */
              if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)PyList_GET_ITEM(__pyx_v_kbestspans, ((__pyx_v_fine->splitmapping[__pyx_v_label])[__pyx_8genexpr2__pyx_v_n]))))) __PYX_ERR(0, 109, __pyx_L1_error)
            }
          } /* exit inner scope */
          if (unlikely(__Pyx_SetItemInt(__pyx_v_whitelist, __pyx_v_label, __pyx_t_2, size_t, 0, __Pyx_PyInt_FromSize_t, 1, 0, 0) < 0)) __PYX_ERR(0, 109, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":108
 * 		for label in range(fine.nonterminals):
 * 			if splitprune and markorigin and fine.fanout[label] != 1:
 * 				if fine.splitmapping[label] is not NULL:             # <<<<<<<<<<<<<<
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]
 * 							for n in range(fine.fanout[label])]
 */
        }

        /* "discodop/coarsetofine.pyx":107
 * 		# now construct a list which references these coarse items:
 * 		for label in range(fine.nonterminals):
 * 			if splitprune and markorigin and fine.fanout[label] != 1:             # <<<<<<<<<<<<<<
 * 				if fine.splitmapping[label] is not NULL:
 * 					whitelist[label] = [kbestspans[fine.splitmapping[label][n]]
 */
        goto __pyx_L34;
      }

      /* "discodop/coarsetofine.pyx":112
 * 							for n in range(fine.fanout[label])]
 * 			else:
 * 				if fine.mapping[label] != 0:             # <<<<<<<<<<<<<<
 * 					whitelist[label] = kbestspans[fine.mapping[label]]
 * 		return whitelist, items, msg
 */
      /*else*/ {
        __pyx_t_1 = (((__pyx_v_fine->mapping[__pyx_v_label]) != 0) != 0);
        if (__pyx_t_1) {

          /* "discodop/coarsetofine.pyx":113
 * 			else:
 * 				if fine.mapping[label] != 0:
 * 					whitelist[label] = kbestspans[fine.mapping[label]]             # <<<<<<<<<<<<<<
 * 		return whitelist, items, msg
 * 
 */
          __pyx_t_2 = PyList_GET_ITEM(__pyx_v_kbestspans, (__pyx_v_fine->mapping[__pyx_v_label]));
          __Pyx_INCREF(__pyx_t_2);
          if (unlikely(__Pyx_SetItemInt(__pyx_v_whitelist, __pyx_v_label, __pyx_t_2, size_t, 0, __Pyx_PyInt_FromSize_t, 1, 0, 0) < 0)) __PYX_ERR(0, 113, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":112
 * 							for n in range(fine.fanout[label])]
 * 			else:
 * 				if fine.mapping[label] != 0:             # <<<<<<<<<<<<<<
 * 					whitelist[label] = kbestspans[fine.mapping[label]]
 * 		return whitelist, items, msg
 */
        }
      }
      __pyx_L34:;
    }

    /* "discodop/coarsetofine.pyx":114
 * 				if fine.mapping[label] != 0:
 * 					whitelist[label] = kbestspans[fine.mapping[label]]
 * 		return whitelist, items, msg             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_whitelist);
    __Pyx_GIVEREF(__pyx_v_whitelist);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_whitelist);
    __Pyx_INCREF(__pyx_v_items);
    __Pyx_GIVEREF(__pyx_v_items);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_items);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_msg);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "discodop/coarsetofine.pyx":20
 * 
 * 
 * def prunechart(Chart coarsechart, Grammar fine, k,             # <<<<<<<<<<<<<<
 * 		bint splitprune, bint markorigin, bint finecfg, bint bitpar):
 * 	"""Produce a white list of selected chart items.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("discodop.coarsetofine.prunechart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_whitelist);
  __Pyx_XDECREF((PyObject *)__pyx_v_chartitem);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_cfgwhitelist);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_kbestspans);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":117
 * 
 * 
 * def bitparkbestitems(Chart chart, int k, bint finecfg):             # <<<<<<<<<<<<<<
 * 	"""Produce ChartItems occurring in a dictionary of derivations.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_3bitparkbestitems(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_2bitparkbestitems[] = "bitparkbestitems(Chart chart, int k, bool finecfg)\nProduce ChartItems occurring in a dictionary of derivations.\n\n\t:param chart: a chart where rankededges is a dictionary of CFG derivations.\n\t:returns: a dictionary of ChartItems (mapping to None) occurring in the\n\t\tderivations.";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_3bitparkbestitems = {"bitparkbestitems", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_3bitparkbestitems, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8discodop_12coarsetofine_2bitparkbestitems};
static PyObject *__pyx_pw_8discodop_12coarsetofine_3bitparkbestitems(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart = 0;
  int __pyx_v_k;
  int __pyx_v_finecfg;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bitparkbestitems (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chart,&__pyx_n_s_k,&__pyx_n_s_finecfg,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chart)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("bitparkbestitems", 1, 3, 3, 1); __PYX_ERR(0, 117, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_finecfg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("bitparkbestitems", 1, 3, 3, 2); __PYX_ERR(0, 117, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bitparkbestitems") < 0)) __PYX_ERR(0, 117, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_chart = ((struct __pyx_obj_8discodop_10containers_Chart *)values[0]);
    __pyx_v_k = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L3_error)
    __pyx_v_finecfg = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_finecfg == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("bitparkbestitems", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 117, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("discodop.coarsetofine.bitparkbestitems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chart), __pyx_ptype_8discodop_10containers_Chart, 1, "chart", 0))) __PYX_ERR(0, 117, __pyx_L1_error)
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_2bitparkbestitems(__pyx_self, __pyx_v_chart, __pyx_v_k, __pyx_v_finecfg);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_2bitparkbestitems(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart, int __pyx_v_k, int __pyx_v_finecfg) {
  int __pyx_v_fatitems;
  PyObject *__pyx_v_derivs = 0;
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_deriv = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_n = NULL;
  PyObject *__pyx_v_label = NULL;
  PyObject *__pyx_v_leaves = NULL;
  PyObject *__pyx_v_start = NULL;
  PyObject *__pyx_v_end = NULL;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  short __pyx_t_11;
  short __pyx_t_12;
  uint32_t __pyx_t_13;
  __pyx_t_8discodop_10containers_Idx __pyx_t_14;
  __pyx_t_8discodop_10containers_Idx __pyx_t_15;
  int __pyx_t_16;
  __Pyx_RefNannySetupContext("bitparkbestitems", 0);

  /* "discodop/coarsetofine.pyx":123
 * 	:returns: a dictionary of ChartItems (mapping to None) occurring in the
 * 		derivations."""
 * 	cdef bint fatitems = chart.lensent >= (sizeof(uint64_t) * 8)             # <<<<<<<<<<<<<<
 * 	cdef list derivs = chart.rankededges[chart.root()]
 * 	cdef set items = set()
 */
  __pyx_v_fatitems = (__pyx_v_chart->lensent >= ((sizeof(uint64_t)) * 8));

  /* "discodop/coarsetofine.pyx":124
 * 		derivations."""
 * 	cdef bint fatitems = chart.lensent >= (sizeof(uint64_t) * 8)
 * 	cdef list derivs = chart.rankededges[chart.root()]             # <<<<<<<<<<<<<<
 * 	cdef set items = set()
 * 	for deriv, _ in derivs[:k]:
 */
  if (unlikely(__pyx_v_chart->rankededges == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 124, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_root); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_chart->rankededges, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 124, __pyx_L1_error)
  __pyx_v_derivs = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":125
 * 	cdef bint fatitems = chart.lensent >= (sizeof(uint64_t) * 8)
 * 	cdef list derivs = chart.rankededges[chart.root()]
 * 	cdef set items = set()             # <<<<<<<<<<<<<<
 * 	for deriv, _ in derivs[:k]:
 * 		t = Tree(deriv)
 */
  __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_items = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":126
 * 	cdef list derivs = chart.rankededges[chart.root()]
 * 	cdef set items = set()
 * 	for deriv, _ in derivs[:k]:             # <<<<<<<<<<<<<<
 * 		t = Tree(deriv)
 * 		for n in t.subtrees():
 */
  if (unlikely(__pyx_v_derivs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 126, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_derivs, 0, __pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 126, __pyx_L1_error)
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 126, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 126, __pyx_L1_error)
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 126, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_deriv, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "discodop/coarsetofine.pyx":127
 * 	cdef set items = set()
 * 	for deriv, _ in derivs[:k]:
 * 		t = Tree(deriv)             # <<<<<<<<<<<<<<
 * 		for n in t.subtrees():
 * 			label = chart.grammar.toid[n.label]
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Tree); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_deriv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_deriv};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_deriv};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_INCREF(__pyx_v_deriv);
        __Pyx_GIVEREF(__pyx_v_deriv);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_deriv);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":128
 * 	for deriv, _ in derivs[:k]:
 * 		t = Tree(deriv)
 * 		for n in t.subtrees():             # <<<<<<<<<<<<<<
 * 			label = chart.grammar.toid[n.label]
 * 			leaves = n.leaves()
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_t, __pyx_n_s_subtrees); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_5 = __pyx_t_2; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 128, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 128, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 128, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_9(__pyx_t_5);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 128, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":129
 * 		t = Tree(deriv)
 * 		for n in t.subtrees():
 * 			label = chart.grammar.toid[n.label]             # <<<<<<<<<<<<<<
 * 			leaves = n.leaves()
 * 			start = min(leaves)
 */
      if (unlikely(__pyx_v_chart->grammar->toid == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 129, __pyx_L1_error)
      }
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_n, __pyx_n_s_label); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_chart->grammar->toid, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_label, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "discodop/coarsetofine.pyx":130
 * 		for n in t.subtrees():
 * 			label = chart.grammar.toid[n.label]
 * 			leaves = n.leaves()             # <<<<<<<<<<<<<<
 * 			start = min(leaves)
 * 			end = max(leaves) + 1
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_n, __pyx_n_s_leaves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 130, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_leaves, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "discodop/coarsetofine.pyx":131
 * 			label = chart.grammar.toid[n.label]
 * 			leaves = n.leaves()
 * 			start = min(leaves)             # <<<<<<<<<<<<<<
 * 			end = max(leaves) + 1
 * 			if finecfg:
 */
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_leaves);
      __Pyx_GIVEREF(__pyx_v_leaves);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_leaves);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_min, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_start, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":132
 * 			leaves = n.leaves()
 * 			start = min(leaves)
 * 			end = max(leaves) + 1             # <<<<<<<<<<<<<<
 * 			if finecfg:
 * 				# create a cellidx to the coarse chart here,
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_leaves);
      __Pyx_GIVEREF(__pyx_v_leaves);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_leaves);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 132, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_end, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":133
 * 			start = min(leaves)
 * 			end = max(leaves) + 1
 * 			if finecfg:             # <<<<<<<<<<<<<<
 * 				# create a cellidx to the coarse chart here,
 * 				# only to convert it to a cellidx for the fine chart later...
 */
      __pyx_t_10 = (__pyx_v_finecfg != 0);
      if (__pyx_t_10) {

        /* "discodop/coarsetofine.pyx":136
 * 				# create a cellidx to the coarse chart here,
 * 				# only to convert it to a cellidx for the fine chart later...
 * 				item = cellidx(start, end, chart.lensent,             # <<<<<<<<<<<<<<
 * 						chart.grammar.nonterminals) + label
 * 			elif fatitems:
 */
        __pyx_t_11 = __Pyx_PyInt_As_short(__pyx_v_start); if (unlikely((__pyx_t_11 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L1_error)
        __pyx_t_12 = __Pyx_PyInt_As_short(__pyx_v_end); if (unlikely((__pyx_t_12 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L1_error)

        /* "discodop/coarsetofine.pyx":137
 * 				# only to convert it to a cellidx for the fine chart later...
 * 				item = cellidx(start, end, chart.lensent,
 * 						chart.grammar.nonterminals) + label             # <<<<<<<<<<<<<<
 * 			elif fatitems:
 * 				item = CFGtoFatChartItem(label, start, end)
 */
        __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_f_8discodop_10containers_cellidx(__pyx_t_11, __pyx_t_12, __pyx_v_chart->lensent, __pyx_v_chart->grammar->nonterminals)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_v_label); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
        __pyx_t_6 = 0;

        /* "discodop/coarsetofine.pyx":133
 * 			start = min(leaves)
 * 			end = max(leaves) + 1
 * 			if finecfg:             # <<<<<<<<<<<<<<
 * 				# create a cellidx to the coarse chart here,
 * 				# only to convert it to a cellidx for the fine chart later...
 */
        goto __pyx_L9;
      }

      /* "discodop/coarsetofine.pyx":138
 * 				item = cellidx(start, end, chart.lensent,
 * 						chart.grammar.nonterminals) + label
 * 			elif fatitems:             # <<<<<<<<<<<<<<
 * 				item = CFGtoFatChartItem(label, start, end)
 * 			else:
 */
      __pyx_t_10 = (__pyx_v_fatitems != 0);
      if (__pyx_t_10) {

        /* "discodop/coarsetofine.pyx":139
 * 						chart.grammar.nonterminals) + label
 * 			elif fatitems:
 * 				item = CFGtoFatChartItem(label, start, end)             # <<<<<<<<<<<<<<
 * 			else:
 * 				item = CFGtoSmallChartItem(label, start, end)
 */
        __pyx_t_13 = __Pyx_PyInt_As_uint32_t(__pyx_v_label); if (unlikely((__pyx_t_13 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L1_error)
        __pyx_t_14 = __Pyx_PyInt_As_uint8_t(__pyx_v_start); if (unlikely((__pyx_t_14 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L1_error)
        __pyx_t_15 = __Pyx_PyInt_As_uint8_t(__pyx_v_end); if (unlikely((__pyx_t_15 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L1_error)
        __pyx_t_6 = ((PyObject *)__pyx_f_8discodop_10containers_CFGtoFatChartItem(__pyx_t_13, __pyx_t_14, __pyx_t_15)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 139, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
        __pyx_t_6 = 0;

        /* "discodop/coarsetofine.pyx":138
 * 				item = cellidx(start, end, chart.lensent,
 * 						chart.grammar.nonterminals) + label
 * 			elif fatitems:             # <<<<<<<<<<<<<<
 * 				item = CFGtoFatChartItem(label, start, end)
 * 			else:
 */
        goto __pyx_L9;
      }

      /* "discodop/coarsetofine.pyx":141
 * 				item = CFGtoFatChartItem(label, start, end)
 * 			else:
 * 				item = CFGtoSmallChartItem(label, start, end)             # <<<<<<<<<<<<<<
 * 			items.add(item)
 * 	return items
 */
      /*else*/ {
        __pyx_t_13 = __Pyx_PyInt_As_uint32_t(__pyx_v_label); if (unlikely((__pyx_t_13 == ((uint32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
        __pyx_t_15 = __Pyx_PyInt_As_uint8_t(__pyx_v_start); if (unlikely((__pyx_t_15 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
        __pyx_t_14 = __Pyx_PyInt_As_uint8_t(__pyx_v_end); if (unlikely((__pyx_t_14 == ((uint8_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
        __pyx_t_6 = ((PyObject *)__pyx_f_8discodop_10containers_CFGtoSmallChartItem(__pyx_t_13, __pyx_t_15, __pyx_t_14)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
        __pyx_t_6 = 0;
      }
      __pyx_L9:;

      /* "discodop/coarsetofine.pyx":142
 * 			else:
 * 				item = CFGtoSmallChartItem(label, start, end)
 * 			items.add(item)             # <<<<<<<<<<<<<<
 * 	return items
 * 
 */
      __pyx_t_16 = PySet_Add(__pyx_v_items, __pyx_v_item); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 142, __pyx_L1_error)

      /* "discodop/coarsetofine.pyx":128
 * 	for deriv, _ in derivs[:k]:
 * 		t = Tree(deriv)
 * 		for n in t.subtrees():             # <<<<<<<<<<<<<<
 * 			label = chart.grammar.toid[n.label]
 * 			leaves = n.leaves()
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "discodop/coarsetofine.pyx":126
 * 	cdef list derivs = chart.rankededges[chart.root()]
 * 	cdef set items = set()
 * 	for deriv, _ in derivs[:k]:             # <<<<<<<<<<<<<<
 * 		t = Tree(deriv)
 * 		for n in t.subtrees():
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":143
 * 				item = CFGtoSmallChartItem(label, start, end)
 * 			items.add(item)
 * 	return items             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_items);
  __pyx_r = __pyx_v_items;
  goto __pyx_L0;

  /* "discodop/coarsetofine.pyx":117
 * 
 * 
 * def bitparkbestitems(Chart chart, int k, bint finecfg):             # <<<<<<<<<<<<<<
 * 	"""Produce ChartItems occurring in a dictionary of derivations.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("discodop.coarsetofine.bitparkbestitems", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_derivs);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_deriv);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_label);
  __Pyx_XDECREF(__pyx_v_leaves);
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":146
 * 
 * 
 * def posteriorthreshold(Chart chart, double threshold):             # <<<<<<<<<<<<<<
 * 	"""Prune labeled spans from chart below given posterior threshold.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_5posteriorthreshold(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_4posteriorthreshold[] = "posteriorthreshold(Chart chart, double threshold)\nPrune labeled spans from chart below given posterior threshold.\n\n\t:returns: dictionary of remaining items.";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_5posteriorthreshold = {"posteriorthreshold", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_5posteriorthreshold, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8discodop_12coarsetofine_4posteriorthreshold};
static PyObject *__pyx_pw_8discodop_12coarsetofine_5posteriorthreshold(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart = 0;
  double __pyx_v_threshold;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("posteriorthreshold (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chart,&__pyx_n_s_threshold,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chart)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_threshold)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("posteriorthreshold", 1, 2, 2, 1); __PYX_ERR(0, 146, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "posteriorthreshold") < 0)) __PYX_ERR(0, 146, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_chart = ((struct __pyx_obj_8discodop_10containers_Chart *)values[0]);
    __pyx_v_threshold = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_threshold == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("posteriorthreshold", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 146, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("discodop.coarsetofine.posteriorthreshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chart), __pyx_ptype_8discodop_10containers_Chart, 1, "chart", 0))) __PYX_ERR(0, 146, __pyx_L1_error)
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_4posteriorthreshold(__pyx_self, __pyx_v_chart, __pyx_v_threshold);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_4posteriorthreshold(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart, double __pyx_v_threshold) {
  int __pyx_v_origlogprob;
  PyObject *__pyx_v_sentprob = NULL;
  PyObject *__pyx_v_posterior = NULL;
  Py_ssize_t __pyx_v_unfiltered;
  Py_ssize_t __pyx_v_numitems;
  Py_ssize_t __pyx_v_numremain;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("posteriorthreshold", 0);

  /* "discodop/coarsetofine.pyx":150
 * 
 * 	:returns: dictionary of remaining items."""
 * 	if not 0 < threshold < 1:             # <<<<<<<<<<<<<<
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:
 */
  __pyx_t_1 = (0.0 < __pyx_v_threshold);
  if (__pyx_t_1) {
    __pyx_t_1 = (__pyx_v_threshold < 1.0);
  }
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "discodop/coarsetofine.pyx":151
 * 	:returns: dictionary of remaining items."""
 * 	if not 0 < threshold < 1:
 * 		raise ValueError('probability threshold should be between 0 and 1.')             # <<<<<<<<<<<<<<
 * 	if not chart.itemsinorder:
 * 		raise ValueError('need list of chart items in topological order.')
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 151, __pyx_L1_error)

    /* "discodop/coarsetofine.pyx":150
 * 
 * 	:returns: dictionary of remaining items."""
 * 	if not 0 < threshold < 1:             # <<<<<<<<<<<<<<
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:
 */
  }

  /* "discodop/coarsetofine.pyx":152
 * 	if not 0 < threshold < 1:
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:             # <<<<<<<<<<<<<<
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_chart->itemsinorder); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 152, __pyx_L1_error)
  __pyx_t_1 = ((!__pyx_t_2) != 0);
  if (__pyx_t_1) {

    /* "discodop/coarsetofine.pyx":153
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:
 * 		raise ValueError('need list of chart items in topological order.')             # <<<<<<<<<<<<<<
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 153, __pyx_L1_error)

    /* "discodop/coarsetofine.pyx":152
 * 	if not 0 < threshold < 1:
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:             # <<<<<<<<<<<<<<
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob
 */
  }

  /* "discodop/coarsetofine.pyx":154
 * 	if not chart.itemsinorder:
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob             # <<<<<<<<<<<<<<
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 */
  __pyx_t_1 = __pyx_v_chart->grammar->logprob;
  __pyx_v_origlogprob = __pyx_t_1;

  /* "discodop/coarsetofine.pyx":155
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=False)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart->grammar), __pyx_n_s_switch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "discodop/coarsetofine.pyx":156
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],             # <<<<<<<<<<<<<<
 * 			logprob=False)
 * 	getinside(chart)
 */
  if (unlikely(__pyx_v_chart->grammar->modelnames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 156, __pyx_L1_error)
  }

  /* "discodop/coarsetofine.pyx":155
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=False)
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));
  __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));
  PyTuple_SET_ITEM(__pyx_t_4, 0, PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));

  /* "discodop/coarsetofine.pyx":157
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=False)             # <<<<<<<<<<<<<<
 * 	getinside(chart)
 * 	getoutside(chart)
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_logprob, Py_False) < 0) __PYX_ERR(0, 157, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":155
 * 		raise ValueError('need list of chart items in topological order.')
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=False)
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "discodop/coarsetofine.pyx":158
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=False)
 * 	getinside(chart)             # <<<<<<<<<<<<<<
 * 	getoutside(chart)
 * 	chart.grammar.switch(
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_getinside); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_chart)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_chart)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_chart)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_chart));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_chart));
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)__pyx_v_chart));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "discodop/coarsetofine.pyx":159
 * 			logprob=False)
 * 	getinside(chart)
 * 	getoutside(chart)             # <<<<<<<<<<<<<<
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_getoutside); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_chart)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_chart)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)__pyx_v_chart)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_chart));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_chart));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_chart));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "discodop/coarsetofine.pyx":160
 * 	getinside(chart)
 * 	getoutside(chart)
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=origlogprob)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart->grammar), __pyx_n_s_switch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "discodop/coarsetofine.pyx":161
 * 	getoutside(chart)
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],             # <<<<<<<<<<<<<<
 * 			logprob=origlogprob)
 * 	sentprob = chart.inside[chart.root()]
 */
  if (unlikely(__pyx_v_chart->grammar->modelnames == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 161, __pyx_L1_error)
  }

  /* "discodop/coarsetofine.pyx":160
 * 	getinside(chart)
 * 	getoutside(chart)
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=origlogprob)
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));
  __Pyx_GIVEREF(PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));
  PyTuple_SET_ITEM(__pyx_t_5, 0, PyList_GET_ITEM(__pyx_v_chart->grammar->modelnames, __pyx_v_chart->grammar->currentmodel));

  /* "discodop/coarsetofine.pyx":162
 * 	chart.grammar.switch(
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=origlogprob)             # <<<<<<<<<<<<<<
 * 	sentprob = chart.inside[chart.root()]
 * 	threshold *= sentprob
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_origlogprob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_logprob, __pyx_t_3) < 0) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":160
 * 	getinside(chart)
 * 	getoutside(chart)
 * 	chart.grammar.switch(             # <<<<<<<<<<<<<<
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=origlogprob)
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":163
 * 			chart.grammar.modelnames[chart.grammar.currentmodel],
 * 			logprob=origlogprob)
 * 	sentprob = chart.inside[chart.root()]             # <<<<<<<<<<<<<<
 * 	threshold *= sentprob
 * 	if not sentprob:
 */
  if (unlikely(__pyx_v_chart->inside == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 163, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_root); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_sentprob = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":164
 * 			logprob=origlogprob)
 * 	sentprob = chart.inside[chart.root()]
 * 	threshold *= sentprob             # <<<<<<<<<<<<<<
 * 	if not sentprob:
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_v_sentprob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_threshold = __pyx_t_7;

  /* "discodop/coarsetofine.pyx":165
 * 	sentprob = chart.inside[chart.root()]
 * 	threshold *= sentprob
 * 	if not sentprob:             # <<<<<<<<<<<<<<
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_sentprob); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 165, __pyx_L1_error)
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "discodop/coarsetofine.pyx":166
 * 	threshold *= sentprob
 * 	if not sentprob:
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)             # <<<<<<<<<<<<<<
 * 	posterior = {item for item in chart.getitems()
 * 			if chart.inside[item] * chart.outside[item] > threshold}
 */
    __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_sentence_has_zero_posterior_prob, __pyx_v_sentprob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 166, __pyx_L1_error)

    /* "discodop/coarsetofine.pyx":165
 * 	sentprob = chart.inside[chart.root()]
 * 	threshold *= sentprob
 * 	if not sentprob:             # <<<<<<<<<<<<<<
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()
 */
  }

  /* "discodop/coarsetofine.pyx":167
 * 	if not sentprob:
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()             # <<<<<<<<<<<<<<
 * 			if chart.inside[item] * chart.outside[item] > threshold}
 * 
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr3__pyx_v_item = NULL;
    __pyx_t_3 = PySet_New(NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L8_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __pyx_L8_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L8_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L8_error)
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L8_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 167, __pyx_L8_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 167, __pyx_L8_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_9(__pyx_t_5);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 167, __pyx_L8_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_item, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "discodop/coarsetofine.pyx":168
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()
 * 			if chart.inside[item] * chart.outside[item] > threshold}             # <<<<<<<<<<<<<<
 * 
 * 	unfiltered = len(chart.getitems())
 */
      if (unlikely(__pyx_v_chart->inside == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 168, __pyx_L8_error)
      }
      __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_8genexpr3__pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__pyx_v_chart->outside == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 168, __pyx_L8_error)
      }
      __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_chart->outside, __pyx_8genexpr3__pyx_v_item); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_threshold); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, __pyx_t_6, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 168, __pyx_L8_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {

        /* "discodop/coarsetofine.pyx":167
 * 	if not sentprob:
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()             # <<<<<<<<<<<<<<
 * 			if chart.inside[item] * chart.outside[item] > threshold}
 * 
 */
        if (unlikely(PySet_Add(__pyx_t_3, (PyObject*)__pyx_8genexpr3__pyx_v_item))) __PYX_ERR(0, 167, __pyx_L8_error)

        /* "discodop/coarsetofine.pyx":168
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()
 * 			if chart.inside[item] * chart.outside[item] > threshold}             # <<<<<<<<<<<<<<
 * 
 * 	unfiltered = len(chart.getitems())
 */
      }

      /* "discodop/coarsetofine.pyx":167
 * 	if not sentprob:
 * 		raise ValueError('sentence has zero posterior prob.: %g' % sentprob)
 * 	posterior = {item for item in chart.getitems()             # <<<<<<<<<<<<<<
 * 			if chart.inside[item] * chart.outside[item] > threshold}
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_item);
    goto __pyx_L12_exit_scope;
    __pyx_L8_error:;
    __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_item);
    goto __pyx_L1_error;
    __pyx_L12_exit_scope:;
  } /* exit inner scope */
  __pyx_v_posterior = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":170
 * 			if chart.inside[item] * chart.outside[item] > threshold}
 * 
 * 	unfiltered = len(chart.getitems())             # <<<<<<<<<<<<<<
 * 	numitems = len(chart.outside)
 * 	numremain = len(posterior)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_unfiltered = __pyx_t_8;

  /* "discodop/coarsetofine.pyx":171
 * 
 * 	unfiltered = len(chart.getitems())
 * 	numitems = len(chart.outside)             # <<<<<<<<<<<<<<
 * 	numremain = len(posterior)
 * 	msg = ('coarse items before pruning=%d; filtered: %d;'
 */
  __pyx_t_3 = __pyx_v_chart->outside;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 171, __pyx_L1_error)
  }
  __pyx_t_8 = PyDict_Size(__pyx_t_3); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_numitems = __pyx_t_8;

  /* "discodop/coarsetofine.pyx":172
 * 	unfiltered = len(chart.getitems())
 * 	numitems = len(chart.outside)
 * 	numremain = len(posterior)             # <<<<<<<<<<<<<<
 * 	msg = ('coarse items before pruning=%d; filtered: %d;'
 * 			' pruned: %d; sentprob=%g' % (
 */
  __pyx_t_8 = PySet_GET_SIZE(__pyx_v_posterior); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 172, __pyx_L1_error)
  __pyx_v_numremain = __pyx_t_8;

  /* "discodop/coarsetofine.pyx":175
 * 	msg = ('coarse items before pruning=%d; filtered: %d;'
 * 			' pruned: %d; sentprob=%g' % (
 * 			unfiltered, numitems, numremain, sentprob))             # <<<<<<<<<<<<<<
 * 	return posterior, msg
 * 
 */
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_unfiltered); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_numitems); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_numremain); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_sentprob);
  __Pyx_GIVEREF(__pyx_v_sentprob);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_sentprob);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":174
 * 	numremain = len(posterior)
 * 	msg = ('coarse items before pruning=%d; filtered: %d;'
 * 			' pruned: %d; sentprob=%g' % (             # <<<<<<<<<<<<<<
 * 			unfiltered, numitems, numremain, sentprob))
 * 	return posterior, msg
 */
  __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_coarse_items_before_pruning_d_fi, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_msg = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":176
 * 			' pruned: %d; sentprob=%g' % (
 * 			unfiltered, numitems, numremain, sentprob))
 * 	return posterior, msg             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_posterior);
  __Pyx_GIVEREF(__pyx_v_posterior);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_posterior);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_msg);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "discodop/coarsetofine.pyx":146
 * 
 * 
 * def posteriorthreshold(Chart chart, double threshold):             # <<<<<<<<<<<<<<
 * 	"""Prune labeled spans from chart below given posterior threshold.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("discodop.coarsetofine.posteriorthreshold", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sentprob);
  __Pyx_XDECREF(__pyx_v_posterior);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":179
 * 
 * 
 * def getinside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute inside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_7getinside(PyObject *__pyx_self, PyObject *__pyx_v_chart); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_6getinside[] = "getinside(Chart chart)\nCompute inside probabilities for a chart given its parse forest.";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_7getinside = {"getinside", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_7getinside, METH_O, __pyx_doc_8discodop_12coarsetofine_6getinside};
static PyObject *__pyx_pw_8discodop_12coarsetofine_7getinside(PyObject *__pyx_self, PyObject *__pyx_v_chart) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getinside (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chart), __pyx_ptype_8discodop_10containers_Chart, 1, "chart", 0))) __PYX_ERR(0, 179, __pyx_L1_error)
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_6getinside(__pyx_self, ((struct __pyx_obj_8discodop_10containers_Chart *)__pyx_v_chart));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_6getinside(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart) {
  size_t __pyx_v_n;
  struct __pyx_t_8discodop_10containers_Edge *__pyx_v_edge;
  struct __pyx_obj_8discodop_10containers_Edges *__pyx_v_edges = 0;
  struct __pyx_t_8discodop_10containers_MoreEdges *__pyx_v_edgelist;
  PyObject *__pyx_v_item = NULL;
  uint32_t __pyx_v_label;
  PyObject *__pyx_v_word = NULL;
  PyObject *__pyx_v_prob = NULL;
  PyObject *__pyx_v_leftitem = NULL;
  PyObject *__pyx_v_rightitem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  struct __pyx_t_8discodop_10containers_MoreEdges *__pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  size_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("getinside", 0);

  /* "discodop/coarsetofine.pyx":198
 * 	# revitems = {item: n for n, item in enumerate(self.itemsinorder)}
 * 	# now self.inside[n] and self.outside[n] can be double arrays.
 * 	chart.inside = dict.fromkeys(chart.getitems(), 0.0)             # <<<<<<<<<<<<<<
 * 
 * 	# traverse items in bottom-up order
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyDict_Type)), __pyx_n_s_fromkeys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_float_0_0};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_float_0_0};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_INCREF(__pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_float_0_0);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_float_0_0);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chart->inside);
  __Pyx_DECREF(__pyx_v_chart->inside);
  __pyx_v_chart->inside = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":201
 * 
 * 	# traverse items in bottom-up order
 * 	for item in chart.itemsinorder:             # <<<<<<<<<<<<<<
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL
 */
  if (likely(PyList_CheckExact(__pyx_v_chart->itemsinorder)) || PyTuple_CheckExact(__pyx_v_chart->itemsinorder)) {
    __pyx_t_1 = __pyx_v_chart->itemsinorder; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_chart->itemsinorder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 201, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 201, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":202
 * 	# traverse items in bottom-up order
 * 	for item in chart.itemsinorder:
 * 		edges = chart.getedges(item)             # <<<<<<<<<<<<<<
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->getedges(__pyx_v_chart, __pyx_v_item)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_edges, ((struct __pyx_obj_8discodop_10containers_Edges *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":203
 * 	for item in chart.itemsinorder:
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL             # <<<<<<<<<<<<<<
 * 		while edgelist is not NULL:
 * 			for n in range(edges.len if edgelist is edges.head
 */
    __pyx_t_10 = (((PyObject *)__pyx_v_edges) != Py_None);
    if ((__pyx_t_10 != 0)) {
      __pyx_t_9 = __pyx_v_edges->head;
    } else {
      __pyx_t_9 = NULL;
    }
    __pyx_v_edgelist = __pyx_t_9;

    /* "discodop/coarsetofine.pyx":204
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:             # <<<<<<<<<<<<<<
 * 			for n in range(edges.len if edgelist is edges.head
 * 					else EDGES_SIZE):
 */
    while (1) {
      __pyx_t_10 = ((__pyx_v_edgelist != NULL) != 0);
      if (!__pyx_t_10) break;

      /* "discodop/coarsetofine.pyx":205
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:
 * 			for n in range(edges.len if edgelist is edges.head             # <<<<<<<<<<<<<<
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])
 */
      if (((__pyx_v_edgelist == __pyx_v_edges->head) != 0)) {
        __pyx_t_11 = __pyx_v_edges->len;
      } else {
        __pyx_t_11 = 15;
      }
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
        __pyx_v_n = __pyx_t_12;

        /* "discodop/coarsetofine.pyx":207
 * 			for n in range(edges.len if edgelist is edges.head
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])             # <<<<<<<<<<<<<<
 * 				if edge.rule is NULL:
 * 					label = chart.label(item)
 */
        __pyx_v_edge = (&(__pyx_v_edgelist->data[__pyx_v_n]));

        /* "discodop/coarsetofine.pyx":208
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])
 * 				if edge.rule is NULL:             # <<<<<<<<<<<<<<
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]
 */
        __pyx_t_10 = ((__pyx_v_edge->rule == NULL) != 0);
        if (__pyx_t_10) {

          /* "discodop/coarsetofine.pyx":209
 * 				edge = &(edgelist.data[n])
 * 				if edge.rule is NULL:
 * 					label = chart.label(item)             # <<<<<<<<<<<<<<
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 */
          __pyx_v_label = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->label(__pyx_v_chart, __pyx_v_item);

          /* "discodop/coarsetofine.pyx":210
 * 				if edge.rule is NULL:
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]             # <<<<<<<<<<<<<<
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 * 							label].get(word, 1.0)).prob
 */
          if (unlikely(__pyx_v_chart->sent == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 210, __pyx_L1_error)
          }
          __pyx_t_6 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->lexidx(__pyx_v_chart, __pyx_v_edge);
          __pyx_t_2 = PyList_GET_ITEM(__pyx_v_chart->sent, __pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_word, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":211
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[             # <<<<<<<<<<<<<<
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:
 */
          if (unlikely(__pyx_v_chart->grammar->lexicalbylhs == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 211, __pyx_L1_error)
          }

          /* "discodop/coarsetofine.pyx":212
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 * 							label].get(word, 1.0)).prob             # <<<<<<<<<<<<<<
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)
 */
          __pyx_t_5 = __Pyx_PyInt_From_uint32_t(__pyx_v_label); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);

          /* "discodop/coarsetofine.pyx":211
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[             # <<<<<<<<<<<<<<
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:
 */
          __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_chart->grammar->lexicalbylhs, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":212
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 * 							label].get(word, 1.0)).prob             # <<<<<<<<<<<<<<
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)
 */
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          __pyx_t_6 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_5, function);
              __pyx_t_6 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_word, __pyx_float_1_0};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_word, __pyx_float_1_0};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_2);
          } else
          #endif
          {
            __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
            }
            __Pyx_INCREF(__pyx_v_word);
            __Pyx_GIVEREF(__pyx_v_word);
            PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_word);
            __Pyx_INCREF(__pyx_float_1_0);
            __Pyx_GIVEREF(__pyx_float_1_0);
            PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_float_1_0);
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":211
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[             # <<<<<<<<<<<<<<
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:
 */
          __pyx_t_5 = PyFloat_FromDouble(((struct __pyx_obj_8discodop_10containers_LexicalRule *)__pyx_t_2)->prob); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_5);
          __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":208
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])
 * 				if edge.rule is NULL:             # <<<<<<<<<<<<<<
 * 					label = chart.label(item)
 * 					word = chart.sent[chart.lexidx(edge)]
 */
          goto __pyx_L9;
        }

        /* "discodop/coarsetofine.pyx":213
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:             # <<<<<<<<<<<<<<
 * 					leftitem = chart._left(item, edge)
 * 					prob = (edge.rule.prob
 */
        __pyx_t_10 = ((__pyx_v_edge->rule->rhs2 == 0) != 0);
        if (__pyx_t_10) {

          /* "discodop/coarsetofine.pyx":214
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)             # <<<<<<<<<<<<<<
 * 					prob = (edge.rule.prob
 * 							* chart.inside[leftitem])
 */
          __pyx_t_5 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_left(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_XDECREF_SET(__pyx_v_leftitem, __pyx_t_5);
          __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":215
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)
 * 					prob = (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[leftitem])
 * 				else:
 */
          __pyx_t_5 = PyFloat_FromDouble(__pyx_v_edge->rule->prob); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);

          /* "discodop/coarsetofine.pyx":216
 * 					leftitem = chart._left(item, edge)
 * 					prob = (edge.rule.prob
 * 							* chart.inside[leftitem])             # <<<<<<<<<<<<<<
 * 				else:
 * 					leftitem = chart._left(item, edge)
 */
          if (unlikely(__pyx_v_chart->inside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 216, __pyx_L1_error)
          }
          __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_v_leftitem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyNumber_Multiply(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":213
 * 					prob = (<LexicalRule>chart.grammar.lexicalbylhs[
 * 							label].get(word, 1.0)).prob
 * 				elif edge.rule.rhs2 == 0:             # <<<<<<<<<<<<<<
 * 					leftitem = chart._left(item, edge)
 * 					prob = (edge.rule.prob
 */
          goto __pyx_L9;
        }

        /* "discodop/coarsetofine.pyx":218
 * 							* chart.inside[leftitem])
 * 				else:
 * 					leftitem = chart._left(item, edge)             # <<<<<<<<<<<<<<
 * 					rightitem = chart._right(item, edge)
 * 					prob = (edge.rule.prob
 */
        /*else*/ {
          __pyx_t_4 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_left(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_XDECREF_SET(__pyx_v_leftitem, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":219
 * 				else:
 * 					leftitem = chart._left(item, edge)
 * 					rightitem = chart._right(item, edge)             # <<<<<<<<<<<<<<
 * 					prob = (edge.rule.prob
 * 							* chart.inside[leftitem]
 */
          __pyx_t_4 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_right(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_XDECREF_SET(__pyx_v_rightitem, __pyx_t_4);
          __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":220
 * 					leftitem = chart._left(item, edge)
 * 					rightitem = chart._right(item, edge)
 * 					prob = (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[leftitem]
 * 							* chart.inside[rightitem])
 */
          __pyx_t_4 = PyFloat_FromDouble(__pyx_v_edge->rule->prob); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);

          /* "discodop/coarsetofine.pyx":221
 * 					rightitem = chart._right(item, edge)
 * 					prob = (edge.rule.prob
 * 							* chart.inside[leftitem]             # <<<<<<<<<<<<<<
 * 							* chart.inside[rightitem])
 * 				# chart.addprob(item, prob)
 */
          if (unlikely(__pyx_v_chart->inside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 221, __pyx_L1_error)
          }
          __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_v_leftitem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":222
 * 					prob = (edge.rule.prob
 * 							* chart.inside[leftitem]
 * 							* chart.inside[rightitem])             # <<<<<<<<<<<<<<
 * 				# chart.addprob(item, prob)
 * 				chart.inside[item] += prob
 */
          if (unlikely(__pyx_v_chart->inside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 222, __pyx_L1_error)
          }
          __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_v_rightitem); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyNumber_Multiply(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF_SET(__pyx_v_prob, __pyx_t_4);
          __pyx_t_4 = 0;
        }
        __pyx_L9:;

        /* "discodop/coarsetofine.pyx":224
 * 							* chart.inside[rightitem])
 * 				# chart.addprob(item, prob)
 * 				chart.inside[item] += prob             # <<<<<<<<<<<<<<
 * 			edgelist = edgelist.prev
 * 
 */
        if (unlikely(__pyx_v_chart->inside == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 224, __pyx_L1_error)
        }
        __Pyx_INCREF(__pyx_v_chart->inside);
        __pyx_t_13 = __pyx_v_chart->inside;
        __Pyx_INCREF(__pyx_v_item);
        __pyx_t_4 = __pyx_v_item;
        if (unlikely(__pyx_t_13 == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 224, __pyx_L1_error)
        }
        __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_t_13, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_v_prob); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(__pyx_t_13 == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 224, __pyx_L1_error)
        }
        if (unlikely(PyDict_SetItem(__pyx_t_13, __pyx_t_4, __pyx_t_5) < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }

      /* "discodop/coarsetofine.pyx":225
 * 				# chart.addprob(item, prob)
 * 				chart.inside[item] += prob
 * 			edgelist = edgelist.prev             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_9 = __pyx_v_edgelist->prev;
      __pyx_v_edgelist = __pyx_t_9;
    }

    /* "discodop/coarsetofine.pyx":201
 * 
 * 	# traverse items in bottom-up order
 * 	for item in chart.itemsinorder:             # <<<<<<<<<<<<<<
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":179
 * 
 * 
 * def getinside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute inside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("discodop.coarsetofine.getinside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_edges);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_word);
  __Pyx_XDECREF(__pyx_v_prob);
  __Pyx_XDECREF(__pyx_v_leftitem);
  __Pyx_XDECREF(__pyx_v_rightitem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":228
 * 
 * 
 * def getoutside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute outside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_9getoutside(PyObject *__pyx_self, PyObject *__pyx_v_chart); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_8getoutside[] = "getoutside(Chart chart)\nCompute outside probabilities for a chart given its parse forest.";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_9getoutside = {"getoutside", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_9getoutside, METH_O, __pyx_doc_8discodop_12coarsetofine_8getoutside};
static PyObject *__pyx_pw_8discodop_12coarsetofine_9getoutside(PyObject *__pyx_self, PyObject *__pyx_v_chart) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getoutside (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chart), __pyx_ptype_8discodop_10containers_Chart, 1, "chart", 0))) __PYX_ERR(0, 228, __pyx_L1_error)
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_8getoutside(__pyx_self, ((struct __pyx_obj_8discodop_10containers_Chart *)__pyx_v_chart));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_8getoutside(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_8discodop_10containers_Chart *__pyx_v_chart) {
  size_t __pyx_v_n;
  struct __pyx_t_8discodop_10containers_Edge *__pyx_v_edge;
  struct __pyx_obj_8discodop_10containers_Edges *__pyx_v_edges = 0;
  struct __pyx_t_8discodop_10containers_MoreEdges *__pyx_v_edgelist;
  double __pyx_v_outsideprob;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_leftitem = NULL;
  PyObject *__pyx_v_rightitem = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  struct __pyx_t_8discodop_10containers_MoreEdges *__pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  size_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  double __pyx_t_15;
  __Pyx_RefNannySetupContext("getoutside", 0);

  /* "discodop/coarsetofine.pyx":238
 * 	# traverse items in top-down order
 * 	# could use list with idx of item in itemsinorder
 * 	chart.outside = dict.fromkeys(chart.getitems(), 0.0)             # <<<<<<<<<<<<<<
 * 	chart.outside[chart.root()] = 1.0
 * 	for item in reversed(chart.itemsinorder):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyDict_Type)), __pyx_n_s_fromkeys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_getitems); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_float_0_0};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_float_0_0};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_INCREF(__pyx_float_0_0);
    __Pyx_GIVEREF(__pyx_float_0_0);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_float_0_0);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chart->outside);
  __Pyx_DECREF(__pyx_v_chart->outside);
  __pyx_v_chart->outside = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":239
 * 	# could use list with idx of item in itemsinorder
 * 	chart.outside = dict.fromkeys(chart.getitems(), 0.0)
 * 	chart.outside[chart.root()] = 1.0             # <<<<<<<<<<<<<<
 * 	for item in reversed(chart.itemsinorder):
 * 		# can we define outside[item] simply as sentprob - inside[item] ?
 */
  if (unlikely(__pyx_v_chart->outside == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 239, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chart), __pyx_n_s_root); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_chart->outside, __pyx_t_1, __pyx_float_1_0) < 0)) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":240
 * 	chart.outside = dict.fromkeys(chart.getitems(), 0.0)
 * 	chart.outside[chart.root()] = 1.0
 * 	for item in reversed(chart.itemsinorder):             # <<<<<<<<<<<<<<
 * 		# can we define outside[item] simply as sentprob - inside[item] ?
 * 		# chart.outside[item] = sentprob - chart.inside[item]
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_chart->itemsinorder);
  __Pyx_GIVEREF(__pyx_v_chart->itemsinorder);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_chart->itemsinorder);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_reversed, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 240, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 240, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 240, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 240, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":243
 * 		# can we define outside[item] simply as sentprob - inside[item] ?
 * 		# chart.outside[item] = sentprob - chart.inside[item]
 * 		edges = chart.getedges(item)             # <<<<<<<<<<<<<<
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->getedges(__pyx_v_chart, __pyx_v_item)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_edges, ((struct __pyx_obj_8discodop_10containers_Edges *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":244
 * 		# chart.outside[item] = sentprob - chart.inside[item]
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL             # <<<<<<<<<<<<<<
 * 		while edgelist is not NULL:
 * 			for n in range(edges.len if edgelist is edges.head
 */
    __pyx_t_10 = (((PyObject *)__pyx_v_edges) != Py_None);
    if ((__pyx_t_10 != 0)) {
      __pyx_t_9 = __pyx_v_edges->head;
    } else {
      __pyx_t_9 = NULL;
    }
    __pyx_v_edgelist = __pyx_t_9;

    /* "discodop/coarsetofine.pyx":245
 * 		edges = chart.getedges(item)
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:             # <<<<<<<<<<<<<<
 * 			for n in range(edges.len if edgelist is edges.head
 * 					else EDGES_SIZE):
 */
    while (1) {
      __pyx_t_10 = ((__pyx_v_edgelist != NULL) != 0);
      if (!__pyx_t_10) break;

      /* "discodop/coarsetofine.pyx":246
 * 		edgelist = edges.head if edges is not None else NULL
 * 		while edgelist is not NULL:
 * 			for n in range(edges.len if edgelist is edges.head             # <<<<<<<<<<<<<<
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])
 */
      if (((__pyx_v_edgelist == __pyx_v_edges->head) != 0)) {
        __pyx_t_11 = __pyx_v_edges->len;
      } else {
        __pyx_t_11 = 15;
      }
      for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
        __pyx_v_n = __pyx_t_12;

        /* "discodop/coarsetofine.pyx":248
 * 			for n in range(edges.len if edgelist is edges.head
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])             # <<<<<<<<<<<<<<
 * 				if edge.rule is NULL:
 * 					pass
 */
        __pyx_v_edge = (&(__pyx_v_edgelist->data[__pyx_v_n]));

        /* "discodop/coarsetofine.pyx":249
 * 					else EDGES_SIZE):
 * 				edge = &(edgelist.data[n])
 * 				if edge.rule is NULL:             # <<<<<<<<<<<<<<
 * 					pass
 * 				elif edge.rule.rhs2 == 0:
 */
        __pyx_t_10 = ((__pyx_v_edge->rule == NULL) != 0);
        if (__pyx_t_10) {
          goto __pyx_L9;
        }

        /* "discodop/coarsetofine.pyx":251
 * 				if edge.rule is NULL:
 * 					pass
 * 				elif edge.rule.rhs2 == 0:             # <<<<<<<<<<<<<<
 * 					leftitem = chart._left(item, edge)
 * 					chart.outside[leftitem] += (edge.rule.prob
 */
        __pyx_t_10 = ((__pyx_v_edge->rule->rhs2 == 0) != 0);
        if (__pyx_t_10) {

          /* "discodop/coarsetofine.pyx":252
 * 					pass
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)             # <<<<<<<<<<<<<<
 * 					chart.outside[leftitem] += (edge.rule.prob
 * 							* chart.outside[item])
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_left(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_leftitem, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":253
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)
 * 					chart.outside[leftitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.outside[item])
 * 				else:
 */
          if (unlikely(__pyx_v_chart->outside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 253, __pyx_L1_error)
          }
          __Pyx_INCREF(__pyx_v_chart->outside);
          __pyx_t_13 = __pyx_v_chart->outside;
          __Pyx_INCREF(__pyx_v_leftitem);
          __pyx_t_2 = __pyx_v_leftitem;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 253, __pyx_L1_error)
          }
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 253, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_edge->rule->prob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);

          /* "discodop/coarsetofine.pyx":254
 * 					leftitem = chart._left(item, edge)
 * 					chart.outside[leftitem] += (edge.rule.prob
 * 							* chart.outside[item])             # <<<<<<<<<<<<<<
 * 				else:
 * 					leftitem = chart._left(item, edge)
 */
          if (unlikely(__pyx_v_chart->outside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 254, __pyx_L1_error)
          }
          __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_chart->outside, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_14 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":253
 * 				elif edge.rule.rhs2 == 0:
 * 					leftitem = chart._left(item, edge)
 * 					chart.outside[leftitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.outside[item])
 * 				else:
 */
          __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 253, __pyx_L1_error)
          }
          if (unlikely(PyDict_SetItem(__pyx_t_13, __pyx_t_2, __pyx_t_4) < 0)) __PYX_ERR(0, 253, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "discodop/coarsetofine.pyx":251
 * 				if edge.rule is NULL:
 * 					pass
 * 				elif edge.rule.rhs2 == 0:             # <<<<<<<<<<<<<<
 * 					leftitem = chart._left(item, edge)
 * 					chart.outside[leftitem] += (edge.rule.prob
 */
          goto __pyx_L9;
        }

        /* "discodop/coarsetofine.pyx":256
 * 							* chart.outside[item])
 * 				else:
 * 					leftitem = chart._left(item, edge)             # <<<<<<<<<<<<<<
 * 					rightitem = chart._right(item, edge)
 * 					outsideprob = chart.outside[item]
 */
        /*else*/ {
          __pyx_t_2 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_left(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_leftitem, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":257
 * 				else:
 * 					leftitem = chart._left(item, edge)
 * 					rightitem = chart._right(item, edge)             # <<<<<<<<<<<<<<
 * 					outsideprob = chart.outside[item]
 * 					chart.outside[leftitem] += (edge.rule.prob
 */
          __pyx_t_2 = ((struct __pyx_vtabstruct_8discodop_10containers_Chart *)__pyx_v_chart->__pyx_vtab)->_right(__pyx_v_chart, __pyx_v_item, __pyx_v_edge); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_rightitem, __pyx_t_2);
          __pyx_t_2 = 0;

          /* "discodop/coarsetofine.pyx":258
 * 					leftitem = chart._left(item, edge)
 * 					rightitem = chart._right(item, edge)
 * 					outsideprob = chart.outside[item]             # <<<<<<<<<<<<<<
 * 					chart.outside[leftitem] += (edge.rule.prob
 * 							* chart.inside[rightitem]
 */
          if (unlikely(__pyx_v_chart->outside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 258, __pyx_L1_error)
          }
          __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_chart->outside, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_v_outsideprob = __pyx_t_15;

          /* "discodop/coarsetofine.pyx":259
 * 					rightitem = chart._right(item, edge)
 * 					outsideprob = chart.outside[item]
 * 					chart.outside[leftitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[rightitem]
 * 							* outsideprob)
 */
          if (unlikely(__pyx_v_chart->outside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 259, __pyx_L1_error)
          }
          __Pyx_INCREF(__pyx_v_chart->outside);
          __pyx_t_13 = __pyx_v_chart->outside;
          __Pyx_INCREF(__pyx_v_leftitem);
          __pyx_t_2 = __pyx_v_leftitem;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 259, __pyx_L1_error)
          }
          __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_14 = PyFloat_FromDouble(__pyx_v_edge->rule->prob); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 259, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);

          /* "discodop/coarsetofine.pyx":260
 * 					outsideprob = chart.outside[item]
 * 					chart.outside[leftitem] += (edge.rule.prob
 * 							* chart.inside[rightitem]             # <<<<<<<<<<<<<<
 * 							* outsideprob)
 * 					chart.outside[rightitem] += (edge.rule.prob
 */
          if (unlikely(__pyx_v_chart->inside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 260, __pyx_L1_error)
          }
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_v_rightitem); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_3 = PyNumber_Multiply(__pyx_t_14, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":261
 * 					chart.outside[leftitem] += (edge.rule.prob
 * 							* chart.inside[rightitem]
 * 							* outsideprob)             # <<<<<<<<<<<<<<
 * 					chart.outside[rightitem] += (edge.rule.prob
 * 							* chart.inside[leftitem]
 */
          __pyx_t_5 = PyFloat_FromDouble(__pyx_v_outsideprob); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_14 = PyNumber_Multiply(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 261, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "discodop/coarsetofine.pyx":259
 * 					rightitem = chart._right(item, edge)
 * 					outsideprob = chart.outside[item]
 * 					chart.outside[leftitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[rightitem]
 * 							* outsideprob)
 */
          __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 259, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 259, __pyx_L1_error)
          }
          if (unlikely(PyDict_SetItem(__pyx_t_13, __pyx_t_2, __pyx_t_5) < 0)) __PYX_ERR(0, 259, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "discodop/coarsetofine.pyx":262
 * 							* chart.inside[rightitem]
 * 							* outsideprob)
 * 					chart.outside[rightitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[leftitem]
 * 							* outsideprob)
 */
          if (unlikely(__pyx_v_chart->outside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 262, __pyx_L1_error)
          }
          __Pyx_INCREF(__pyx_v_chart->outside);
          __pyx_t_13 = __pyx_v_chart->outside;
          __Pyx_INCREF(__pyx_v_rightitem);
          __pyx_t_2 = __pyx_v_rightitem;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 262, __pyx_L1_error)
          }
          __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 262, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_14 = PyFloat_FromDouble(__pyx_v_edge->rule->prob); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 262, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);

          /* "discodop/coarsetofine.pyx":263
 * 							* outsideprob)
 * 					chart.outside[rightitem] += (edge.rule.prob
 * 							* chart.inside[leftitem]             # <<<<<<<<<<<<<<
 * 							* outsideprob)
 * 			edgelist = edgelist.prev
 */
          if (unlikely(__pyx_v_chart->inside == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 263, __pyx_L1_error)
          }
          __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_chart->inside, __pyx_v_leftitem); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = PyNumber_Multiply(__pyx_t_14, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":264
 * 					chart.outside[rightitem] += (edge.rule.prob
 * 							* chart.inside[leftitem]
 * 							* outsideprob)             # <<<<<<<<<<<<<<
 * 			edgelist = edgelist.prev
 * 
 */
          __pyx_t_4 = PyFloat_FromDouble(__pyx_v_outsideprob); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_14 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 264, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "discodop/coarsetofine.pyx":262
 * 							* chart.inside[rightitem]
 * 							* outsideprob)
 * 					chart.outside[rightitem] += (edge.rule.prob             # <<<<<<<<<<<<<<
 * 							* chart.inside[leftitem]
 * 							* outsideprob)
 */
          __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(__pyx_t_13 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 262, __pyx_L1_error)
          }
          if (unlikely(PyDict_SetItem(__pyx_t_13, __pyx_t_2, __pyx_t_4) < 0)) __PYX_ERR(0, 262, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        }
        __pyx_L9:;
      }

      /* "discodop/coarsetofine.pyx":265
 * 							* chart.inside[leftitem]
 * 							* outsideprob)
 * 			edgelist = edgelist.prev             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_9 = __pyx_v_edgelist->prev;
      __pyx_v_edgelist = __pyx_t_9;
    }

    /* "discodop/coarsetofine.pyx":240
 * 	chart.outside = dict.fromkeys(chart.getitems(), 0.0)
 * 	chart.outside[chart.root()] = 1.0
 * 	for item in reversed(chart.itemsinorder):             # <<<<<<<<<<<<<<
 * 		# can we define outside[item] simply as sentprob - inside[item] ?
 * 		# chart.outside[item] = sentprob - chart.inside[item]
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":228
 * 
 * 
 * def getoutside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute outside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("discodop.coarsetofine.getoutside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_edges);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_leftitem);
  __Pyx_XDECREF(__pyx_v_rightitem);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":268
 * 
 * 
 * def doctftest(coarse, fine, sent, tree, k, split, verbose=False):             # <<<<<<<<<<<<<<
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_11doctftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_10doctftest[] = "doctftest(coarse, fine, sent, tree, k, split, verbose=False)\nTest coarse-to-fine methods on a sentence.";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_11doctftest = {"doctftest", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_11doctftest, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8discodop_12coarsetofine_10doctftest};
static PyObject *__pyx_pw_8discodop_12coarsetofine_11doctftest(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_coarse = 0;
  PyObject *__pyx_v_fine = 0;
  PyObject *__pyx_v_sent = 0;
  PyObject *__pyx_v_tree = 0;
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_split = 0;
  PyObject *__pyx_v_verbose = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("doctftest (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_coarse,&__pyx_n_s_fine,&__pyx_n_s_sent,&__pyx_n_s_tree,&__pyx_n_s_k,&__pyx_n_s_split,&__pyx_n_s_verbose,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[6] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_coarse)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fine)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, 1); __PYX_ERR(0, 268, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sent)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, 2); __PYX_ERR(0, 268, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tree)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, 3); __PYX_ERR(0, 268, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, 4); __PYX_ERR(0, 268, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_split)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, 5); __PYX_ERR(0, 268, __pyx_L3_error)
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_verbose);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "doctftest") < 0)) __PYX_ERR(0, 268, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_coarse = values[0];
    __pyx_v_fine = values[1];
    __pyx_v_sent = values[2];
    __pyx_v_tree = values[3];
    __pyx_v_k = values[4];
    __pyx_v_split = values[5];
    __pyx_v_verbose = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("doctftest", 0, 6, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 268, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("discodop.coarsetofine.doctftest", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_10doctftest(__pyx_self, __pyx_v_coarse, __pyx_v_fine, __pyx_v_sent, __pyx_v_tree, __pyx_v_k, __pyx_v_split, __pyx_v_verbose);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_10doctftest(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coarse, PyObject *__pyx_v_fine, PyObject *__pyx_v_sent, PyObject *__pyx_v_tree, PyObject *__pyx_v_k, PyObject *__pyx_v_split, PyObject *__pyx_v_verbose) {
  PyObject *__pyx_v_plcfrs = NULL;
  PyObject *__pyx_v_getderivations = NULL;
  PyObject *__pyx_v_marginalize = NULL;
  PyObject *__pyx_v_canonicalize = NULL;
  PyObject *__pyx_v_removefanoutmarkers = NULL;
  PyObject *__pyx_v_pyexp = NULL;
  PyObject *__pyx_v_tags = NULL;
  PyObject *__pyx_v_chart = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_derivations = NULL;
  PyObject *__pyx_v_entries = NULL;
  PyObject *__pyx_v_mpp = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_n = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_m = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_chart2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("doctftest", 0);
  __Pyx_INCREF(__pyx_v_sent);

  /* "discodop/coarsetofine.pyx":270
 * def doctftest(coarse, fine, sent, tree, k, split, verbose=False):
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs             # <<<<<<<<<<<<<<
 * 	from .disambiguation import getderivations, marginalize
 * 	from .treetransforms import canonicalize, removefanoutmarkers
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_plcfrs);
  __Pyx_GIVEREF(__pyx_n_s_plcfrs);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_plcfrs);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s__5, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_plcfrs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_plcfrs = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":271
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs
 * 	from .disambiguation import getderivations, marginalize             # <<<<<<<<<<<<<<
 * 	from .treetransforms import canonicalize, removefanoutmarkers
 * 	from math import exp as pyexp
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_getderivations);
  __Pyx_GIVEREF(__pyx_n_s_getderivations);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_getderivations);
  __Pyx_INCREF(__pyx_n_s_marginalize);
  __Pyx_GIVEREF(__pyx_n_s_marginalize);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_marginalize);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_disambiguation, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_getderivations); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_getderivations = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_marginalize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_marginalize = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":272
 * 	from . import plcfrs
 * 	from .disambiguation import getderivations, marginalize
 * 	from .treetransforms import canonicalize, removefanoutmarkers             # <<<<<<<<<<<<<<
 * 	from math import exp as pyexp
 * 	sent, tags = zip(*sent)
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_canonicalize);
  __Pyx_GIVEREF(__pyx_n_s_canonicalize);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_canonicalize);
  __Pyx_INCREF(__pyx_n_s_removefanoutmarkers);
  __Pyx_GIVEREF(__pyx_n_s_removefanoutmarkers);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_removefanoutmarkers);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_treetransforms, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_canonicalize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_canonicalize = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_removefanoutmarkers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_removefanoutmarkers = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":273
 * 	from .disambiguation import getderivations, marginalize
 * 	from .treetransforms import canonicalize, removefanoutmarkers
 * 	from math import exp as pyexp             # <<<<<<<<<<<<<<
 * 	sent, tags = zip(*sent)
 * 	print(' C O A R S E ')
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_exp);
  __Pyx_GIVEREF(__pyx_n_s_exp);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_exp);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_exp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_pyexp = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":274
 * 	from .treetransforms import canonicalize, removefanoutmarkers
 * 	from math import exp as pyexp
 * 	sent, tags = zip(*sent)             # <<<<<<<<<<<<<<
 * 	print(' C O A R S E ')
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 */
  __pyx_t_1 = PySequence_Tuple(__pyx_v_sent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 274, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 274, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 274, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __Pyx_DECREF_SET(__pyx_v_sent, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_tags = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":275
 * 	from math import exp as pyexp
 * 	sent, tags = zip(*sent)
 * 	print(' C O A R S E ')             # <<<<<<<<<<<<<<
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 * 	if chart:
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":276
 * 	sent, tags = zip(*sent)
 * 	print(' C O A R S E ')
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)             # <<<<<<<<<<<<<<
 * 	if chart:
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plcfrs, __pyx_n_s_parse); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_sent);
  __Pyx_GIVEREF(__pyx_v_sent);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_sent);
  __Pyx_INCREF(__pyx_v_coarse);
  __Pyx_GIVEREF(__pyx_v_coarse);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_coarse);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_tags, __pyx_v_tags) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 276, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 276, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_chart = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v__ = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":277
 * 	print(' C O A R S E ')
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 * 	if chart:             # <<<<<<<<<<<<<<
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_chart); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 277, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "discodop/coarsetofine.pyx":278
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 * 	if chart:
 * 		derivations, entries = getderivations(chart, 10, True, False, True)             # <<<<<<<<<<<<<<
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 * 		for t, p, _ in mpp:
 */
    __Pyx_INCREF(__pyx_v_getderivations);
    __pyx_t_3 = __pyx_v_getderivations; __pyx_t_1 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_chart, __pyx_int_10, Py_True, Py_False, Py_True};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[6] = {__pyx_t_1, __pyx_v_chart, __pyx_int_10, Py_True, Py_False, Py_True};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_v_chart);
      __Pyx_GIVEREF(__pyx_v_chart);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_chart);
      __Pyx_INCREF(__pyx_int_10);
      __Pyx_GIVEREF(__pyx_int_10);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_int_10);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_7, Py_True);
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_7, Py_False);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_2, 4+__pyx_t_7, Py_True);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 278, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_1), 2) < 0) __PYX_ERR(0, 278, __pyx_L1_error)
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L9_unpacking_done;
      __pyx_L8_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 278, __pyx_L1_error)
      __pyx_L9_unpacking_done:;
    }
    __pyx_v_derivations = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_entries = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":279
 * 	if chart:
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)             # <<<<<<<<<<<<<<
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')
 */
    __Pyx_INCREF(__pyx_v_marginalize);
    __pyx_t_2 = __pyx_v_marginalize; __pyx_t_3 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_n_u_mpp, __pyx_v_derivations, __pyx_v_entries, __pyx_v_chart};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_n_u_mpp, __pyx_v_derivations, __pyx_v_entries, __pyx_v_chart};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_n_u_mpp);
      __Pyx_GIVEREF(__pyx_n_u_mpp);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_7, __pyx_n_u_mpp);
      __Pyx_INCREF(__pyx_v_derivations);
      __Pyx_GIVEREF(__pyx_v_derivations);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_7, __pyx_v_derivations);
      __Pyx_INCREF(__pyx_v_entries);
      __Pyx_GIVEREF(__pyx_v_entries);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_7, __pyx_v_entries);
      __Pyx_INCREF(__pyx_v_chart);
      __Pyx_GIVEREF(__pyx_v_chart);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_7, __pyx_v_chart);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 279, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 279, __pyx_L1_error)
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 279, __pyx_L1_error)
      __pyx_L11_unpacking_done:;
    }
    __pyx_v_mpp = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v__, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":280
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 * 		for t, p, _ in mpp:             # <<<<<<<<<<<<<<
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 */
    if (likely(PyList_CheckExact(__pyx_v_mpp)) || PyTuple_CheckExact(__pyx_v_mpp)) {
      __pyx_t_4 = __pyx_v_mpp; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_mpp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 280, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 280, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_4);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 280, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 280, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L14_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L14_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 2; __pyx_t_10 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L14_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_11), 3) < 0) __PYX_ERR(0, 280, __pyx_L1_error)
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L15_unpacking_done;
        __pyx_L14_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 280, __pyx_L1_error)
        __pyx_L15_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v__, __pyx_t_10);
      __pyx_t_10 = 0;

      /* "discodop/coarsetofine.pyx":281
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')             # <<<<<<<<<<<<<<
 * 			t = Tree.parse(t)
 * 			if split:
 */
      __pyx_t_10 = PyNumber_Negative(__pyx_v_p); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_pyexp);
      __pyx_t_3 = __pyx_v_pyexp; __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_10};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_10};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_end, __pyx_kp_u__7) < 0) __PYX_ERR(0, 281, __pyx_L1_error)
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":282
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)             # <<<<<<<<<<<<<<
 * 			if split:
 * 				unbinarize(t, childchar=":", parentchar="!")
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Tree); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_parse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 282, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_t);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 282, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":283
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 * 			if split:             # <<<<<<<<<<<<<<
 * 				unbinarize(t, childchar=":", parentchar="!")
 * 				mergediscnodes(t)
 */
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_split); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
      if (__pyx_t_6) {

        /* "discodop/coarsetofine.pyx":284
 * 			t = Tree.parse(t)
 * 			if split:
 * 				unbinarize(t, childchar=":", parentchar="!")             # <<<<<<<<<<<<<<
 * 				mergediscnodes(t)
 * 			unbinarize(t)
 */
        __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_unbinarize); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_t);
        __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_childchar, __pyx_kp_u__8) < 0) __PYX_ERR(0, 284, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_parentchar, __pyx_kp_u__9) < 0) __PYX_ERR(0, 284, __pyx_L1_error)
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "discodop/coarsetofine.pyx":285
 * 			if split:
 * 				unbinarize(t, childchar=":", parentchar="!")
 * 				mergediscnodes(t)             # <<<<<<<<<<<<<<
 * 			unbinarize(t)
 * 			t = canonicalize(removefanoutmarkers(t))
 */
        __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_mergediscnodes); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_10)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_t};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_t};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 285, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_INCREF(__pyx_v_t);
            __Pyx_GIVEREF(__pyx_v_t);
            PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_t);
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "discodop/coarsetofine.pyx":283
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 * 			if split:             # <<<<<<<<<<<<<<
 * 				unbinarize(t, childchar=":", parentchar="!")
 * 				mergediscnodes(t)
 */
      }

      /* "discodop/coarsetofine.pyx":286
 * 				unbinarize(t, childchar=":", parentchar="!")
 * 				mergediscnodes(t)
 * 			unbinarize(t)             # <<<<<<<<<<<<<<
 * 			t = canonicalize(removefanoutmarkers(t))
 * 			print("exact match" if t == canonicalize(tree) else "no match")
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_unbinarize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_t);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":287
 * 				mergediscnodes(t)
 * 			unbinarize(t)
 * 			t = canonicalize(removefanoutmarkers(t))             # <<<<<<<<<<<<<<
 * 			print("exact match" if t == canonicalize(tree) else "no match")
 * 	else:
 */
      __Pyx_INCREF(__pyx_v_removefanoutmarkers);
      __pyx_t_3 = __pyx_v_removefanoutmarkers; __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_t};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_10);
        } else
        #endif
        {
          __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_t);
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_v_canonicalize);
      __pyx_t_3 = __pyx_v_canonicalize; __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_10};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_10};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":288
 * 			unbinarize(t)
 * 			t = canonicalize(removefanoutmarkers(t))
 * 			print("exact match" if t == canonicalize(tree) else "no match")             # <<<<<<<<<<<<<<
 * 	else:
 * 		print("no parse")
 */
      __Pyx_INCREF(__pyx_v_canonicalize);
      __pyx_t_11 = __pyx_v_canonicalize; __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_tree); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_tree};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_tree};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
        } else
        #endif
        {
          __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_INCREF(__pyx_v_tree);
          __Pyx_GIVEREF(__pyx_v_tree);
          PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_tree);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (__pyx_t_6) {
        __Pyx_INCREF(__pyx_kp_u_exact_match);
        __pyx_t_1 = __pyx_kp_u_exact_match;
      } else {
        __Pyx_INCREF(__pyx_kp_u_no_match);
        __pyx_t_1 = __pyx_kp_u_no_match;
      }
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":280
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 * 		for t, p, _ in mpp:             # <<<<<<<<<<<<<<
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":277
 * 	print(' C O A R S E ')
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 * 	if chart:             # <<<<<<<<<<<<<<
 * 		derivations, entries = getderivations(chart, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart)
 */
    goto __pyx_L7;
  }

  /* "discodop/coarsetofine.pyx":290
 * 			print("exact match" if t == canonicalize(tree) else "no match")
 * 	else:
 * 		print("no parse")             # <<<<<<<<<<<<<<
 * 		return
 * 		# print(chart)
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":291
 * 	else:
 * 		print("no parse")
 * 		return             # <<<<<<<<<<<<<<
 * 		# print(chart)
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }
  __pyx_L7:;

  /* "discodop/coarsetofine.pyx":293
 * 		return
 * 		# print(chart)
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)             # <<<<<<<<<<<<<<
 * 	if verbose:
 * 		print("\nitems in 50-best of coarse chart")
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_prunechart); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_v_chart, __pyx_v_fine, __pyx_v_k, __pyx_v_split, Py_True, Py_False, Py_False};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 7+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_v_chart, __pyx_v_fine, __pyx_v_k, __pyx_v_split, Py_True, Py_False, Py_False};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 7+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(7+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_INCREF(__pyx_v_chart);
    __Pyx_GIVEREF(__pyx_v_chart);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_chart);
    __Pyx_INCREF(__pyx_v_fine);
    __Pyx_GIVEREF(__pyx_v_fine);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_fine);
    __Pyx_INCREF(__pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, __pyx_v_k);
    __Pyx_INCREF(__pyx_v_split);
    __Pyx_GIVEREF(__pyx_v_split);
    PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_7, __pyx_v_split);
    __Pyx_INCREF(Py_True);
    __Pyx_GIVEREF(Py_True);
    PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_7, Py_True);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_3, 5+__pyx_t_7, Py_False);
    __Pyx_INCREF(Py_False);
    __Pyx_GIVEREF(Py_False);
    PyTuple_SET_ITEM(__pyx_t_3, 6+__pyx_t_7, Py_False);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 293, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_11);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 2; __pyx_t_11 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_11)) goto __pyx_L17_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_11);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 3) < 0) __PYX_ERR(0, 293, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L18_unpacking_done;
    __pyx_L17_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 293, __pyx_L1_error)
    __pyx_L18_unpacking_done:;
  }
  __pyx_v_l = __pyx_t_1;
  __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_11);
  __pyx_t_11 = 0;

  /* "discodop/coarsetofine.pyx":294
 * 		# print(chart)
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)
 * 	if verbose:             # <<<<<<<<<<<<<<
 * 		print("\nitems in 50-best of coarse chart")
 * 		_ = lazykbest(chart, k, derivs=False)
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 294, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "discodop/coarsetofine.pyx":295
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)
 * 	if verbose:
 * 		print("\nitems in 50-best of coarse chart")             # <<<<<<<<<<<<<<
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":296
 * 	if verbose:
 * 		print("\nitems in 50-best of coarse chart")
 * 		_ = lazykbest(chart, k, derivs=False)             # <<<<<<<<<<<<<<
 * 		for a in chart.rankededges:
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_lazykbest); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_chart);
    __Pyx_GIVEREF(__pyx_v_chart);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_chart);
    __Pyx_INCREF(__pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_k);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_derivs, Py_False) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v__, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":297
 * 		print("\nitems in 50-best of coarse chart")
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:             # <<<<<<<<<<<<<<
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 * 					bin((<ChartItem>a).vec))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_chart, __pyx_n_s_rankededges); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 297, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 297, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 297, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_3);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 297, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":298
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:
 * 			print(coarse.tolabel[(<ChartItem>a).label],             # <<<<<<<<<<<<<<
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_coarse, __pyx_n_s_tolabel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_t_1, ((struct __pyx_obj_8discodop_10containers_ChartItem *)__pyx_v_a)->label, uint32_t, 0, __Pyx_PyInt_From_uint32_t, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":299
 * 		for a in chart.rankededges:
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 * 					bin((<ChartItem>a).vec))             # <<<<<<<<<<<<<<
 * 		print("\nwhitelist:")
 * 		for n, x in enumerate(l):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_vec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_bin, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "discodop/coarsetofine.pyx":298
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:
 * 			print(coarse.tolabel[(<ChartItem>a).label],             # <<<<<<<<<<<<<<
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")
 */
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
      __pyx_t_11 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":297
 * 		print("\nitems in 50-best of coarse chart")
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:             # <<<<<<<<<<<<<<
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 * 					bin((<ChartItem>a).vec))
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":300
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")             # <<<<<<<<<<<<<<
 * 		for n, x in enumerate(l):
 * 			if isinstance(x, dict):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":301
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")
 * 		for n, x in enumerate(l):             # <<<<<<<<<<<<<<
 * 			if isinstance(x, dict):
 * 				print(fine.tolabel[n], map(bin, x))
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    if (likely(PyList_CheckExact(__pyx_v_l)) || PyTuple_CheckExact(__pyx_v_l)) {
      __pyx_t_1 = __pyx_v_l; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_l); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 301, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 301, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 301, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_9(__pyx_t_1);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 301, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "discodop/coarsetofine.pyx":302
 * 		print("\nwhitelist:")
 * 		for n, x in enumerate(l):
 * 			if isinstance(x, dict):             # <<<<<<<<<<<<<<
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:
 */
      __pyx_t_6 = PyDict_Check(__pyx_v_x); 
      __pyx_t_12 = (__pyx_t_6 != 0);
      if (__pyx_t_12) {

        /* "discodop/coarsetofine.pyx":303
 * 		for n, x in enumerate(l):
 * 			if isinstance(x, dict):
 * 				print(fine.tolabel[n], map(bin, x))             # <<<<<<<<<<<<<<
 * 			elif x:
 * 				for m, y in enumerate(x):
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fine, __pyx_n_s_tolabel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = PyObject_GetItem(__pyx_t_4, __pyx_v_n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_builtin_bin);
        __Pyx_GIVEREF(__pyx_builtin_bin);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_builtin_bin);
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_x);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
        __pyx_t_11 = 0;
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "discodop/coarsetofine.pyx":302
 * 		print("\nwhitelist:")
 * 		for n, x in enumerate(l):
 * 			if isinstance(x, dict):             # <<<<<<<<<<<<<<
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:
 */
        goto __pyx_L24;
      }

      /* "discodop/coarsetofine.pyx":304
 * 			if isinstance(x, dict):
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:             # <<<<<<<<<<<<<<
 * 				for m, y in enumerate(x):
 * 					print(fine.tolabel[n], m, map(bin, y))
 */
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_x); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 304, __pyx_L1_error)
      if (__pyx_t_12) {

        /* "discodop/coarsetofine.pyx":305
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:
 * 				for m, y in enumerate(x):             # <<<<<<<<<<<<<<
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')
 */
        __Pyx_INCREF(__pyx_int_0);
        __pyx_t_2 = __pyx_int_0;
        if (likely(PyList_CheckExact(__pyx_v_x)) || PyTuple_CheckExact(__pyx_v_x)) {
          __pyx_t_4 = __pyx_v_x; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0;
          __pyx_t_14 = NULL;
        } else {
          __pyx_t_13 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_14 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 305, __pyx_L1_error)
        }
        for (;;) {
          if (likely(!__pyx_t_14)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_11); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 305, __pyx_L1_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 305, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            } else {
              if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_11); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 305, __pyx_L1_error)
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 305, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_11);
              #endif
            }
          } else {
            __pyx_t_11 = __pyx_t_14(__pyx_t_4);
            if (unlikely(!__pyx_t_11)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 305, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_11);
          __pyx_t_11 = 0;
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_2);
          __pyx_t_11 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_2);
          __pyx_t_2 = __pyx_t_11;
          __pyx_t_11 = 0;

          /* "discodop/coarsetofine.pyx":306
 * 			elif x:
 * 				for m, y in enumerate(x):
 * 					print(fine.tolabel[n], m, map(bin, y))             # <<<<<<<<<<<<<<
 * 	print(' F I N E ')
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_fine, __pyx_n_s_tolabel); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_10 = PyObject_GetItem(__pyx_t_11, __pyx_v_n); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_INCREF(__pyx_builtin_bin);
          __Pyx_GIVEREF(__pyx_builtin_bin);
          PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_bin);
          __Pyx_INCREF(__pyx_v_y);
          __Pyx_GIVEREF(__pyx_v_y);
          PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_y);
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_11, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
          __Pyx_INCREF(__pyx_v_m);
          __Pyx_GIVEREF(__pyx_v_m);
          PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_m);
          __Pyx_GIVEREF(__pyx_t_15);
          PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_15);
          __pyx_t_10 = 0;
          __pyx_t_15 = 0;
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_11, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 306, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

          /* "discodop/coarsetofine.pyx":305
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:
 * 				for m, y in enumerate(x):             # <<<<<<<<<<<<<<
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')
 */
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "discodop/coarsetofine.pyx":304
 * 			if isinstance(x, dict):
 * 				print(fine.tolabel[n], map(bin, x))
 * 			elif x:             # <<<<<<<<<<<<<<
 * 				for m, y in enumerate(x):
 * 					print(fine.tolabel[n], m, map(bin, y))
 */
      }
      __pyx_L24:;

      /* "discodop/coarsetofine.pyx":301
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")
 * 		for n, x in enumerate(l):             # <<<<<<<<<<<<<<
 * 			if isinstance(x, dict):
 * 				print(fine.tolabel[n], map(bin, x))
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":294
 * 		# print(chart)
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)
 * 	if verbose:             # <<<<<<<<<<<<<<
 * 		print("\nitems in 50-best of coarse chart")
 * 		_ = lazykbest(chart, k, derivs=False)
 */
  }

  /* "discodop/coarsetofine.pyx":307
 * 				for m, y in enumerate(x):
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')             # <<<<<<<<<<<<<<
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 * 			splitprune=split, markorigin=True)
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":308
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,             # <<<<<<<<<<<<<<
 * 			splitprune=split, markorigin=True)
 * 	if chart2:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plcfrs, __pyx_n_s_parse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_sent);
  __Pyx_GIVEREF(__pyx_v_sent);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sent);
  __Pyx_INCREF(__pyx_v_fine);
  __Pyx_GIVEREF(__pyx_v_fine);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_fine);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_tags, __pyx_v_tags) < 0) __PYX_ERR(0, 308, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_whitelist_2, __pyx_v_l) < 0) __PYX_ERR(0, 308, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":309
 * 	print(' F I N E ')
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 * 			splitprune=split, markorigin=True)             # <<<<<<<<<<<<<<
 * 	if chart2:
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 */
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_splitprune, __pyx_v_split) < 0) __PYX_ERR(0, 308, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_markorigin, Py_True) < 0) __PYX_ERR(0, 308, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":308
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,             # <<<<<<<<<<<<<<
 * 			splitprune=split, markorigin=True)
 * 	if chart2:
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 308, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L27_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L27_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 308, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L28_unpacking_done;
    __pyx_L27_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 308, __pyx_L1_error)
    __pyx_L28_unpacking_done:;
  }
  __pyx_v_chart2 = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":310
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 * 			splitprune=split, markorigin=True)
 * 	if chart2:             # <<<<<<<<<<<<<<
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 */
  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_chart2); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 310, __pyx_L1_error)
  if (__pyx_t_12) {

    /* "discodop/coarsetofine.pyx":311
 * 			splitprune=split, markorigin=True)
 * 	if chart2:
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)             # <<<<<<<<<<<<<<
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 * 		for t, p, _ in mpp:
 */
    __Pyx_INCREF(__pyx_v_getderivations);
    __pyx_t_1 = __pyx_v_getderivations; __pyx_t_2 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_v_chart2, __pyx_int_10, Py_True, Py_False, Py_True};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[6] = {__pyx_t_2, __pyx_v_chart2, __pyx_int_10, Py_True, Py_False, Py_True};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_chart2);
      __Pyx_GIVEREF(__pyx_v_chart2);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_chart2);
      __Pyx_INCREF(__pyx_int_10);
      __Pyx_GIVEREF(__pyx_int_10);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_int_10);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, Py_True);
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_7, Py_False);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_3, 4+__pyx_t_7, Py_True);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 311, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L30_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L30_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_2), 2) < 0) __PYX_ERR(0, 311, __pyx_L1_error)
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L31_unpacking_done;
      __pyx_L30_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 311, __pyx_L1_error)
      __pyx_L31_unpacking_done:;
    }
    __Pyx_DECREF_SET(__pyx_v_derivations, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_entries, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":312
 * 	if chart2:
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)             # <<<<<<<<<<<<<<
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')
 */
    __Pyx_INCREF(__pyx_v_marginalize);
    __pyx_t_3 = __pyx_v_marginalize; __pyx_t_1 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_n_u_mpp, __pyx_v_derivations, __pyx_v_entries, __pyx_v_chart2};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_n_u_mpp, __pyx_v_derivations, __pyx_v_entries, __pyx_v_chart2};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_n_u_mpp);
      __Pyx_GIVEREF(__pyx_n_u_mpp);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_n_u_mpp);
      __Pyx_INCREF(__pyx_v_derivations);
      __Pyx_GIVEREF(__pyx_v_derivations);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_v_derivations);
      __Pyx_INCREF(__pyx_v_entries);
      __Pyx_GIVEREF(__pyx_v_entries);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_7, __pyx_v_entries);
      __Pyx_INCREF(__pyx_v_chart2);
      __Pyx_GIVEREF(__pyx_v_chart2);
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_7, __pyx_v_chart2);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 312, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L32_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L32_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_1), 2) < 0) __PYX_ERR(0, 312, __pyx_L1_error)
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L33_unpacking_done;
      __pyx_L32_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 312, __pyx_L1_error)
      __pyx_L33_unpacking_done:;
    }
    __Pyx_DECREF_SET(__pyx_v_mpp, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v__, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "discodop/coarsetofine.pyx":313
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 * 		for t, p, _ in mpp:             # <<<<<<<<<<<<<<
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 */
    if (likely(PyList_CheckExact(__pyx_v_mpp)) || PyTuple_CheckExact(__pyx_v_mpp)) {
      __pyx_t_4 = __pyx_v_mpp; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_mpp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 313, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 313, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 313, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_9(__pyx_t_4);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 313, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 313, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_15 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_15 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_15);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_15 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 313, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 313, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L36_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L36_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        index = 2; __pyx_t_15 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_15)) goto __pyx_L36_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_15);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_11), 3) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
        __pyx_t_5 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L37_unpacking_done;
        __pyx_L36_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_5 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 313, __pyx_L1_error)
        __pyx_L37_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v__, __pyx_t_15);
      __pyx_t_15 = 0;

      /* "discodop/coarsetofine.pyx":314
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')             # <<<<<<<<<<<<<<
 * 			t = Tree.parse(t)
 * 			unbinarize(t)
 */
      __pyx_t_15 = PyNumber_Negative(__pyx_v_p); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 314, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_INCREF(__pyx_v_pyexp);
      __pyx_t_1 = __pyx_v_pyexp; __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_15};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_15};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 314, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_15);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_15);
          __pyx_t_15 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 314, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_end, __pyx_kp_u__7) < 0) __PYX_ERR(0, 314, __pyx_L1_error)
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 314, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":315
 * 		for t, p, _ in mpp:
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)             # <<<<<<<<<<<<<<
 * 			unbinarize(t)
 * 			t = canonicalize(removefanoutmarkers(t))
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Tree); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 315, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_parse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 315, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_t); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 315, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2); __pyx_t_2 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_t);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":316
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 * 			unbinarize(t)             # <<<<<<<<<<<<<<
 * 			t = canonicalize(removefanoutmarkers(t))
 * 			# print(t)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_unbinarize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_t); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_t};
          __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_11);
        } else
        #endif
        {
          __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_15); __pyx_t_15 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_t);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":317
 * 			t = Tree.parse(t)
 * 			unbinarize(t)
 * 			t = canonicalize(removefanoutmarkers(t))             # <<<<<<<<<<<<<<
 * 			# print(t)
 * 			print("exact match" if t == canonicalize(tree) else "no match", t)
 */
      __Pyx_INCREF(__pyx_v_removefanoutmarkers);
      __pyx_t_2 = __pyx_v_removefanoutmarkers; __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_15); __pyx_t_15 = NULL;
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_t);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_INCREF(__pyx_v_canonicalize);
      __pyx_t_2 = __pyx_v_canonicalize; __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_11);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
          __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
          __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_t, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":319
 * 			t = canonicalize(removefanoutmarkers(t))
 * 			# print(t)
 * 			print("exact match" if t == canonicalize(tree) else "no match", t)             # <<<<<<<<<<<<<<
 * 	else:
 * 		print("no parse. problem.")
 */
      __Pyx_INCREF(__pyx_v_canonicalize);
      __pyx_t_15 = __pyx_v_canonicalize; __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_15, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_tree); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_15)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_tree};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_tree};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_INCREF(__pyx_v_tree);
          __Pyx_GIVEREF(__pyx_v_tree);
          PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_tree);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyObject_RichCompare(__pyx_v_t, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (__pyx_t_12) {
        __Pyx_INCREF(__pyx_kp_u_exact_match);
        __pyx_t_11 = __pyx_kp_u_exact_match;
      } else {
        __Pyx_INCREF(__pyx_kp_u_no_match);
        __pyx_t_11 = __pyx_kp_u_no_match;
      }
      __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_11);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_t);
      __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":313
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 * 		for t, p, _ in mpp:             # <<<<<<<<<<<<<<
 * 			print(pyexp(-p), end=' ')
 * 			t = Tree.parse(t)
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":310
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 * 			splitprune=split, markorigin=True)
 * 	if chart2:             # <<<<<<<<<<<<<<
 * 		derivations, entries = getderivations(chart2, 10, True, False, True)
 * 		mpp, _ = marginalize("mpp", derivations, entries, chart2)
 */
    goto __pyx_L29;
  }

  /* "discodop/coarsetofine.pyx":321
 * 			print("exact match" if t == canonicalize(tree) else "no match", t)
 * 	else:
 * 		print("no parse. problem.")             # <<<<<<<<<<<<<<
 * 		return
 * 		# if verbose:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 321, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":322
 * 	else:
 * 		print("no parse. problem.")
 * 		return             # <<<<<<<<<<<<<<
 * 		# if verbose:
 * 		# xp = set((coarse.tolabel[a.label], a.vec) for a in chart.keys()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }
  __pyx_L29:;

  /* "discodop/coarsetofine.pyx":268
 * 
 * 
 * def doctftest(coarse, fine, sent, tree, k, split, verbose=False):             # <<<<<<<<<<<<<<
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("discodop.coarsetofine.doctftest", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_plcfrs);
  __Pyx_XDECREF(__pyx_v_getderivations);
  __Pyx_XDECREF(__pyx_v_marginalize);
  __Pyx_XDECREF(__pyx_v_canonicalize);
  __Pyx_XDECREF(__pyx_v_removefanoutmarkers);
  __Pyx_XDECREF(__pyx_v_pyexp);
  __Pyx_XDECREF(__pyx_v_tags);
  __Pyx_XDECREF(__pyx_v_chart);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_derivations);
  __Pyx_XDECREF(__pyx_v_entries);
  __Pyx_XDECREF(__pyx_v_mpp);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_chart2);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "discodop/coarsetofine.pyx":339
 * 
 * 
 * def test():             # <<<<<<<<<<<<<<
 * 	import re
 * 	from time import clock
 */

/* Python wrapper */
static PyObject *__pyx_pw_8discodop_12coarsetofine_13test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8discodop_12coarsetofine_12test[] = "test()";
static PyMethodDef __pyx_mdef_8discodop_12coarsetofine_13test = {"test", (PyCFunction)__pyx_pw_8discodop_12coarsetofine_13test, METH_NOARGS, __pyx_doc_8discodop_12coarsetofine_12test};
static PyObject *__pyx_pw_8discodop_12coarsetofine_13test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("test (wrapper)", 0);
  __pyx_r = __pyx_pf_8discodop_12coarsetofine_12test(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8discodop_12coarsetofine_12test(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_v_re = NULL;
  PyObject *__pyx_v_clock = NULL;
  PyObject *__pyx_v_splitdiscnodes = NULL;
  PyObject *__pyx_v_binarize = NULL;
  PyObject *__pyx_v_addfanoutmarkers = NULL;
  PyObject *__pyx_v_NegraCorpusReader = NULL;
  PyObject *__pyx_v_treebankgrammar = NULL;
  PyObject *__pyx_v_dopreduction = NULL;
  PyObject *__pyx_v_subsetgrammar = NULL;
  long __pyx_v_k;
  PyObject *__pyx_v_corpus = NULL;
  PyObject *__pyx_v_train = NULL;
  PyObject *__pyx_v_test = NULL;
  long __pyx_v_testmaxlen;
  PyObject *__pyx_v_trees = NULL;
  PyObject *__pyx_v_sents = NULL;
  PyObject *__pyx_v_dtrees = NULL;
  PyObject *__pyx_v_parenttrees = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_cftrees = NULL;
  PyObject *__pyx_v_normallcfrs = NULL;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_normal = NULL;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_parent = NULL;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_splitg = NULL;
  PyObject *__pyx_v_s = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_yf = NULL;
  PyObject *__pyx_v_fine999x = NULL;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_fine999 = NULL;
  struct __pyx_obj_8discodop_10containers_Grammar *__pyx_v_fine1 = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_coarse = NULL;
  PyObject *__pyx_v_fine = NULL;
  PyObject *__pyx_v_split = NULL;
  PyObject *__pyx_v_enabled = NULL;
  PyObject *__pyx_v_begin = NULL;
  PyObject *__pyx_v_n = NULL;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_tree = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  __Pyx_RefNannySetupContext("test", 0);

  /* "discodop/coarsetofine.pyx":340
 * 
 * def test():
 * 	import re             # <<<<<<<<<<<<<<
 * 	from time import clock
 * 	from .treetransforms import splitdiscnodes, binarize, addfanoutmarkers
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_re = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":341
 * def test():
 * 	import re
 * 	from time import clock             # <<<<<<<<<<<<<<
 * 	from .treetransforms import splitdiscnodes, binarize, addfanoutmarkers
 * 	from .treebank import NegraCorpusReader
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_clock);
  __Pyx_GIVEREF(__pyx_n_s_clock);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_clock);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_time, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_clock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_clock = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":342
 * 	import re
 * 	from time import clock
 * 	from .treetransforms import splitdiscnodes, binarize, addfanoutmarkers             # <<<<<<<<<<<<<<
 * 	from .treebank import NegraCorpusReader
 * 	from .grammar import treebankgrammar, dopreduction, subsetgrammar
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_splitdiscnodes);
  __Pyx_GIVEREF(__pyx_n_s_splitdiscnodes);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_splitdiscnodes);
  __Pyx_INCREF(__pyx_n_s_binarize);
  __Pyx_GIVEREF(__pyx_n_s_binarize);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_binarize);
  __Pyx_INCREF(__pyx_n_s_addfanoutmarkers);
  __Pyx_GIVEREF(__pyx_n_s_addfanoutmarkers);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_addfanoutmarkers);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_treetransforms, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_splitdiscnodes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_splitdiscnodes = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_binarize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_binarize = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_addfanoutmarkers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_addfanoutmarkers = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":343
 * 	from time import clock
 * 	from .treetransforms import splitdiscnodes, binarize, addfanoutmarkers
 * 	from .treebank import NegraCorpusReader             # <<<<<<<<<<<<<<
 * 	from .grammar import treebankgrammar, dopreduction, subsetgrammar
 * 	k = 50
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_NegraCorpusReader);
  __Pyx_GIVEREF(__pyx_n_s_NegraCorpusReader);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_NegraCorpusReader);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_treebank, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NegraCorpusReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_NegraCorpusReader = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":344
 * 	from .treetransforms import splitdiscnodes, binarize, addfanoutmarkers
 * 	from .treebank import NegraCorpusReader
 * 	from .grammar import treebankgrammar, dopreduction, subsetgrammar             # <<<<<<<<<<<<<<
 * 	k = 50
 * 	# corpus = NegraCorpusReader("toytb.export", encoding="iso-8859-1")
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_treebankgrammar);
  __Pyx_GIVEREF(__pyx_n_s_treebankgrammar);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_treebankgrammar);
  __Pyx_INCREF(__pyx_n_s_dopreduction);
  __Pyx_GIVEREF(__pyx_n_s_dopreduction);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_dopreduction);
  __Pyx_INCREF(__pyx_n_s_subsetgrammar);
  __Pyx_GIVEREF(__pyx_n_s_subsetgrammar);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_subsetgrammar);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_grammar, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_treebankgrammar); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_treebankgrammar = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_dopreduction); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_dopreduction = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_subsetgrammar); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_subsetgrammar = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":345
 * 	from .treebank import NegraCorpusReader
 * 	from .grammar import treebankgrammar, dopreduction, subsetgrammar
 * 	k = 50             # <<<<<<<<<<<<<<
 * 	# corpus = NegraCorpusReader("toytb.export", encoding="iso-8859-1")
 * 	# corpus = NegraCorpusReader("negraproc.export",
 */
  __pyx_v_k = 50;

  /* "discodop/coarsetofine.pyx":353
 * 	# test = 40
 * 	# testmaxlen = 999
 * 	corpus = NegraCorpusReader('alpinosample.export')             # <<<<<<<<<<<<<<
 * 	train = 0
 * 	test = 3
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_NegraCorpusReader, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_corpus = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":354
 * 	# testmaxlen = 999
 * 	corpus = NegraCorpusReader('alpinosample.export')
 * 	train = 0             # <<<<<<<<<<<<<<
 * 	test = 3
 * 	testmaxlen = 999
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_train = __pyx_int_0;

  /* "discodop/coarsetofine.pyx":355
 * 	corpus = NegraCorpusReader('alpinosample.export')
 * 	train = 0
 * 	test = 3             # <<<<<<<<<<<<<<
 * 	testmaxlen = 999
 * 	# trees = corpus.trees().values()[:train]
 */
  __Pyx_INCREF(__pyx_int_3);
  __pyx_v_test = __pyx_int_3;

  /* "discodop/coarsetofine.pyx":356
 * 	train = 0
 * 	test = 3
 * 	testmaxlen = 999             # <<<<<<<<<<<<<<
 * 	# trees = corpus.trees().values()[:train]
 * 	# sents = corpus.sents().values()[:train]
 */
  __pyx_v_testmaxlen = 0x3E7;

  /* "discodop/coarsetofine.pyx":359
 * 	# trees = corpus.trees().values()[:train]
 * 	# sents = corpus.sents().values()[:train]
 * 	trees = list(corpus.trees().values())             # <<<<<<<<<<<<<<
 * 	sents = list(corpus.sents().values())
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_corpus, __pyx_n_s_trees); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 359, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_trees = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":360
 * 	# sents = corpus.sents().values()[:train]
 * 	trees = list(corpus.trees().values())
 * 	sents = list(corpus.sents().values())             # <<<<<<<<<<<<<<
 * 
 * 	dtrees = [t.copy(True) for t in trees]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_corpus, __pyx_n_s_sents); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_sents = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":362
 * 	sents = list(corpus.sents().values())
 * 
 * 	dtrees = [t.copy(True) for t in trees]             # <<<<<<<<<<<<<<
 * 	parenttrees = [t.copy(True) for t in trees]
 * 	for t in trees:
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr4__pyx_v_t = NULL;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_v_trees; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 362, __pyx_L5_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_t, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr4__pyx_v_t, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 362, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_t);
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_t);
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_dtrees = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":363
 * 
 * 	dtrees = [t.copy(True) for t in trees]
 * 	parenttrees = [t.copy(True) for t in trees]             # <<<<<<<<<<<<<<
 * 	for t in trees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr5__pyx_v_t = NULL;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_v_trees; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 363, __pyx_L11_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 363, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_t, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 363, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 363, __pyx_L11_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_t);
    goto __pyx_L14_exit_scope;
    __pyx_L11_error:;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_t);
    goto __pyx_L1_error;
    __pyx_L14_exit_scope:;
  } /* exit inner scope */
  __pyx_v_parenttrees = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":364
 * 	dtrees = [t.copy(True) for t in trees]
 * 	parenttrees = [t.copy(True) for t in trees]
 * 	for t in trees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  __pyx_t_2 = __pyx_v_trees; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 364, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":365
 * 	parenttrees = [t.copy(True) for t in trees]
 * 	for t in trees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)             # <<<<<<<<<<<<<<
 * 		addfanoutmarkers(t)
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_t);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_vertmarkov, __pyx_int_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_horzmarkov, __pyx_int_1) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_binarize, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":366
 * 	for t in trees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)             # <<<<<<<<<<<<<<
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]
 * 	for t in cftrees:
 */
    __Pyx_INCREF(__pyx_v_addfanoutmarkers);
    __pyx_t_1 = __pyx_v_addfanoutmarkers; __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_t};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_t};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_t);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":364
 * 	dtrees = [t.copy(True) for t in trees]
 * 	parenttrees = [t.copy(True) for t in trees]
 * 	for t in trees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":367
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]             # <<<<<<<<<<<<<<
 * 	for t in cftrees:
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr6__pyx_v_t = NULL;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L19_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_v_trees; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 367, __pyx_L19_error)
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_t, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr6__pyx_v_t, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_markorigin, Py_True) < 0) __PYX_ERR(0, 367, __pyx_L19_error)
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_splitdiscnodes, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 367, __pyx_L19_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_t);
    goto __pyx_L22_exit_scope;
    __pyx_L19_error:;
    __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_t);
    goto __pyx_L1_error;
    __pyx_L22_exit_scope:;
  } /* exit inner scope */
  __pyx_v_cftrees = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":368
 * 		addfanoutmarkers(t)
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]
 * 	for t in cftrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,
 * 			childchar=":")  # NB leftmostunary is important
 */
  __pyx_t_2 = __pyx_v_cftrees; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 368, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":369
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]
 * 	for t in cftrees:
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,             # <<<<<<<<<<<<<<
 * 			childchar=":")  # NB leftmostunary is important
 * 		addfanoutmarkers(t)
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_t);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_horzmarkov, __pyx_int_2) < 0) __PYX_ERR(0, 369, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_tailmarker, __pyx_kp_u__5) < 0) __PYX_ERR(0, 369, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_leftmostunary, Py_True) < 0) __PYX_ERR(0, 369, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_childchar, __pyx_kp_u__8) < 0) __PYX_ERR(0, 369, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_binarize, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "discodop/coarsetofine.pyx":371
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,
 * 			childchar=":")  # NB leftmostunary is important
 * 		addfanoutmarkers(t)             # <<<<<<<<<<<<<<
 * 	for t in parenttrees:
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 */
    __Pyx_INCREF(__pyx_v_addfanoutmarkers);
    __pyx_t_3 = __pyx_v_addfanoutmarkers; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_t};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_t};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_t);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "discodop/coarsetofine.pyx":368
 * 		addfanoutmarkers(t)
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]
 * 	for t in cftrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,
 * 			childchar=":")  # NB leftmostunary is important
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":372
 * 			childchar=":")  # NB leftmostunary is important
 * 		addfanoutmarkers(t)
 * 	for t in parenttrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  __pyx_t_2 = __pyx_v_parenttrees; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 372, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "discodop/coarsetofine.pyx":373
 * 		addfanoutmarkers(t)
 * 	for t in parenttrees:
 * 		binarize(t, vertmarkov=3, horzmarkov=1)             # <<<<<<<<<<<<<<
 * 		addfanoutmarkers(t)
 * 	for t in dtrees:
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_t);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_vertmarkov, __pyx_int_3) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_horzmarkov, __pyx_int_1) < 0) __PYX_ERR(0, 373, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_binarize, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":374
 * 	for t in parenttrees:
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 * 		addfanoutmarkers(t)             # <<<<<<<<<<<<<<
 * 	for t in dtrees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 */
    __Pyx_INCREF(__pyx_v_addfanoutmarkers);
    __pyx_t_3 = __pyx_v_addfanoutmarkers; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_t};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_t};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_t);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 374, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":372
 * 			childchar=":")  # NB leftmostunary is important
 * 		addfanoutmarkers(t)
 * 	for t in parenttrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":375
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 * 		addfanoutmarkers(t)
 * 	for t in dtrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  __pyx_t_2 = __pyx_v_dtrees; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":376
 * 		addfanoutmarkers(t)
 * 	for t in dtrees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)             # <<<<<<<<<<<<<<
 * 		addfanoutmarkers(t)
 * 	normallcfrs = treebankgrammar(trees, sents)
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_t);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_vertmarkov, __pyx_int_1) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_horzmarkov, __pyx_int_1) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_binarize, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":377
 * 	for t in dtrees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)             # <<<<<<<<<<<<<<
 * 	normallcfrs = treebankgrammar(trees, sents)
 * 	normal = Grammar(normallcfrs)
 */
    __Pyx_INCREF(__pyx_v_addfanoutmarkers);
    __pyx_t_3 = __pyx_v_addfanoutmarkers; __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_t};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_t};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_INCREF(__pyx_v_t);
        __Pyx_GIVEREF(__pyx_v_t);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_t);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":375
 * 		binarize(t, vertmarkov=3, horzmarkov=1)
 * 		addfanoutmarkers(t)
 * 	for t in dtrees:             # <<<<<<<<<<<<<<
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":378
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 * 	normallcfrs = treebankgrammar(trees, sents)             # <<<<<<<<<<<<<<
 * 	normal = Grammar(normallcfrs)
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))
 */
  __Pyx_INCREF(__pyx_v_treebankgrammar);
  __pyx_t_4 = __pyx_v_treebankgrammar; __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_trees, __pyx_v_sents};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_trees, __pyx_v_sents};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_trees);
    __Pyx_GIVEREF(__pyx_v_trees);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_trees);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_sents);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_normallcfrs = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "discodop/coarsetofine.pyx":379
 * 		addfanoutmarkers(t)
 * 	normallcfrs = treebankgrammar(trees, sents)
 * 	normal = Grammar(normallcfrs)             # <<<<<<<<<<<<<<
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_normallcfrs);
  __Pyx_GIVEREF(__pyx_v_normallcfrs);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_normallcfrs);
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8discodop_10containers_Grammar), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_normal = ((struct __pyx_obj_8discodop_10containers_Grammar *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":380
 * 	normallcfrs = treebankgrammar(trees, sents)
 * 	normal = Grammar(normallcfrs)
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))             # <<<<<<<<<<<<<<
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 * 	for t, s in zip(cftrees, sents):
 */
  __Pyx_INCREF(__pyx_v_treebankgrammar);
  __pyx_t_2 = __pyx_v_treebankgrammar; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_parenttrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_parenttrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_parenttrees);
    __Pyx_GIVEREF(__pyx_v_parenttrees);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_7, __pyx_v_parenttrees);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_7, __pyx_v_sents);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8discodop_10containers_Grammar), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_parent = ((struct __pyx_obj_8discodop_10containers_Grammar *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":381
 * 	normal = Grammar(normallcfrs)
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))             # <<<<<<<<<<<<<<
 * 	for t, s in zip(cftrees, sents):
 * 		for (_, yf), _ in treebankgrammar([t], [s]):
 */
  __Pyx_INCREF(__pyx_v_treebankgrammar);
  __pyx_t_2 = __pyx_v_treebankgrammar; __pyx_t_3 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cftrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cftrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_cftrees);
    __Pyx_GIVEREF(__pyx_v_cftrees);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_cftrees);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_sents);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8discodop_10containers_Grammar), __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_splitg = ((struct __pyx_obj_8discodop_10containers_Grammar *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":382
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 * 	for t, s in zip(cftrees, sents):             # <<<<<<<<<<<<<<
 * 		for (_, yf), _ in treebankgrammar([t], [s]):
 * 			assert len(yf) == 1
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_cftrees);
  __Pyx_GIVEREF(__pyx_v_cftrees);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_cftrees);
  __Pyx_INCREF(__pyx_v_sents);
  __Pyx_GIVEREF(__pyx_v_sents);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_sents);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 382, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 382, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 382, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 382, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_4);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 382, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 382, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 382, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 382, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_6)) goto __pyx_L31_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_3 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L31_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_1), 2) < 0) __PYX_ERR(0, 382, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L32_unpacking_done;
      __pyx_L31_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 382, __pyx_L1_error)
      __pyx_L32_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":383
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 * 	for t, s in zip(cftrees, sents):
 * 		for (_, yf), _ in treebankgrammar([t], [s]):             # <<<<<<<<<<<<<<
 * 			assert len(yf) == 1
 * 	fine999x = dopreduction(trees, sents)[0]
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_t);
    __Pyx_GIVEREF(__pyx_v_t);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_t);
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_s);
    __Pyx_GIVEREF(__pyx_v_s);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_s);
    __Pyx_INCREF(__pyx_v_treebankgrammar);
    __pyx_t_1 = __pyx_v_treebankgrammar; __pyx_t_10 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_3, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_3, __pyx_t_6};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_7, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_7, __pyx_t_6);
      __pyx_t_3 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 383, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_13(__pyx_t_1);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 383, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 383, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_6);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_11)) goto __pyx_L35_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_6 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L35_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_3), 2) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L36_unpacking_done;
        __pyx_L35_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 383, __pyx_L1_error)
        __pyx_L36_unpacking_done:;
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
        PyObject* sequence = __pyx_t_11;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 383, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_14 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_14)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_3)) goto __pyx_L37_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_10 = __pyx_t_9(__pyx_t_14); if (unlikely(!__pyx_t_10)) goto __pyx_L37_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_14), 2) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L38_unpacking_done;
        __pyx_L37_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 383, __pyx_L1_error)
        __pyx_L38_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_yf, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v__, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "discodop/coarsetofine.pyx":384
 * 	for t, s in zip(cftrees, sents):
 * 		for (_, yf), _ in treebankgrammar([t], [s]):
 * 			assert len(yf) == 1             # <<<<<<<<<<<<<<
 * 	fine999x = dopreduction(trees, sents)[0]
 * 	fine999 = Grammar(fine999x)
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_15 = PyObject_Length(__pyx_v_yf); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 384, __pyx_L1_error)
        if (unlikely(!((__pyx_t_15 == 1) != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 384, __pyx_L1_error)
        }
      }
      #endif

      /* "discodop/coarsetofine.pyx":383
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 * 	for t, s in zip(cftrees, sents):
 * 		for (_, yf), _ in treebankgrammar([t], [s]):             # <<<<<<<<<<<<<<
 * 			assert len(yf) == 1
 * 	fine999x = dopreduction(trees, sents)[0]
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":382
 * 	parent = Grammar(treebankgrammar(parenttrees, sents))
 * 	splitg = Grammar(treebankgrammar(cftrees, sents))
 * 	for t, s in zip(cftrees, sents):             # <<<<<<<<<<<<<<
 * 		for (_, yf), _ in treebankgrammar([t], [s]):
 * 			assert len(yf) == 1
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":385
 * 		for (_, yf), _ in treebankgrammar([t], [s]):
 * 			assert len(yf) == 1
 * 	fine999x = dopreduction(trees, sents)[0]             # <<<<<<<<<<<<<<
 * 	fine999 = Grammar(fine999x)
 * 	fine1 = Grammar(dopreduction(dtrees, sents)[0])
 */
  __Pyx_INCREF(__pyx_v_dopreduction);
  __pyx_t_1 = __pyx_v_dopreduction; __pyx_t_2 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_trees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_trees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_trees);
    __Pyx_GIVEREF(__pyx_v_trees);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_trees);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_sents);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_fine999x = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":386
 * 			assert len(yf) == 1
 * 	fine999x = dopreduction(trees, sents)[0]
 * 	fine999 = Grammar(fine999x)             # <<<<<<<<<<<<<<
 * 	fine1 = Grammar(dopreduction(dtrees, sents)[0])
 * 	trees = list(corpus.trees().values())[train:train + test]
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_fine999x);
  __Pyx_GIVEREF(__pyx_v_fine999x);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fine999x);
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8discodop_10containers_Grammar), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_fine999 = ((struct __pyx_obj_8discodop_10containers_Grammar *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":387
 * 	fine999x = dopreduction(trees, sents)[0]
 * 	fine999 = Grammar(fine999x)
 * 	fine1 = Grammar(dopreduction(dtrees, sents)[0])             # <<<<<<<<<<<<<<
 * 	trees = list(corpus.trees().values())[train:train + test]
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 */
  __Pyx_INCREF(__pyx_v_dopreduction);
  __pyx_t_1 = __pyx_v_dopreduction; __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dtrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_dtrees, __pyx_v_sents};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_v_dtrees);
    __Pyx_GIVEREF(__pyx_v_dtrees);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_dtrees);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_v_sents);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8discodop_10containers_Grammar), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_fine1 = ((struct __pyx_obj_8discodop_10containers_Grammar *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":388
 * 	fine999 = Grammar(fine999x)
 * 	fine1 = Grammar(dopreduction(dtrees, sents)[0])
 * 	trees = list(corpus.trees().values())[train:train + test]             # <<<<<<<<<<<<<<
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 * 	if subsetgrammar(normallcfrs, fine999x):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_corpus, __pyx_n_s_trees); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_train); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L1_error)
  __pyx_t_1 = PyNumber_Add(__pyx_v_train, __pyx_v_test); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_t_2, __pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_trees, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":389
 * 	fine1 = Grammar(dopreduction(dtrees, sents)[0])
 * 	trees = list(corpus.trees().values())[train:train + test]
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]             # <<<<<<<<<<<<<<
 * 	if subsetgrammar(normallcfrs, fine999x):
 * 		print("DOP grammar is a superset")
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_corpus, __pyx_n_s_tagged_sents); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_v_train); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L1_error)
  __pyx_t_1 = PyNumber_Add(__pyx_v_train, __pyx_v_test); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_t_4, __pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_sents, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "discodop/coarsetofine.pyx":390
 * 	trees = list(corpus.trees().values())[train:train + test]
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 * 	if subsetgrammar(normallcfrs, fine999x):             # <<<<<<<<<<<<<<
 * 		print("DOP grammar is a superset")
 * 	else:
 */
  __Pyx_INCREF(__pyx_v_subsetgrammar);
  __pyx_t_4 = __pyx_v_subsetgrammar; __pyx_t_2 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_normallcfrs, __pyx_v_fine999x};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_normallcfrs, __pyx_v_fine999x};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_normallcfrs);
    __Pyx_GIVEREF(__pyx_v_normallcfrs);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_normallcfrs);
    __Pyx_INCREF(__pyx_v_fine999x);
    __Pyx_GIVEREF(__pyx_v_fine999x);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_fine999x);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_16) {

    /* "discodop/coarsetofine.pyx":391
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 * 	if subsetgrammar(normallcfrs, fine999x):
 * 		print("DOP grammar is a superset")             # <<<<<<<<<<<<<<
 * 	else:
 * 		print("DOP grammar is NOT a superset!")
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "discodop/coarsetofine.pyx":390
 * 	trees = list(corpus.trees().values())[train:train + test]
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 * 	if subsetgrammar(normallcfrs, fine999x):             # <<<<<<<<<<<<<<
 * 		print("DOP grammar is a superset")
 * 	else:
 */
    goto __pyx_L39;
  }

  /* "discodop/coarsetofine.pyx":393
 * 		print("DOP grammar is a superset")
 * 	else:
 * 		print("DOP grammar is NOT a superset!")             # <<<<<<<<<<<<<<
 * 	for msg, coarse, fine, split, enabled in zip(
 * 			('normal', 'parentannot', 'cf-split'),
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L39:;

  /* "discodop/coarsetofine.pyx":396
 * 	for msg, coarse, fine, split, enabled in zip(
 * 			('normal', 'parentannot', 'cf-split'),
 * 			(normal, parent, splitg),             # <<<<<<<<<<<<<<
 * 			(fine999, fine1, fine1),
 * 			(False, False, True),
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_normal));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_normal));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_normal));
  __Pyx_INCREF(((PyObject *)__pyx_v_parent));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_parent));
  __Pyx_INCREF(((PyObject *)__pyx_v_splitg));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_splitg));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_splitg));

  /* "discodop/coarsetofine.pyx":397
 * 			('normal', 'parentannot', 'cf-split'),
 * 			(normal, parent, splitg),
 * 			(fine999, fine1, fine1),             # <<<<<<<<<<<<<<
 * 			(False, False, True),
 * 			(True, False, True)):
 */
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_fine999));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_fine999));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_fine999));
  __Pyx_INCREF(((PyObject *)__pyx_v_fine1));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_fine1));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_fine1));
  __Pyx_INCREF(((PyObject *)__pyx_v_fine1));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_fine1));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_fine1));

  /* "discodop/coarsetofine.pyx":394
 * 	else:
 * 		print("DOP grammar is NOT a superset!")
 * 	for msg, coarse, fine, split, enabled in zip(             # <<<<<<<<<<<<<<
 * 			('normal', 'parentannot', 'cf-split'),
 * 			(normal, parent, splitg),
 */
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
  __Pyx_INCREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_tuple__22);
  __Pyx_INCREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_tuple__23);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_6 = __pyx_t_4; __Pyx_INCREF(__pyx_t_6); __pyx_t_5 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 394, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 394, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_6, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 394, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_6, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_8(__pyx_t_6);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 394, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 5)) {
        if (size > 5) __Pyx_RaiseTooManyValuesError(5);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 394, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 4); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 4); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3};
        for (i=0; i < 5; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 394, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_11,&__pyx_t_10,&__pyx_t_3};
      __pyx_t_14 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_14)->tp_iternext;
      for (index=0; index < 5; index++) {
        PyObject* item = __pyx_t_9(__pyx_t_14); if (unlikely(!item)) goto __pyx_L42_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_14), 5) < 0) __PYX_ERR(0, 394, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      goto __pyx_L43_unpacking_done;
      __pyx_L42_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 394, __pyx_L1_error)
      __pyx_L43_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_msg, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_coarse, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_fine, __pyx_t_11);
    __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_split, __pyx_t_10);
    __pyx_t_10 = 0;
    __Pyx_XDECREF_SET(__pyx_v_enabled, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":400
 * 			(False, False, True),
 * 			(True, False, True)):
 * 		if not enabled:             # <<<<<<<<<<<<<<
 * 			continue
 * 		print("coarse grammar:", msg)
 */
    __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_v_enabled); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 400, __pyx_L1_error)
    __pyx_t_17 = ((!__pyx_t_16) != 0);
    if (__pyx_t_17) {

      /* "discodop/coarsetofine.pyx":401
 * 			(True, False, True)):
 * 		if not enabled:
 * 			continue             # <<<<<<<<<<<<<<
 * 		print("coarse grammar:", msg)
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)
 */
      goto __pyx_L40_continue;

      /* "discodop/coarsetofine.pyx":400
 * 			(False, False, True),
 * 			(True, False, True)):
 * 		if not enabled:             # <<<<<<<<<<<<<<
 * 			continue
 * 		print("coarse grammar:", msg)
 */
    }

    /* "discodop/coarsetofine.pyx":402
 * 		if not enabled:
 * 			continue
 * 		print("coarse grammar:", msg)             # <<<<<<<<<<<<<<
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)
 * 		begin = clock()
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_kp_u_coarse_grammar);
    __Pyx_GIVEREF(__pyx_kp_u_coarse_grammar);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_coarse_grammar);
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_msg);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":403
 * 			continue
 * 		print("coarse grammar:", msg)
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)             # <<<<<<<<<<<<<<
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fine, __pyx_n_s_getmapping); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_re, __pyx_n_s_compile); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_coarse, __pyx_t_11, Py_None, __pyx_v_split, Py_True};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_v_coarse, __pyx_t_11, Py_None, __pyx_v_split, Py_True};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_v_coarse);
      __Pyx_GIVEREF(__pyx_v_coarse);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_coarse);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_t_11);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_7, Py_None);
      __Pyx_INCREF(__pyx_v_split);
      __Pyx_GIVEREF(__pyx_v_split);
      PyTuple_SET_ITEM(__pyx_t_2, 3+__pyx_t_7, __pyx_v_split);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_2, 4+__pyx_t_7, Py_True);
      __pyx_t_11 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":404
 * 		print("coarse grammar:", msg)
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)
 * 		begin = clock()             # <<<<<<<<<<<<<<
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 * 			if len(sent) > testmaxlen:
 */
    __Pyx_INCREF(__pyx_v_clock);
    __pyx_t_4 = __pyx_v_clock; __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_begin, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":405
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):             # <<<<<<<<<<<<<<
 * 			if len(sent) > testmaxlen:
 * 				continue
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_sents);
    __Pyx_GIVEREF(__pyx_v_sents);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_sents);
    __Pyx_INCREF(__pyx_v_trees);
    __Pyx_GIVEREF(__pyx_v_trees);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_trees);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 405, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 405, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) __PYX_ERR(0, 405, __pyx_L1_error)
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        }
      } else {
        __pyx_t_2 = __pyx_t_13(__pyx_t_4);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 405, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 405, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_11)) goto __pyx_L47_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_10 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_10)) goto __pyx_L47_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_1), 2) < 0) __PYX_ERR(0, 405, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L48_unpacking_done;
        __pyx_L47_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 405, __pyx_L1_error)
        __pyx_L48_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_tree, __pyx_t_10);
      __pyx_t_10 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_3);
      __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "discodop/coarsetofine.pyx":406
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 * 			if len(sent) > testmaxlen:             # <<<<<<<<<<<<<<
 * 				continue
 * 			print(n, end=' ')
 */
      __pyx_t_15 = PyObject_Length(__pyx_v_sent); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 406, __pyx_L1_error)
      __pyx_t_17 = ((__pyx_t_15 > __pyx_v_testmaxlen) != 0);
      if (__pyx_t_17) {

        /* "discodop/coarsetofine.pyx":407
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 * 			if len(sent) > testmaxlen:
 * 				continue             # <<<<<<<<<<<<<<
 * 			print(n, end=' ')
 * 			doctftest(coarse, fine, sent, tree, k, split, verbose=False)
 */
        goto __pyx_L45_continue;

        /* "discodop/coarsetofine.pyx":406
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 * 			if len(sent) > testmaxlen:             # <<<<<<<<<<<<<<
 * 				continue
 * 			print(n, end=' ')
 */
      }

      /* "discodop/coarsetofine.pyx":408
 * 			if len(sent) > testmaxlen:
 * 				continue
 * 			print(n, end=' ')             # <<<<<<<<<<<<<<
 * 			doctftest(coarse, fine, sent, tree, k, split, verbose=False)
 * 		print("time elapsed", clock() - begin, "s")
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_n);
      __Pyx_GIVEREF(__pyx_v_n);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n);
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_end, __pyx_kp_u__7) < 0) __PYX_ERR(0, 408, __pyx_L1_error)
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 408, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "discodop/coarsetofine.pyx":409
 * 				continue
 * 			print(n, end=' ')
 * 			doctftest(coarse, fine, sent, tree, k, split, verbose=False)             # <<<<<<<<<<<<<<
 * 		print("time elapsed", clock() - begin, "s")
 * 
 */
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_doctftest); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_v_k); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_coarse);
      __Pyx_GIVEREF(__pyx_v_coarse);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_coarse);
      __Pyx_INCREF(__pyx_v_fine);
      __Pyx_GIVEREF(__pyx_v_fine);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_fine);
      __Pyx_INCREF(__pyx_v_sent);
      __Pyx_GIVEREF(__pyx_v_sent);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_sent);
      __Pyx_INCREF(__pyx_v_tree);
      __Pyx_GIVEREF(__pyx_v_tree);
      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_tree);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_10);
      __Pyx_INCREF(__pyx_v_split);
      __Pyx_GIVEREF(__pyx_v_split);
      PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_v_split);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_verbose, Py_False) < 0) __PYX_ERR(0, 409, __pyx_L1_error)
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "discodop/coarsetofine.pyx":405
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):             # <<<<<<<<<<<<<<
 * 			if len(sent) > testmaxlen:
 * 				continue
 */
      __pyx_L45_continue:;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "discodop/coarsetofine.pyx":410
 * 			print(n, end=' ')
 * 			doctftest(coarse, fine, sent, tree, k, split, verbose=False)
 * 		print("time elapsed", clock() - begin, "s")             # <<<<<<<<<<<<<<
 * 
 * __all__ = ['prunechart', 'bitparkbestitems', 'posteriorthreshold',
 */
    __Pyx_INCREF(__pyx_v_clock);
    __pyx_t_4 = __pyx_v_clock; __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_3, __pyx_v_begin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_kp_u_time_elapsed);
    __Pyx_GIVEREF(__pyx_kp_u_time_elapsed);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_time_elapsed);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __Pyx_INCREF(__pyx_n_u_s);
    __Pyx_GIVEREF(__pyx_n_u_s);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_n_u_s);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "discodop/coarsetofine.pyx":394
 * 	else:
 * 		print("DOP grammar is NOT a superset!")
 * 	for msg, coarse, fine, split, enabled in zip(             # <<<<<<<<<<<<<<
 * 			('normal', 'parentannot', 'cf-split'),
 * 			(normal, parent, splitg),
 */
    __pyx_L40_continue:;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "discodop/coarsetofine.pyx":339
 * 
 * 
 * def test():             # <<<<<<<<<<<<<<
 * 	import re
 * 	from time import clock
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("discodop.coarsetofine.test", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_re);
  __Pyx_XDECREF(__pyx_v_clock);
  __Pyx_XDECREF(__pyx_v_splitdiscnodes);
  __Pyx_XDECREF(__pyx_v_binarize);
  __Pyx_XDECREF(__pyx_v_addfanoutmarkers);
  __Pyx_XDECREF(__pyx_v_NegraCorpusReader);
  __Pyx_XDECREF(__pyx_v_treebankgrammar);
  __Pyx_XDECREF(__pyx_v_dopreduction);
  __Pyx_XDECREF(__pyx_v_subsetgrammar);
  __Pyx_XDECREF(__pyx_v_corpus);
  __Pyx_XDECREF(__pyx_v_train);
  __Pyx_XDECREF(__pyx_v_test);
  __Pyx_XDECREF(__pyx_v_trees);
  __Pyx_XDECREF(__pyx_v_sents);
  __Pyx_XDECREF(__pyx_v_dtrees);
  __Pyx_XDECREF(__pyx_v_parenttrees);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_cftrees);
  __Pyx_XDECREF(__pyx_v_normallcfrs);
  __Pyx_XDECREF((PyObject *)__pyx_v_normal);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent);
  __Pyx_XDECREF((PyObject *)__pyx_v_splitg);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_yf);
  __Pyx_XDECREF(__pyx_v_fine999x);
  __Pyx_XDECREF((PyObject *)__pyx_v_fine999);
  __Pyx_XDECREF((PyObject *)__pyx_v_fine1);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_coarse);
  __Pyx_XDECREF(__pyx_v_fine);
  __Pyx_XDECREF(__pyx_v_split);
  __Pyx_XDECREF(__pyx_v_enabled);
  __Pyx_XDECREF(__pyx_v_begin);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_tree);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":91
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7cpython_5array_5array___getbuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags) {
  PyObject *__pyx_v_item_count = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }

  /* "cpython/array.pxd":96
 *             # In particular strided access is always provided regardless
 *             # of flags
 *             item_count = Py_SIZE(self)             # <<<<<<<<<<<<<<
 * 
 *             info.suboffsets = NULL
 */
  __pyx_t_1 = PyInt_FromSsize_t(Py_SIZE(((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 96, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_item_count = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cpython/array.pxd":98
 *             item_count = Py_SIZE(self)
 * 
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.buf = self.data.as_chars
 *             info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "cpython/array.pxd":99
 * 
 *             info.suboffsets = NULL
 *             info.buf = self.data.as_chars             # <<<<<<<<<<<<<<
 *             info.readonly = 0
 *             info.ndim = 1
 */
  __pyx_t_2 = __pyx_v_self->data.as_chars;
  __pyx_v_info->buf = __pyx_t_2;

  /* "cpython/array.pxd":100
 *             info.suboffsets = NULL
 *             info.buf = self.data.as_chars
 *             info.readonly = 0             # <<<<<<<<<<<<<<
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 */
  __pyx_v_info->readonly = 0;

  /* "cpython/array.pxd":101
 *             info.buf = self.data.as_chars
 *             info.readonly = 0
 *             info.ndim = 1             # <<<<<<<<<<<<<<
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 *             info.len = info.itemsize * item_count
 */
  __pyx_v_info->ndim = 1;

  /* "cpython/array.pxd":102
 *             info.readonly = 0
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)             # <<<<<<<<<<<<<<
 *             info.len = info.itemsize * item_count
 * 
 */
  __pyx_t_3 = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_info->itemsize = __pyx_t_3;

  /* "cpython/array.pxd":103
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 *             info.len = info.itemsize * item_count             # <<<<<<<<<<<<<<
 * 
 *             info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_info->itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_v_item_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 103, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 103, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_info->len = __pyx_t_5;

  /* "cpython/array.pxd":105
 *             info.len = info.itemsize * item_count
 * 
 *             info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)             # <<<<<<<<<<<<<<
 *             if not info.shape:
 *                 raise MemoryError()
 */
  __pyx_v_info->shape = ((Py_ssize_t *)PyObject_Malloc(((sizeof(Py_ssize_t)) + 2)));

  /* "cpython/array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:             # <<<<<<<<<<<<<<
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 */
  __pyx_t_6 = ((!(__pyx_v_info->shape != 0)) != 0);
  if (__pyx_t_6) {

    /* "cpython/array.pxd":107
 *             info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:
 *                 raise MemoryError()             # <<<<<<<<<<<<<<
 *             info.shape[0] = item_count      # constant regardless of resizing
 *             info.strides = &info.itemsize
 */
    PyErr_NoMemory(); __PYX_ERR(1, 107, __pyx_L1_error)

    /* "cpython/array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:             # <<<<<<<<<<<<<<
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 */
  }

  /* "cpython/array.pxd":108
 *             if not info.shape:
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing             # <<<<<<<<<<<<<<
 *             info.strides = &info.itemsize
 * 
 */
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item_count); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 108, __pyx_L1_error)
  (__pyx_v_info->shape[0]) = __pyx_t_5;

  /* "cpython/array.pxd":109
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 *             info.strides = &info.itemsize             # <<<<<<<<<<<<<<
 * 
 *             info.format = <char*> (info.shape + 1)
 */
  __pyx_v_info->strides = (&__pyx_v_info->itemsize);

  /* "cpython/array.pxd":111
 *             info.strides = &info.itemsize
 * 
 *             info.format = <char*> (info.shape + 1)             # <<<<<<<<<<<<<<
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 */
  __pyx_v_info->format = ((char *)(__pyx_v_info->shape + 1));

  /* "cpython/array.pxd":112
 * 
 *             info.format = <char*> (info.shape + 1)
 *             info.format[0] = self.ob_descr.typecode             # <<<<<<<<<<<<<<
 *             info.format[1] = 0
 *             info.obj = self
 */
  __pyx_t_3 = __pyx_v_self->ob_descr->typecode;
  (__pyx_v_info->format[0]) = __pyx_t_3;

  /* "cpython/array.pxd":113
 *             info.format = <char*> (info.shape + 1)
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0             # <<<<<<<<<<<<<<
 *             info.obj = self
 * 
 */
  (__pyx_v_info->format[1]) = 0;

  /* "cpython/array.pxd":114
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 *             info.obj = self             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(self, Py_buffer* info):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "cpython/array.pxd":91
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpython.array.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_item_count);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":116
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyObject_Free(info.shape)
 * 
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_7cpython_5array_5array_2__releasebuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "cpython/array.pxd":117
 * 
 *         def __releasebuffer__(self, Py_buffer* info):
 *             PyObject_Free(info.shape)             # <<<<<<<<<<<<<<
 * 
 *     array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr)
 */
  PyObject_Free(__pyx_v_info->shape);

  /* "cpython/array.pxd":116
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyObject_Free(info.shape)
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "cpython/array.pxd":128
 * 
 * 
 * cdef inline array clone(array template, Py_ssize_t length, bint zero):             # <<<<<<<<<<<<<<
 *     """ fast creation of a new array, given a template array.
 *     type will be same as template.
 */

static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *__pyx_v_template, Py_ssize_t __pyx_v_length, int __pyx_v_zero) {
  arrayobject *__pyx_v_op = NULL;
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("clone", 0);

  /* "cpython/array.pxd":132
 *     type will be same as template.
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)             # <<<<<<<<<<<<<<
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_template)), __pyx_v_length, __pyx_v_template->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpython/array.pxd":133
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:             # <<<<<<<<<<<<<<
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op
 */
  __pyx_t_3 = (__pyx_v_zero != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (((PyObject *)__pyx_v_op) != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cpython/array.pxd":134
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *     return op
 * 
 */
    memset(__pyx_v_op->data.as_chars, 0, (__pyx_v_length * __pyx_v_op->ob_descr->itemsize));

    /* "cpython/array.pxd":133
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:             # <<<<<<<<<<<<<<
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op
 */
  }

  /* "cpython/array.pxd":135
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op             # <<<<<<<<<<<<<<
 * 
 * cdef inline array copy(array self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_op));
  __pyx_r = __pyx_v_op;
  goto __pyx_L0;

  /* "cpython/array.pxd":128
 * 
 * 
 * cdef inline array clone(array template, Py_ssize_t length, bint zero):             # <<<<<<<<<<<<<<
 *     """ fast creation of a new array, given a template array.
 *     type will be same as template.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.array.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":137
 *     return op
 * 
 * cdef inline array copy(array self):             # <<<<<<<<<<<<<<
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 */

static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobject *__pyx_v_self) {
  arrayobject *__pyx_v_op = NULL;
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "cpython/array.pxd":139
 * cdef inline array copy(array self):
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)             # <<<<<<<<<<<<<<
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
 *     return op
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_self)), Py_SIZE(((PyObject *)__pyx_v_self)), __pyx_v_self->ob_descr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cpython/array.pxd":140
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *     return op
 * 
 */
  memcpy(__pyx_v_op->data.as_chars, __pyx_v_self->data.as_chars, (Py_SIZE(((PyObject *)__pyx_v_op)) * __pyx_v_op->ob_descr->itemsize));

  /* "cpython/array.pxd":141
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
 *     return op             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_op));
  __pyx_r = __pyx_v_op;
  goto __pyx_L0;

  /* "cpython/array.pxd":137
 *     return op
 * 
 * cdef inline array copy(array self):             # <<<<<<<<<<<<<<
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.array.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":143
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficent appending of new stuff of same type
 *     (e.g. of same array type)
 */

static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *__pyx_v_self, char *__pyx_v_stuff, Py_ssize_t __pyx_v_n) {
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_origsize;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("extend_buffer", 0);

  /* "cpython/array.pxd":147
 *     (e.g. of same array type)
 *     n: number of elements (not number of bytes!) """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)
 */
  __pyx_t_1 = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "cpython/array.pxd":148
 *     n: number of elements (not number of bytes!) """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize
 *     cdef Py_ssize_t origsize = Py_SIZE(self)             # <<<<<<<<<<<<<<
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 */
  __pyx_v_origsize = Py_SIZE(((PyObject *)__pyx_v_self));

  /* "cpython/array.pxd":149
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)             # <<<<<<<<<<<<<<
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 *     return 0
 */
  __pyx_t_1 = resize_smart(__pyx_v_self, (__pyx_v_origsize + __pyx_v_n)); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 149, __pyx_L1_error)

  /* "cpython/array.pxd":150
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  memcpy((__pyx_v_self->data.as_chars + (__pyx_v_origsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize));

  /* "cpython/array.pxd":151
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend(array self, array other) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "cpython/array.pxd":143
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficent appending of new stuff of same type
 *     (e.g. of same array type)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpython.array.extend_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":153
 *     return 0
 * 
 * cdef inline int extend(array self, array other) except -1:             # <<<<<<<<<<<<<<
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 */

static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "cpython/array.pxd":155
 * cdef inline int extend(array self, array other) except -1:
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:             # <<<<<<<<<<<<<<
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 */
  __pyx_t_1 = ((__pyx_v_self->ob_descr->typecode != __pyx_v_other->ob_descr->typecode) != 0);
  if (__pyx_t_1) {

    /* "cpython/array.pxd":156
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 *         PyErr_BadArgument()             # <<<<<<<<<<<<<<
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 */
    __pyx_t_2 = PyErr_BadArgument(); if (unlikely(__pyx_t_2 == 0)) __PYX_ERR(1, 156, __pyx_L1_error)

    /* "cpython/array.pxd":155
 * cdef inline int extend(array self, array other) except -1:
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:             # <<<<<<<<<<<<<<
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 */
  }

  /* "cpython/array.pxd":157
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))             # <<<<<<<<<<<<<<
 * 
 * cdef inline void zero(array self):
 */
  __pyx_t_2 = __pyx_f_7cpython_5array_extend_buffer(__pyx_v_self, __pyx_v_other->data.as_chars, Py_SIZE(((PyObject *)__pyx_v_other))); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(1, 157, __pyx_L1_error)
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "cpython/array.pxd":153
 *     return 0
 * 
 * cdef inline int extend(array self, array other) except -1:             # <<<<<<<<<<<<<<
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpython.array.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cpython/array.pxd":159
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 * cdef inline void zero(array self):             # <<<<<<<<<<<<<<
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
 */

static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("zero", 0);

  /* "cpython/array.pxd":161
 * cdef inline void zero(array self):
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 */
  memset(__pyx_v_self->data.as_chars, 0, (Py_SIZE(((PyObject *)__pyx_v_self)) * __pyx_v_self->ob_descr->itemsize));

  /* "cpython/array.pxd":159
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 * cdef inline void zero(array self):             # <<<<<<<<<<<<<<
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "containers.pxd":292
 * 
 * 
 * cdef inline FatChartItem new_FatChartItem(uint32_t label):             # <<<<<<<<<<<<<<
 * 	cdef FatChartItem item = FatChartItem.__new__(FatChartItem)
 * 	item.label = label
 */

static CYTHON_INLINE struct __pyx_obj_8discodop_10containers_FatChartItem *__pyx_f_8discodop_10containers_new_FatChartItem(uint32_t __pyx_v_label) {
  struct __pyx_obj_8discodop_10containers_FatChartItem *__pyx_v_item = 0;
  struct __pyx_obj_8discodop_10containers_FatChartItem *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_FatChartItem", 0);

  /* "containers.pxd":293
 * 
 * cdef inline FatChartItem new_FatChartItem(uint32_t label):
 * 	cdef FatChartItem item = FatChartItem.__new__(FatChartItem)             # <<<<<<<<<<<<<<
 * 	item.label = label
 * 	# NB: since item.vec is a static array, its elements are initialized to 0.
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8discodop_10containers_FatChartItem), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8discodop_10containers_FatChartItem)))) __PYX_ERR(2, 293, __pyx_L1_error)
  __pyx_v_item = ((struct __pyx_obj_8discodop_10containers_FatChartItem *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "containers.pxd":294
 * cdef inline FatChartItem new_FatChartItem(uint32_t label):
 * 	cdef FatChartItem item = FatChartItem.__new__(FatChartItem)
 * 	item.label = label             # <<<<<<<<<<<<<<
 * 	# NB: since item.vec is a static array, its elements are initialized to 0.
 * 	return item
 */
  __pyx_v_item->__pyx_base.label = __pyx_v_label;

  /* "containers.pxd":296
 * 	item.label = label
 * 	# NB: since item.vec is a static array, its elements are initialized to 0.
 * 	return item             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_item));
  __pyx_r = __pyx_v_item;
  goto __pyx_L0;

  /* "containers.pxd":292
 * 
 * 
 * cdef inline FatChartItem new_FatChartItem(uint32_t label):             # <<<<<<<<<<<<<<
 * 	cdef FatChartItem item = FatChartItem.__new__(FatChartItem)
 * 	item.label = label
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("discodop.containers.new_FatChartItem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_item);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":299
 * 
 * 
 * cdef inline SmallChartItem new_SmallChartItem(uint32_t label, uint64_t vec):             # <<<<<<<<<<<<<<
 * 	cdef SmallChartItem item = SmallChartItem.__new__(SmallChartItem)
 * 	item.label = label
 */

static CYTHON_INLINE struct __pyx_obj_8discodop_10containers_SmallChartItem *__pyx_f_8discodop_10containers_new_SmallChartItem(uint32_t __pyx_v_label, uint64_t __pyx_v_vec) {
  struct __pyx_obj_8discodop_10containers_SmallChartItem *__pyx_v_item = 0;
  struct __pyx_obj_8discodop_10containers_SmallChartItem *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_SmallChartItem", 0);

  /* "containers.pxd":300
 * 
 * cdef inline SmallChartItem new_SmallChartItem(uint32_t label, uint64_t vec):
 * 	cdef SmallChartItem item = SmallChartItem.__new__(SmallChartItem)             # <<<<<<<<<<<<<<
 * 	item.label = label
 * 	item.vec = vec
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8discodop_10containers_SmallChartItem), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8discodop_10containers_SmallChartItem)))) __PYX_ERR(2, 300, __pyx_L1_error)
  __pyx_v_item = ((struct __pyx_obj_8discodop_10containers_SmallChartItem *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "containers.pxd":301
 * cdef inline SmallChartItem new_SmallChartItem(uint32_t label, uint64_t vec):
 * 	cdef SmallChartItem item = SmallChartItem.__new__(SmallChartItem)
 * 	item.label = label             # <<<<<<<<<<<<<<
 * 	item.vec = vec
 * 	return item
 */
  __pyx_v_item->__pyx_base.label = __pyx_v_label;

  /* "containers.pxd":302
 * 	cdef SmallChartItem item = SmallChartItem.__new__(SmallChartItem)
 * 	item.label = label
 * 	item.vec = vec             # <<<<<<<<<<<<<<
 * 	return item
 * 
 */
  __pyx_v_item->vec = __pyx_v_vec;

  /* "containers.pxd":303
 * 	item.label = label
 * 	item.vec = vec
 * 	return item             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_item));
  __pyx_r = __pyx_v_item;
  goto __pyx_L0;

  /* "containers.pxd":299
 * 
 * 
 * cdef inline SmallChartItem new_SmallChartItem(uint32_t label, uint64_t vec):             # <<<<<<<<<<<<<<
 * 	cdef SmallChartItem item = SmallChartItem.__new__(SmallChartItem)
 * 	item.label = label
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("discodop.containers.new_SmallChartItem", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_item);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":306
 * 
 * 
 * cdef inline RankedEdge new_RankedEdge(             # <<<<<<<<<<<<<<
 * 		object head, Edge *edge, int left, int right):
 * 	cdef RankedEdge rankededge = RankedEdge.__new__(RankedEdge)
 */

static CYTHON_INLINE struct __pyx_obj_8discodop_10containers_RankedEdge *__pyx_f_8discodop_10containers_new_RankedEdge(PyObject *__pyx_v_head, struct __pyx_t_8discodop_10containers_Edge *__pyx_v_edge, int __pyx_v_left, int __pyx_v_right) {
  struct __pyx_obj_8discodop_10containers_RankedEdge *__pyx_v_rankededge = 0;
  struct __pyx_obj_8discodop_10containers_RankedEdge *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("new_RankedEdge", 0);

  /* "containers.pxd":308
 * cdef inline RankedEdge new_RankedEdge(
 * 		object head, Edge *edge, int left, int right):
 * 	cdef RankedEdge rankededge = RankedEdge.__new__(RankedEdge)             # <<<<<<<<<<<<<<
 * 	rankededge.head = head
 * 	rankededge.edge = edge
 */
  __pyx_t_1 = __Pyx_tp_new(((PyObject *)__pyx_ptype_8discodop_10containers_RankedEdge), __pyx_empty_tuple); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_8discodop_10containers_RankedEdge)))) __PYX_ERR(2, 308, __pyx_L1_error)
  __pyx_v_rankededge = ((struct __pyx_obj_8discodop_10containers_RankedEdge *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "containers.pxd":309
 * 		object head, Edge *edge, int left, int right):
 * 	cdef RankedEdge rankededge = RankedEdge.__new__(RankedEdge)
 * 	rankededge.head = head             # <<<<<<<<<<<<<<
 * 	rankededge.edge = edge
 * 	rankededge.left = left
 */
  __Pyx_INCREF(__pyx_v_head);
  __Pyx_GIVEREF(__pyx_v_head);
  __Pyx_GOTREF(__pyx_v_rankededge->head);
  __Pyx_DECREF(__pyx_v_rankededge->head);
  __pyx_v_rankededge->head = __pyx_v_head;

  /* "containers.pxd":310
 * 	cdef RankedEdge rankededge = RankedEdge.__new__(RankedEdge)
 * 	rankededge.head = head
 * 	rankededge.edge = edge             # <<<<<<<<<<<<<<
 * 	rankededge.left = left
 * 	rankededge.right = right
 */
  __pyx_v_rankededge->edge = __pyx_v_edge;

  /* "containers.pxd":311
 * 	rankededge.head = head
 * 	rankededge.edge = edge
 * 	rankededge.left = left             # <<<<<<<<<<<<<<
 * 	rankededge.right = right
 * 	return rankededge
 */
  __pyx_v_rankededge->left = __pyx_v_left;

  /* "containers.pxd":312
 * 	rankededge.edge = edge
 * 	rankededge.left = left
 * 	rankededge.right = right             # <<<<<<<<<<<<<<
 * 	return rankededge
 * 
 */
  __pyx_v_rankededge->right = __pyx_v_right;

  /* "containers.pxd":313
 * 	rankededge.left = left
 * 	rankededge.right = right
 * 	return rankededge             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_rankededge));
  __pyx_r = __pyx_v_rankededge;
  goto __pyx_L0;

  /* "containers.pxd":306
 * 
 * 
 * cdef inline RankedEdge new_RankedEdge(             # <<<<<<<<<<<<<<
 * 		object head, Edge *edge, int left, int right):
 * 	cdef RankedEdge rankededge = RankedEdge.__new__(RankedEdge)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("discodop.containers.new_RankedEdge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rankededge);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":317
 * 
 * # defined here because circular import.
 * cdef inline size_t cellidx(short start, short end, short lensent,             # <<<<<<<<<<<<<<
 * 		uint32_t nonterminals):
 * 	"""Return an index for a regular three dimensional array.
 */

static CYTHON_INLINE size_t __pyx_f_8discodop_10containers_cellidx(short __pyx_v_start, short __pyx_v_end, short __pyx_v_lensent, uint32_t __pyx_v_nonterminals) {
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cellidx", 0);

  /* "containers.pxd":322
 * 
 * 	``chart[start][end][0] => chart[idx]`` """
 * 	return (start * lensent + (end - 1)) * nonterminals             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (((__pyx_v_start * __pyx_v_lensent) + (__pyx_v_end - 1)) * __pyx_v_nonterminals);
  goto __pyx_L0;

  /* "containers.pxd":317
 * 
 * # defined here because circular import.
 * cdef inline size_t cellidx(short start, short end, short lensent,             # <<<<<<<<<<<<<<
 * 		uint32_t nonterminals):
 * 	"""Return an index for a regular three dimensional array.
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":325
 * 
 * 
 * cdef inline size_t compactcellidx(short start, short end, short lensent,             # <<<<<<<<<<<<<<
 * 		uint32_t nonterminals):
 * 	"""Return an index to a triangular array, given start < end.
 */

static CYTHON_INLINE size_t __pyx_f_8discodop_10containers_compactcellidx(short __pyx_v_start, short __pyx_v_end, short __pyx_v_lensent, uint32_t __pyx_v_nonterminals) {
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("compactcellidx", 0);

  /* "containers.pxd":329
 * 	"""Return an index to a triangular array, given start < end.
 * 	The result of this function is the index to chart[start][end][0]."""
 * 	return nonterminals * (lensent * start             # <<<<<<<<<<<<<<
 * 			- ((start - 1) * start / 2) + end - start - 1)
 * 
 */
  __pyx_r = (__pyx_v_nonterminals * (((((__pyx_v_lensent * __pyx_v_start) - (((__pyx_v_start - 1) * __pyx_v_start) / 2)) + __pyx_v_end) - __pyx_v_start) - 1));
  goto __pyx_L0;

  /* "containers.pxd":325
 * 
 * 
 * cdef inline size_t compactcellidx(short start, short end, short lensent,             # <<<<<<<<<<<<<<
 * 		uint32_t nonterminals):
 * 	"""Return an index to a triangular array, given start < end.
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":336
 * 
 * 
 * cdef inline logprobadd(x, y):             # <<<<<<<<<<<<<<
 * 	""" Add two log probabilities in log space.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_8discodop_10containers_logprobadd(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_v_diff = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("logprobadd", 0);

  /* "containers.pxd":346
 * 	:source: https://facwiki.cs.byu.edu/nlp/index.php/Log_Domain_Computations
 * 	"""
 * 	if isinf(x):             # <<<<<<<<<<<<<<
 * 		return y
 * 	elif isinf(y):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_isinf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 346, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_x};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_x};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 346, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_x);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 346, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "containers.pxd":347
 * 	"""
 * 	if isinf(x):
 * 		return y             # <<<<<<<<<<<<<<
 * 	elif isinf(y):
 * 		return x
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_y);
    __pyx_r = __pyx_v_y;
    goto __pyx_L0;

    /* "containers.pxd":346
 * 	:source: https://facwiki.cs.byu.edu/nlp/index.php/Log_Domain_Computations
 * 	"""
 * 	if isinf(x):             # <<<<<<<<<<<<<<
 * 		return y
 * 	elif isinf(y):
 */
  }

  /* "containers.pxd":348
 * 	if isinf(x):
 * 		return y
 * 	elif isinf(y):             # <<<<<<<<<<<<<<
 * 		return x
 * 	# If one value is much smaller than the other, keep the larger value.
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_isinf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 348, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_y};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 348, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 348, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_y);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 348, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 348, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "containers.pxd":349
 * 		return y
 * 	elif isinf(y):
 * 		return x             # <<<<<<<<<<<<<<
 * 	# If one value is much smaller than the other, keep the larger value.
 * 	elif x < (y - 460):  # log(1e200)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_x);
    __pyx_r = __pyx_v_x;
    goto __pyx_L0;

    /* "containers.pxd":348
 * 	if isinf(x):
 * 		return y
 * 	elif isinf(y):             # <<<<<<<<<<<<<<
 * 		return x
 * 	# If one value is much smaller than the other, keep the larger value.
 */
  }

  /* "containers.pxd":351
 * 		return x
 * 	# If one value is much smaller than the other, keep the larger value.
 * 	elif x < (y - 460):  # log(1e200)             # <<<<<<<<<<<<<<
 * 		return y
 * 	elif y < (x - 460):  # log(1e200)
 */
  __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_v_y, __pyx_int_460, 0x1CC, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_x, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 351, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 351, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_5) {

    /* "containers.pxd":352
 * 	# If one value is much smaller than the other, keep the larger value.
 * 	elif x < (y - 460):  # log(1e200)
 * 		return y             # <<<<<<<<<<<<<<
 * 	elif y < (x - 460):  # log(1e200)
 * 		return x
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_y);
    __pyx_r = __pyx_v_y;
    goto __pyx_L0;

    /* "containers.pxd":351
 * 		return x
 * 	# If one value is much smaller than the other, keep the larger value.
 * 	elif x < (y - 460):  # log(1e200)             # <<<<<<<<<<<<<<
 * 		return y
 * 	elif y < (x - 460):  # log(1e200)
 */
  }

  /* "containers.pxd":353
 * 	elif x < (y - 460):  # log(1e200)
 * 		return y
 * 	elif y < (x - 460):  # log(1e200)             # <<<<<<<<<<<<<<
 * 		return x
 * 	diff = y - x
 */
  __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_460, 0x1CC, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_y, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 353, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 353, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "containers.pxd":354
 * 		return y
 * 	elif y < (x - 460):  # log(1e200)
 * 		return x             # <<<<<<<<<<<<<<
 * 	diff = y - x
 * 	assert not isinf(diff)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_x);
    __pyx_r = __pyx_v_x;
    goto __pyx_L0;

    /* "containers.pxd":353
 * 	elif x < (y - 460):  # log(1e200)
 * 		return y
 * 	elif y < (x - 460):  # log(1e200)             # <<<<<<<<<<<<<<
 * 		return x
 * 	diff = y - x
 */
  }

  /* "containers.pxd":355
 * 	elif y < (x - 460):  # log(1e200)
 * 		return x
 * 	diff = y - x             # <<<<<<<<<<<<<<
 * 	assert not isinf(diff)
 * 	if isinf(exp(diff)):  # difference is too large
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_y, __pyx_v_x); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_diff = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "containers.pxd":356
 * 		return x
 * 	diff = y - x
 * 	assert not isinf(diff)             # <<<<<<<<<<<<<<
 * 	if isinf(exp(diff)):  # difference is too large
 * 		return x if x > y else y
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_isinf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_diff); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 356, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_diff};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 356, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_diff};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 356, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 356, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_INCREF(__pyx_v_diff);
        __Pyx_GIVEREF(__pyx_v_diff);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_diff);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 356, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 356, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!((!__pyx_t_5) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(2, 356, __pyx_L1_error)
    }
  }
  #endif

  /* "containers.pxd":357
 * 	diff = y - x
 * 	assert not isinf(diff)
 * 	if isinf(exp(diff)):  # difference is too large             # <<<<<<<<<<<<<<
 * 		return x if x > y else y
 * 	# otherwise return the sum.
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_isinf); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_diff); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_diff};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_diff};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_diff);
      __Pyx_GIVEREF(__pyx_v_diff);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_diff);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 357, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 357, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "containers.pxd":358
 * 	assert not isinf(diff)
 * 	if isinf(exp(diff)):  # difference is too large
 * 		return x if x > y else y             # <<<<<<<<<<<<<<
 * 	# otherwise return the sum.
 * 	return x + log(1.0 + exp(diff))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_x, __pyx_v_y, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 358, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(2, 358, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_5) {
      __Pyx_INCREF(__pyx_v_x);
      __pyx_t_1 = __pyx_v_x;
    } else {
      __Pyx_INCREF(__pyx_v_y);
      __pyx_t_1 = __pyx_v_y;
    }
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "containers.pxd":357
 * 	diff = y - x
 * 	assert not isinf(diff)
 * 	if isinf(exp(diff)):  # difference is too large             # <<<<<<<<<<<<<<
 * 		return x if x > y else y
 * 	# otherwise return the sum.
 */
  }

  /* "containers.pxd":360
 * 		return x if x > y else y
 * 	# otherwise return the sum.
 * 	return x + log(1.0 + exp(diff))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_exp); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_diff); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_diff};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_diff};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_diff);
      __Pyx_GIVEREF(__pyx_v_diff);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_diff);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyFloat_AddCObj(__pyx_float_1_0, __pyx_t_7, 1.0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_v_x, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "containers.pxd":336
 * 
 * 
 * cdef inline logprobadd(x, y):             # <<<<<<<<<<<<<<
 * 	""" Add two log probabilities in log space.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("discodop.containers.logprobadd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_diff);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":363
 * 
 * 
 * cdef inline double logprobsum(list logprobs):             # <<<<<<<<<<<<<<
 * 	"""Sum a list of log probabilities producing a normal probability.
 * 
 */

static CYTHON_INLINE double __pyx_f_8discodop_10containers_logprobsum(PyObject *__pyx_v_logprobs) {
  PyObject *__pyx_v_maxprob = NULL;
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  double __pyx_t_12;
  __Pyx_RefNannySetupContext("logprobsum", 0);

  /* "containers.pxd":377
 * 	Comparison of different methods: https://gist.github.com/andreasvc/6204982
 * 	"""
 * 	maxprob = max(logprobs)             # <<<<<<<<<<<<<<
 * 	return exp(maxprob) * fsum([exp(prob - maxprob) for prob in logprobs])
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_logprobs);
  __Pyx_GIVEREF(__pyx_v_logprobs);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_logprobs);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_maxprob = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "containers.pxd":378
 * 	"""
 * 	maxprob = max(logprobs)
 * 	return exp(maxprob) * fsum([exp(prob - maxprob) for prob in logprobs])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_exp); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_maxprob); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 378, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_maxprob};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_maxprob};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_maxprob);
      __Pyx_GIVEREF(__pyx_v_maxprob);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_maxprob);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_fsum); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  { /* enter inner scope */
    PyObject *__pyx_7genexpr__pyx_v_prob = NULL;
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 378, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_logprobs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(2, 378, __pyx_L5_error)
    }
    __pyx_t_5 = __pyx_v_logprobs; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
    for (;;) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_7 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(2, 378, __pyx_L5_error)
      #else
      __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_prob, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_exp); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 378, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyNumber_Subtract(__pyx_7genexpr__pyx_v_prob, __pyx_v_maxprob); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 378, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
          __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L5_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
          __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L5_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 378, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
          __pyx_t_9 = 0;
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(2, 378, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_prob);
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_prob);
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 378, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 378, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(2, 378, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_12;
  goto __pyx_L0;

  /* "containers.pxd":363
 * 
 * 
 * cdef inline double logprobsum(list logprobs):             # <<<<<<<<<<<<<<
 * 	"""Sum a list of log probabilities producing a normal probability.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_WriteUnraisable("discodop.containers.logprobsum", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_maxprob);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":381
 * 
 * 
 * cdef inline str yieldranges(list leaves):             # <<<<<<<<<<<<<<
 * 	"""Convert a sorted list of indices into a string with intervals.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_8discodop_10containers_yieldranges(PyObject *__pyx_v_leaves) {
  PyObject *__pyx_v_yields = 0;
  int __pyx_v_a;
  int __pyx_v_start;
  int __pyx_v_prev;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("yieldranges", 0);

  /* "containers.pxd":389
 * 	>>> yieldranges([0, 1, 2, 3, 4])
 * 	'0:1= 2:4='"""
 * 	cdef list yields = []             # <<<<<<<<<<<<<<
 * 	cdef int a, start = -2, prev = -2
 * 	for a in leaves:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_yields = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "containers.pxd":390
 * 	'0:1= 2:4='"""
 * 	cdef list yields = []
 * 	cdef int a, start = -2, prev = -2             # <<<<<<<<<<<<<<
 * 	for a in leaves:
 * 		if a - 1 != prev:
 */
  __pyx_v_start = -2;
  __pyx_v_prev = -2;

  /* "containers.pxd":391
 * 	cdef list yields = []
 * 	cdef int a, start = -2, prev = -2
 * 	for a in leaves:             # <<<<<<<<<<<<<<
 * 		if a - 1 != prev:
 * 			if prev != -2:
 */
  if (unlikely(__pyx_v_leaves == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 391, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_leaves; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 391, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 391, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_a = __pyx_t_4;

    /* "containers.pxd":392
 * 	cdef int a, start = -2, prev = -2
 * 	for a in leaves:
 * 		if a - 1 != prev:             # <<<<<<<<<<<<<<
 * 			if prev != -2:
 * 				yields.append('%d:%d' % (start, prev))
 */
    __pyx_t_5 = (((__pyx_v_a - 1) != __pyx_v_prev) != 0);
    if (__pyx_t_5) {

      /* "containers.pxd":393
 * 	for a in leaves:
 * 		if a - 1 != prev:
 * 			if prev != -2:             # <<<<<<<<<<<<<<
 * 				yields.append('%d:%d' % (start, prev))
 * 			start = a
 */
      __pyx_t_5 = ((__pyx_v_prev != -2L) != 0);
      if (__pyx_t_5) {

        /* "containers.pxd":394
 * 		if a - 1 != prev:
 * 			if prev != -2:
 * 				yields.append('%d:%d' % (start, prev))             # <<<<<<<<<<<<<<
 * 			start = a
 * 		prev = a
 */
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_prev); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
        __pyx_t_3 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_d_d, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_yields, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 394, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "containers.pxd":393
 * 	for a in leaves:
 * 		if a - 1 != prev:
 * 			if prev != -2:             # <<<<<<<<<<<<<<
 * 				yields.append('%d:%d' % (start, prev))
 * 			start = a
 */
      }

      /* "containers.pxd":395
 * 			if prev != -2:
 * 				yields.append('%d:%d' % (start, prev))
 * 			start = a             # <<<<<<<<<<<<<<
 * 		prev = a
 * 	yields.append('%d:%d' % (start, prev))
 */
      __pyx_v_start = __pyx_v_a;

      /* "containers.pxd":392
 * 	cdef int a, start = -2, prev = -2
 * 	for a in leaves:
 * 		if a - 1 != prev:             # <<<<<<<<<<<<<<
 * 			if prev != -2:
 * 				yields.append('%d:%d' % (start, prev))
 */
    }

    /* "containers.pxd":396
 * 				yields.append('%d:%d' % (start, prev))
 * 			start = a
 * 		prev = a             # <<<<<<<<<<<<<<
 * 	yields.append('%d:%d' % (start, prev))
 * 	return ' '.join(yields)
 */
    __pyx_v_prev = __pyx_v_a;

    /* "containers.pxd":391
 * 	cdef list yields = []
 * 	cdef int a, start = -2, prev = -2
 * 	for a in leaves:             # <<<<<<<<<<<<<<
 * 		if a - 1 != prev:
 * 			if prev != -2:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "containers.pxd":397
 * 			start = a
 * 		prev = a
 * 	yields.append('%d:%d' % (start, prev))             # <<<<<<<<<<<<<<
 * 	return ' '.join(yields)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_prev); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_d_d, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_yields, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(2, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "containers.pxd":398
 * 		prev = a
 * 	yields.append('%d:%d' % (start, prev))
 * 	return ' '.join(yields)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = PyUnicode_Join(__pyx_kp_u__7, __pyx_v_yields); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "containers.pxd":381
 * 
 * 
 * cdef inline str yieldranges(list leaves):             # <<<<<<<<<<<<<<
 * 	"""Convert a sorted list of indices into a string with intervals.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("discodop.containers.yieldranges", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_yields);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "containers.pxd":401
 * 
 * 
 * cdef inline short termidx(short x):             # <<<<<<<<<<<<<<
 * 	"""Translate representation for terminal indices."""
 * 	return -x - 1
 */

static CYTHON_INLINE short __pyx_f_8discodop_10containers_termidx(short __pyx_v_x) {
  short __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("termidx", 0);

  /* "containers.pxd":403
 * cdef inline short termidx(short x):
 * 	"""Translate representation for terminal indices."""
 * 	return -x - 1             # <<<<<<<<<<<<<<
 */
  __pyx_r = ((-__pyx_v_x) - 1);
  goto __pyx_L0;

  /* "containers.pxd":401
 * 
 * 
 * cdef inline short termidx(short x):             # <<<<<<<<<<<<<<
 * 	"""Translate representation for terminal indices."""
 * 	return -x - 1
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "coarsetofine",
    __pyx_k_Project_selected_items_from_a_ch, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_0_9, __pyx_k_0_9, sizeof(__pyx_k_0_9), 0, 1, 0, 0},
  {&__pyx_kp_u_C_O_A_R_S_E, __pyx_k_C_O_A_R_S_E, sizeof(__pyx_k_C_O_A_R_S_E), 0, 1, 0, 0},
  {&__pyx_kp_u_DOP_grammar_is_NOT_a_superset, __pyx_k_DOP_grammar_is_NOT_a_superset, sizeof(__pyx_k_DOP_grammar_is_NOT_a_superset), 0, 1, 0, 0},
  {&__pyx_kp_u_DOP_grammar_is_a_superset, __pyx_k_DOP_grammar_is_a_superset, sizeof(__pyx_k_DOP_grammar_is_a_superset), 0, 1, 0, 0},
  {&__pyx_kp_u_F_I_N_E, __pyx_k_F_I_N_E, sizeof(__pyx_k_F_I_N_E), 0, 1, 0, 0},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s_NegraCorpusReader, __pyx_k_NegraCorpusReader, sizeof(__pyx_k_NegraCorpusReader), 0, 0, 1, 1},
  {&__pyx_n_s_Tree, __pyx_k_Tree, sizeof(__pyx_k_Tree), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s__25, __pyx_k__25, sizeof(__pyx_k__25), 0, 0, 1, 1},
  {&__pyx_n_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 1},
  {&__pyx_kp_u__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 1, 0, 0},
  {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
  {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0},
  {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_addbitsets, __pyx_k_addbitsets, sizeof(__pyx_k_addbitsets), 0, 0, 1, 1},
  {&__pyx_n_s_addfanoutmarkers, __pyx_k_addfanoutmarkers, sizeof(__pyx_k_addfanoutmarkers), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_kp_u_alpinosample_export, __pyx_k_alpinosample_export, sizeof(__pyx_k_alpinosample_export), 0, 1, 0, 0},
  {&__pyx_n_s_begin, __pyx_k_begin, sizeof(__pyx_k_begin), 0, 0, 1, 1},
  {&__pyx_n_s_bin, __pyx_k_bin, sizeof(__pyx_k_bin), 0, 0, 1, 1},
  {&__pyx_n_s_binarize, __pyx_k_binarize, sizeof(__pyx_k_binarize), 0, 0, 1, 1},
  {&__pyx_n_s_bitpar, __pyx_k_bitpar, sizeof(__pyx_k_bitpar), 0, 0, 1, 1},
  {&__pyx_n_s_bitparkbestitems, __pyx_k_bitparkbestitems, sizeof(__pyx_k_bitparkbestitems), 0, 0, 1, 1},
  {&__pyx_n_u_bitparkbestitems, __pyx_k_bitparkbestitems, sizeof(__pyx_k_bitparkbestitems), 0, 1, 0, 1},
  {&__pyx_n_s_canonicalize, __pyx_k_canonicalize, sizeof(__pyx_k_canonicalize), 0, 0, 1, 1},
  {&__pyx_kp_u_cf_split, __pyx_k_cf_split, sizeof(__pyx_k_cf_split), 0, 1, 0, 0},
  {&__pyx_n_s_cfgwhitelist, __pyx_k_cfgwhitelist, sizeof(__pyx_k_cfgwhitelist), 0, 0, 1, 1},
  {&__pyx_n_s_cftrees, __pyx_k_cftrees, sizeof(__pyx_k_cftrees), 0, 0, 1, 1},
  {&__pyx_n_s_chart, __pyx_k_chart, sizeof(__pyx_k_chart), 0, 0, 1, 1},
  {&__pyx_n_s_chart2, __pyx_k_chart2, sizeof(__pyx_k_chart2), 0, 0, 1, 1},
  {&__pyx_n_s_chartitem, __pyx_k_chartitem, sizeof(__pyx_k_chartitem), 0, 0, 1, 1},
  {&__pyx_n_s_childchar, __pyx_k_childchar, sizeof(__pyx_k_childchar), 0, 0, 1, 1},
  {&__pyx_n_s_clock, __pyx_k_clock, sizeof(__pyx_k_clock), 0, 0, 1, 1},
  {&__pyx_n_s_coarse, __pyx_k_coarse, sizeof(__pyx_k_coarse), 0, 0, 1, 1},
  {&__pyx_kp_u_coarse_grammar, __pyx_k_coarse_grammar, sizeof(__pyx_k_coarse_grammar), 0, 1, 0, 0},
  {&__pyx_kp_u_coarse_items_before_pruning_d_af, __pyx_k_coarse_items_before_pruning_d_af, sizeof(__pyx_k_coarse_items_before_pruning_d_af), 0, 1, 0, 0},
  {&__pyx_kp_u_coarse_items_before_pruning_d_fi, __pyx_k_coarse_items_before_pruning_d_fi, sizeof(__pyx_k_coarse_items_before_pruning_d_fi), 0, 1, 0, 0},
  {&__pyx_n_s_coarsechart, __pyx_k_coarsechart, sizeof(__pyx_k_coarsechart), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_n_s_corpus, __pyx_k_corpus, sizeof(__pyx_k_corpus), 0, 0, 1, 1},
  {&__pyx_kp_u_d_d, __pyx_k_d_d, sizeof(__pyx_k_d_d), 0, 1, 0, 0},
  {&__pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_k_datastore_avcrane1_disco_dop_di, sizeof(__pyx_k_datastore_avcrane1_disco_dop_di), 0, 0, 1, 0},
  {&__pyx_n_s_deriv, __pyx_k_deriv, sizeof(__pyx_k_deriv), 0, 0, 1, 1},
  {&__pyx_n_s_derivations, __pyx_k_derivations, sizeof(__pyx_k_derivations), 0, 0, 1, 1},
  {&__pyx_n_s_derivs, __pyx_k_derivs, sizeof(__pyx_k_derivs), 0, 0, 1, 1},
  {&__pyx_n_s_disambiguation, __pyx_k_disambiguation, sizeof(__pyx_k_disambiguation), 0, 0, 1, 1},
  {&__pyx_n_s_discodop_coarsetofine, __pyx_k_discodop_coarsetofine, sizeof(__pyx_k_discodop_coarsetofine), 0, 0, 1, 1},
  {&__pyx_n_s_doctftest, __pyx_k_doctftest, sizeof(__pyx_k_doctftest), 0, 0, 1, 1},
  {&__pyx_n_s_dopreduction, __pyx_k_dopreduction, sizeof(__pyx_k_dopreduction), 0, 0, 1, 1},
  {&__pyx_n_s_dtrees, __pyx_k_dtrees, sizeof(__pyx_k_dtrees), 0, 0, 1, 1},
  {&__pyx_n_s_edge, __pyx_k_edge, sizeof(__pyx_k_edge), 0, 0, 1, 1},
  {&__pyx_n_s_edgelist, __pyx_k_edgelist, sizeof(__pyx_k_edgelist), 0, 0, 1, 1},
  {&__pyx_n_s_edges, __pyx_k_edges, sizeof(__pyx_k_edges), 0, 0, 1, 1},
  {&__pyx_n_s_enabled, __pyx_k_enabled, sizeof(__pyx_k_enabled), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_entries, __pyx_k_entries, sizeof(__pyx_k_entries), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_kp_u_exact_match, __pyx_k_exact_match, sizeof(__pyx_k_exact_match), 0, 1, 0, 0},
  {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1},
  {&__pyx_n_s_fanout, __pyx_k_fanout, sizeof(__pyx_k_fanout), 0, 0, 1, 1},
  {&__pyx_n_s_fatitems, __pyx_k_fatitems, sizeof(__pyx_k_fatitems), 0, 0, 1, 1},
  {&__pyx_n_s_filter, __pyx_k_filter, sizeof(__pyx_k_filter), 0, 0, 1, 1},
  {&__pyx_n_s_fine, __pyx_k_fine, sizeof(__pyx_k_fine), 0, 0, 1, 1},
  {&__pyx_n_s_fine1, __pyx_k_fine1, sizeof(__pyx_k_fine1), 0, 0, 1, 1},
  {&__pyx_n_s_fine999, __pyx_k_fine999, sizeof(__pyx_k_fine999), 0, 0, 1, 1},
  {&__pyx_n_s_fine999x, __pyx_k_fine999x, sizeof(__pyx_k_fine999x), 0, 0, 1, 1},
  {&__pyx_n_s_finecfg, __pyx_k_finecfg, sizeof(__pyx_k_finecfg), 0, 0, 1, 1},
  {&__pyx_n_s_finelabel, __pyx_k_finelabel, sizeof(__pyx_k_finelabel), 0, 0, 1, 1},
  {&__pyx_n_s_finespan, __pyx_k_finespan, sizeof(__pyx_k_finespan), 0, 0, 1, 1},
  {&__pyx_n_s_fromkeys, __pyx_k_fromkeys, sizeof(__pyx_k_fromkeys), 0, 0, 1, 1},
  {&__pyx_n_s_fsum, __pyx_k_fsum, sizeof(__pyx_k_fsum), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_getderivations, __pyx_k_getderivations, sizeof(__pyx_k_getderivations), 0, 0, 1, 1},
  {&__pyx_n_s_getinside, __pyx_k_getinside, sizeof(__pyx_k_getinside), 0, 0, 1, 1},
  {&__pyx_n_u_getinside, __pyx_k_getinside, sizeof(__pyx_k_getinside), 0, 1, 0, 1},
  {&__pyx_n_s_getitems, __pyx_k_getitems, sizeof(__pyx_k_getitems), 0, 0, 1, 1},
  {&__pyx_n_s_getmapping, __pyx_k_getmapping, sizeof(__pyx_k_getmapping), 0, 0, 1, 1},
  {&__pyx_n_s_getoutside, __pyx_k_getoutside, sizeof(__pyx_k_getoutside), 0, 0, 1, 1},
  {&__pyx_n_u_getoutside, __pyx_k_getoutside, sizeof(__pyx_k_getoutside), 0, 1, 0, 1},
  {&__pyx_n_s_grammar, __pyx_k_grammar, sizeof(__pyx_k_grammar), 0, 0, 1, 1},
  {&__pyx_n_s_horzmarkov, __pyx_k_horzmarkov, sizeof(__pyx_k_horzmarkov), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_isinf, __pyx_k_isinf, sizeof(__pyx_k_isinf), 0, 0, 1, 1},
  {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_kp_u_items_in_50_best_of_coarse_char, __pyx_k_items_in_50_best_of_coarse_char, sizeof(__pyx_k_items_in_50_best_of_coarse_char), 0, 1, 0, 0},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_kbest, __pyx_k_kbest, sizeof(__pyx_k_kbest), 0, 0, 1, 1},
  {&__pyx_n_s_kbestspans, __pyx_k_kbestspans, sizeof(__pyx_k_kbestspans), 0, 0, 1, 1},
  {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
  {&__pyx_n_s_label, __pyx_k_label, sizeof(__pyx_k_label), 0, 0, 1, 1},
  {&__pyx_n_s_lazykbest, __pyx_k_lazykbest, sizeof(__pyx_k_lazykbest), 0, 0, 1, 1},
  {&__pyx_n_s_leaves, __pyx_k_leaves, sizeof(__pyx_k_leaves), 0, 0, 1, 1},
  {&__pyx_n_s_leftitem, __pyx_k_leftitem, sizeof(__pyx_k_leftitem), 0, 0, 1, 1},
  {&__pyx_n_s_leftmostunary, __pyx_k_leftmostunary, sizeof(__pyx_k_leftmostunary), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_logprob, __pyx_k_logprob, sizeof(__pyx_k_logprob), 0, 0, 1, 1},
  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1},
  {&__pyx_n_s_marginalize, __pyx_k_marginalize, sizeof(__pyx_k_marginalize), 0, 0, 1, 1},
  {&__pyx_n_s_markorigin, __pyx_k_markorigin, sizeof(__pyx_k_markorigin), 0, 0, 1, 1},
  {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_mergediscnodes, __pyx_k_mergediscnodes, sizeof(__pyx_k_mergediscnodes), 0, 0, 1, 1},
  {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
  {&__pyx_n_s_mpp, __pyx_k_mpp, sizeof(__pyx_k_mpp), 0, 0, 1, 1},
  {&__pyx_n_u_mpp, __pyx_k_mpp, sizeof(__pyx_k_mpp), 0, 1, 0, 1},
  {&__pyx_n_s_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 0, 0, 1, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_kp_u_need_list_of_chart_items_in_topo, __pyx_k_need_list_of_chart_items_in_topo, sizeof(__pyx_k_need_list_of_chart_items_in_topo), 0, 1, 0, 0},
  {&__pyx_kp_u_need_to_call_fine_getmapping_coa, __pyx_k_need_to_call_fine_getmapping_coa, sizeof(__pyx_k_need_to_call_fine_getmapping_coa), 0, 1, 0, 0},
  {&__pyx_kp_u_no_match, __pyx_k_no_match, sizeof(__pyx_k_no_match), 0, 1, 0, 0},
  {&__pyx_kp_u_no_parse, __pyx_k_no_parse, sizeof(__pyx_k_no_parse), 0, 1, 0, 0},
  {&__pyx_kp_u_no_parse_problem, __pyx_k_no_parse_problem, sizeof(__pyx_k_no_parse_problem), 0, 1, 0, 0},
  {&__pyx_n_s_normal, __pyx_k_normal, sizeof(__pyx_k_normal), 0, 0, 1, 1},
  {&__pyx_n_u_normal, __pyx_k_normal, sizeof(__pyx_k_normal), 0, 1, 0, 1},
  {&__pyx_n_s_normallcfrs, __pyx_k_normallcfrs, sizeof(__pyx_k_normallcfrs), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_numitems, __pyx_k_numitems, sizeof(__pyx_k_numitems), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_numremain, __pyx_k_numremain, sizeof(__pyx_k_numremain), 0, 0, 1, 1},
  {&__pyx_n_s_origlogprob, __pyx_k_origlogprob, sizeof(__pyx_k_origlogprob), 0, 0, 1, 1},
  {&__pyx_n_s_outsideprob, __pyx_k_outsideprob, sizeof(__pyx_k_outsideprob), 0, 0, 1, 1},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_parent, __pyx_k_parent, sizeof(__pyx_k_parent), 0, 0, 1, 1},
  {&__pyx_n_u_parentannot, __pyx_k_parentannot, sizeof(__pyx_k_parentannot), 0, 1, 0, 1},
  {&__pyx_n_s_parentchar, __pyx_k_parentchar, sizeof(__pyx_k_parentchar), 0, 0, 1, 1},
  {&__pyx_n_s_parenttrees, __pyx_k_parenttrees, sizeof(__pyx_k_parenttrees), 0, 0, 1, 1},
  {&__pyx_n_s_parse, __pyx_k_parse, sizeof(__pyx_k_parse), 0, 0, 1, 1},
  {&__pyx_n_s_plcfrs, __pyx_k_plcfrs, sizeof(__pyx_k_plcfrs), 0, 0, 1, 1},
  {&__pyx_n_s_posterior, __pyx_k_posterior, sizeof(__pyx_k_posterior), 0, 0, 1, 1},
  {&__pyx_n_s_posteriorthreshold, __pyx_k_posteriorthreshold, sizeof(__pyx_k_posteriorthreshold), 0, 0, 1, 1},
  {&__pyx_n_u_posteriorthreshold, __pyx_k_posteriorthreshold, sizeof(__pyx_k_posteriorthreshold), 0, 1, 0, 1},
  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  {&__pyx_n_s_prob, __pyx_k_prob, sizeof(__pyx_k_prob), 0, 0, 1, 1},
  {&__pyx_kp_u_probability_threshold_should_be, __pyx_k_probability_threshold_should_be, sizeof(__pyx_k_probability_threshold_should_be), 0, 1, 0, 0},
  {&__pyx_n_s_prunechart, __pyx_k_prunechart, sizeof(__pyx_k_prunechart), 0, 0, 1, 1},
  {&__pyx_n_u_prunechart, __pyx_k_prunechart, sizeof(__pyx_k_prunechart), 0, 1, 0, 1},
  {&__pyx_n_s_pyexp, __pyx_k_pyexp, sizeof(__pyx_k_pyexp), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_rankededges, __pyx_k_rankededges, sizeof(__pyx_k_rankededges), 0, 0, 1, 1},
  {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
  {&__pyx_n_s_removefanoutmarkers, __pyx_k_removefanoutmarkers, sizeof(__pyx_k_removefanoutmarkers), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_rightitem, __pyx_k_rightitem, sizeof(__pyx_k_rightitem), 0, 0, 1, 1},
  {&__pyx_n_s_root, __pyx_k_root, sizeof(__pyx_k_root), 0, 0, 1, 1},
  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
  {&__pyx_n_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 1},
  {&__pyx_n_s_sent, __pyx_k_sent, sizeof(__pyx_k_sent), 0, 0, 1, 1},
  {&__pyx_kp_u_sentence_has_zero_posterior_prob, __pyx_k_sentence_has_zero_posterior_prob, sizeof(__pyx_k_sentence_has_zero_posterior_prob), 0, 1, 0, 0},
  {&__pyx_n_s_sentprob, __pyx_k_sentprob, sizeof(__pyx_k_sentprob), 0, 0, 1, 1},
  {&__pyx_n_s_sents, __pyx_k_sents, sizeof(__pyx_k_sents), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_splitdiscnodes, __pyx_k_splitdiscnodes, sizeof(__pyx_k_splitdiscnodes), 0, 0, 1, 1},
  {&__pyx_n_s_splitg, __pyx_k_splitg, sizeof(__pyx_k_splitg), 0, 0, 1, 1},
  {&__pyx_n_s_splitprune, __pyx_k_splitprune, sizeof(__pyx_k_splitprune), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_subsetgrammar, __pyx_k_subsetgrammar, sizeof(__pyx_k_subsetgrammar), 0, 0, 1, 1},
  {&__pyx_n_s_subtrees, __pyx_k_subtrees, sizeof(__pyx_k_subtrees), 0, 0, 1, 1},
  {&__pyx_n_s_switch, __pyx_k_switch, sizeof(__pyx_k_switch), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_n_s_tagged_sents, __pyx_k_tagged_sents, sizeof(__pyx_k_tagged_sents), 0, 0, 1, 1},
  {&__pyx_n_s_tags, __pyx_k_tags, sizeof(__pyx_k_tags), 0, 0, 1, 1},
  {&__pyx_n_s_tailmarker, __pyx_k_tailmarker, sizeof(__pyx_k_tailmarker), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_test_2, __pyx_k_test_2, sizeof(__pyx_k_test_2), 0, 0, 1, 1},
  {&__pyx_n_s_testmaxlen, __pyx_k_testmaxlen, sizeof(__pyx_k_testmaxlen), 0, 0, 1, 1},
  {&__pyx_n_s_threshold, __pyx_k_threshold, sizeof(__pyx_k_threshold), 0, 0, 1, 1},
  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
  {&__pyx_kp_u_time_elapsed, __pyx_k_time_elapsed, sizeof(__pyx_k_time_elapsed), 0, 1, 0, 0},
  {&__pyx_n_s_tolabel, __pyx_k_tolabel, sizeof(__pyx_k_tolabel), 0, 0, 1, 1},
  {&__pyx_n_s_train, __pyx_k_train, sizeof(__pyx_k_train), 0, 0, 1, 1},
  {&__pyx_n_s_tree, __pyx_k_tree, sizeof(__pyx_k_tree), 0, 0, 1, 1},
  {&__pyx_n_s_treebank, __pyx_k_treebank, sizeof(__pyx_k_treebank), 0, 0, 1, 1},
  {&__pyx_n_s_treebankgrammar, __pyx_k_treebankgrammar, sizeof(__pyx_k_treebankgrammar), 0, 0, 1, 1},
  {&__pyx_n_s_trees, __pyx_k_trees, sizeof(__pyx_k_trees), 0, 0, 1, 1},
  {&__pyx_n_s_treetransforms, __pyx_k_treetransforms, sizeof(__pyx_k_treetransforms), 0, 0, 1, 1},
  {&__pyx_n_s_unbinarize, __pyx_k_unbinarize, sizeof(__pyx_k_unbinarize), 0, 0, 1, 1},
  {&__pyx_n_s_unfiltered, __pyx_k_unfiltered, sizeof(__pyx_k_unfiltered), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_vec, __pyx_k_vec, sizeof(__pyx_k_vec), 0, 0, 1, 1},
  {&__pyx_n_s_verbose, __pyx_k_verbose, sizeof(__pyx_k_verbose), 0, 0, 1, 1},
  {&__pyx_n_s_vertmarkov, __pyx_k_vertmarkov, sizeof(__pyx_k_vertmarkov), 0, 0, 1, 1},
  {&__pyx_kp_u_whitelist, __pyx_k_whitelist, sizeof(__pyx_k_whitelist), 0, 1, 0, 0},
  {&__pyx_n_s_whitelist_2, __pyx_k_whitelist_2, sizeof(__pyx_k_whitelist_2), 0, 0, 1, 1},
  {&__pyx_n_s_word, __pyx_k_word, sizeof(__pyx_k_word), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_n_s_yf, __pyx_k_yf, sizeof(__pyx_k_yf), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 60, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 88, __pyx_L1_error)
  __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s_min); if (!__pyx_builtin_min) __PYX_ERR(0, 131, __pyx_L1_error)
  __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 132, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 240, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 274, __pyx_L1_error)
  __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_n_s_print); if (!__pyx_builtin_print) __PYX_ERR(0, 275, __pyx_L1_error)
  __pyx_builtin_bin = __Pyx_GetBuiltinName(__pyx_n_s_bin); if (!__pyx_builtin_bin) __PYX_ERR(0, 299, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 301, __pyx_L1_error)
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 303, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 107, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "discodop/coarsetofine.pyx":60
 * 	cdef ChartItem chartitem
 * 	if fine.mapping is NULL:
 * 		raise ValueError('need to call fine.getmapping(coarse, ...).')             # <<<<<<<<<<<<<<
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_need_to_call_fine_getmapping_coa); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "discodop/coarsetofine.pyx":63
 * 	if splitprune and markorigin:
 * 		if fine.splitmapping is NULL or fine.splitmapping[0] is NULL:
 * 			raise ValueError('need to call fine.getmapping(coarse, ...).')             # <<<<<<<<<<<<<<
 * 	# prune coarse chart and collect items
 * 	if 0 < k < 1:  # threshold on posterior probabilities
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_need_to_call_fine_getmapping_coa); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "discodop/coarsetofine.pyx":151
 * 	:returns: dictionary of remaining items."""
 * 	if not 0 < threshold < 1:
 * 		raise ValueError('probability threshold should be between 0 and 1.')             # <<<<<<<<<<<<<<
 * 	if not chart.itemsinorder:
 * 		raise ValueError('need list of chart items in topological order.')
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_probability_threshold_should_be); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "discodop/coarsetofine.pyx":153
 * 		raise ValueError('probability threshold should be between 0 and 1.')
 * 	if not chart.itemsinorder:
 * 		raise ValueError('need list of chart items in topological order.')             # <<<<<<<<<<<<<<
 * 	origlogprob = chart.grammar.logprob
 * 	chart.grammar.switch(
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_need_list_of_chart_items_in_topo); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "discodop/coarsetofine.pyx":275
 * 	from math import exp as pyexp
 * 	sent, tags = zip(*sent)
 * 	print(' C O A R S E ')             # <<<<<<<<<<<<<<
 * 	chart, _ = plcfrs.parse(sent, coarse, tags=tags)
 * 	if chart:
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_C_O_A_R_S_E); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "discodop/coarsetofine.pyx":290
 * 			print("exact match" if t == canonicalize(tree) else "no match")
 * 	else:
 * 		print("no parse")             # <<<<<<<<<<<<<<
 * 		return
 * 		# print(chart)
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_no_parse); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "discodop/coarsetofine.pyx":295
 * 	l, _, _ = prunechart(chart, fine, k, split, True, False, False)
 * 	if verbose:
 * 		print("\nitems in 50-best of coarse chart")             # <<<<<<<<<<<<<<
 * 		_ = lazykbest(chart, k, derivs=False)
 * 		for a in chart.rankededges:
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_items_in_50_best_of_coarse_char); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "discodop/coarsetofine.pyx":300
 * 			print(coarse.tolabel[(<ChartItem>a).label],
 * 					bin((<ChartItem>a).vec))
 * 		print("\nwhitelist:")             # <<<<<<<<<<<<<<
 * 		for n, x in enumerate(l):
 * 			if isinstance(x, dict):
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_whitelist); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "discodop/coarsetofine.pyx":307
 * 				for m, y in enumerate(x):
 * 					print(fine.tolabel[n], m, map(bin, y))
 * 	print(' F I N E ')             # <<<<<<<<<<<<<<
 * 	chart2, _ = plcfrs.parse(sent, fine, tags=tags, whitelist=l,
 * 			splitprune=split, markorigin=True)
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_F_I_N_E); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "discodop/coarsetofine.pyx":321
 * 			print("exact match" if t == canonicalize(tree) else "no match", t)
 * 	else:
 * 		print("no parse. problem.")             # <<<<<<<<<<<<<<
 * 		return
 * 		# if verbose:
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_no_parse_problem); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 321, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "discodop/coarsetofine.pyx":353
 * 	# test = 40
 * 	# testmaxlen = 999
 * 	corpus = NegraCorpusReader('alpinosample.export')             # <<<<<<<<<<<<<<
 * 	train = 0
 * 	test = 3
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_alpinosample_export); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "discodop/coarsetofine.pyx":362
 * 	sents = list(corpus.sents().values())
 * 
 * 	dtrees = [t.copy(True) for t in trees]             # <<<<<<<<<<<<<<
 * 	parenttrees = [t.copy(True) for t in trees]
 * 	for t in trees:
 */
  __pyx_tuple__16 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 362, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "discodop/coarsetofine.pyx":363
 * 
 * 	dtrees = [t.copy(True) for t in trees]
 * 	parenttrees = [t.copy(True) for t in trees]             # <<<<<<<<<<<<<<
 * 	for t in trees:
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 */
  __pyx_tuple__17 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "discodop/coarsetofine.pyx":367
 * 		binarize(t, vertmarkov=1, horzmarkov=1)
 * 		addfanoutmarkers(t)
 * 	cftrees = [splitdiscnodes(t.copy(True), markorigin=True) for t in trees]             # <<<<<<<<<<<<<<
 * 	for t in cftrees:
 * 		binarize(t, horzmarkov=2, tailmarker='', leftmostunary=True,
 */
  __pyx_tuple__18 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "discodop/coarsetofine.pyx":391
 * 	sents = list(corpus.tagged_sents().values())[train:train + test]
 * 	if subsetgrammar(normallcfrs, fine999x):
 * 		print("DOP grammar is a superset")             # <<<<<<<<<<<<<<
 * 	else:
 * 		print("DOP grammar is NOT a superset!")
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_DOP_grammar_is_a_superset); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "discodop/coarsetofine.pyx":393
 * 		print("DOP grammar is a superset")
 * 	else:
 * 		print("DOP grammar is NOT a superset!")             # <<<<<<<<<<<<<<
 * 	for msg, coarse, fine, split, enabled in zip(
 * 			('normal', 'parentannot', 'cf-split'),
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_DOP_grammar_is_NOT_a_superset); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 393, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "discodop/coarsetofine.pyx":395
 * 		print("DOP grammar is NOT a superset!")
 * 	for msg, coarse, fine, split, enabled in zip(
 * 			('normal', 'parentannot', 'cf-split'),             # <<<<<<<<<<<<<<
 * 			(normal, parent, splitg),
 * 			(fine999, fine1, fine1),
 */
  __pyx_tuple__21 = PyTuple_Pack(3, __pyx_n_u_normal, __pyx_n_u_parentannot, __pyx_kp_u_cf_split); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "discodop/coarsetofine.pyx":398
 * 			(normal, parent, splitg),
 * 			(fine999, fine1, fine1),
 * 			(False, False, True),             # <<<<<<<<<<<<<<
 * 			(True, False, True)):
 * 		if not enabled:
 */
  __pyx_tuple__22 = PyTuple_Pack(3, Py_False, Py_False, Py_True); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "discodop/coarsetofine.pyx":399
 * 			(fine999, fine1, fine1),
 * 			(False, False, True),
 * 			(True, False, True)):             # <<<<<<<<<<<<<<
 * 		if not enabled:
 * 			continue
 */
  __pyx_tuple__23 = PyTuple_Pack(3, Py_True, Py_False, Py_True); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "discodop/coarsetofine.pyx":403
 * 			continue
 * 		print("coarse grammar:", msg)
 * 		fine.getmapping(coarse, re.compile('@[-0-9]+$'), None, split, True)             # <<<<<<<<<<<<<<
 * 		begin = clock()
 * 		for n, (sent, tree) in enumerate(zip(sents, trees)):
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_0_9); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "discodop/coarsetofine.pyx":20
 * 
 * 
 * def prunechart(Chart coarsechart, Grammar fine, k,             # <<<<<<<<<<<<<<
 * 		bint splitprune, bint markorigin, bint finecfg, bint bitpar):
 * 	"""Produce a white list of selected chart items.
 */
  __pyx_tuple__26 = PyTuple_Pack(18, __pyx_n_s_coarsechart, __pyx_n_s_fine, __pyx_n_s_k, __pyx_n_s_splitprune, __pyx_n_s_markorigin, __pyx_n_s_finecfg, __pyx_n_s_bitpar, __pyx_n_s_items, __pyx_n_s_whitelist_2, __pyx_n_s_chartitem, __pyx_n_s_msg, __pyx_n_s__25, __pyx_n_s_cfgwhitelist, __pyx_n_s_item, __pyx_n_s_label, __pyx_n_s_finespan, __pyx_n_s_finelabel, __pyx_n_s_kbestspans); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_prunechart, 20, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 20, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":117
 * 
 * 
 * def bitparkbestitems(Chart chart, int k, bint finecfg):             # <<<<<<<<<<<<<<
 * 	"""Produce ChartItems occurring in a dictionary of derivations.
 * 
 */
  __pyx_tuple__28 = PyTuple_Pack(15, __pyx_n_s_chart, __pyx_n_s_k, __pyx_n_s_finecfg, __pyx_n_s_fatitems, __pyx_n_s_derivs, __pyx_n_s_items, __pyx_n_s_deriv, __pyx_n_s__25, __pyx_n_s_t, __pyx_n_s_n, __pyx_n_s_label, __pyx_n_s_leaves, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_item); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);
  __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_bitparkbestitems, 117, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 117, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":146
 * 
 * 
 * def posteriorthreshold(Chart chart, double threshold):             # <<<<<<<<<<<<<<
 * 	"""Prune labeled spans from chart below given posterior threshold.
 * 
 */
  __pyx_tuple__30 = PyTuple_Pack(9, __pyx_n_s_chart, __pyx_n_s_threshold, __pyx_n_s_origlogprob, __pyx_n_s_sentprob, __pyx_n_s_posterior, __pyx_n_s_unfiltered, __pyx_n_s_numitems, __pyx_n_s_numremain, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
  __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_posteriorthreshold, 146, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 146, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":179
 * 
 * 
 * def getinside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute inside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */
  __pyx_tuple__32 = PyTuple_Pack(11, __pyx_n_s_chart, __pyx_n_s_n, __pyx_n_s_edge, __pyx_n_s_edges, __pyx_n_s_edgelist, __pyx_n_s_item, __pyx_n_s_label, __pyx_n_s_word, __pyx_n_s_prob, __pyx_n_s_leftitem, __pyx_n_s_rightitem); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(1, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_getinside, 179, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 179, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":228
 * 
 * 
 * def getoutside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute outside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */
  __pyx_tuple__34 = PyTuple_Pack(9, __pyx_n_s_chart, __pyx_n_s_n, __pyx_n_s_edge, __pyx_n_s_edges, __pyx_n_s_edgelist, __pyx_n_s_outsideprob, __pyx_n_s_item, __pyx_n_s_leftitem, __pyx_n_s_rightitem); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_getoutside, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 228, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":268
 * 
 * 
 * def doctftest(coarse, fine, sent, tree, k, split, verbose=False):             # <<<<<<<<<<<<<<
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs
 */
  __pyx_tuple__36 = PyTuple_Pack(28, __pyx_n_s_coarse, __pyx_n_s_fine, __pyx_n_s_sent, __pyx_n_s_tree, __pyx_n_s_k, __pyx_n_s_split, __pyx_n_s_verbose, __pyx_n_s_plcfrs, __pyx_n_s_getderivations, __pyx_n_s_marginalize, __pyx_n_s_canonicalize, __pyx_n_s_removefanoutmarkers, __pyx_n_s_pyexp, __pyx_n_s_tags, __pyx_n_s_chart, __pyx_n_s__25, __pyx_n_s_derivations, __pyx_n_s_entries, __pyx_n_s_mpp, __pyx_n_s_t, __pyx_n_s_p, __pyx_n_s_l, __pyx_n_s_a, __pyx_n_s_n, __pyx_n_s_x, __pyx_n_s_m, __pyx_n_s_y, __pyx_n_s_chart2); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(7, 0, 28, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_doctftest, 268, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 268, __pyx_L1_error)

  /* "discodop/coarsetofine.pyx":339
 * 
 * 
 * def test():             # <<<<<<<<<<<<<<
 * 	import re
 * 	from time import clock
 */
  __pyx_tuple__38 = PyTuple_Pack(39, __pyx_n_s_re, __pyx_n_s_clock, __pyx_n_s_splitdiscnodes, __pyx_n_s_binarize, __pyx_n_s_addfanoutmarkers, __pyx_n_s_NegraCorpusReader, __pyx_n_s_treebankgrammar, __pyx_n_s_dopreduction, __pyx_n_s_subsetgrammar, __pyx_n_s_k, __pyx_n_s_corpus, __pyx_n_s_train, __pyx_n_s_test, __pyx_n_s_testmaxlen, __pyx_n_s_trees, __pyx_n_s_sents, __pyx_n_s_dtrees, __pyx_n_s_parenttrees, __pyx_n_s_t, __pyx_n_s_cftrees, __pyx_n_s_normallcfrs, __pyx_n_s_normal, __pyx_n_s_parent, __pyx_n_s_splitg, __pyx_n_s_s, __pyx_n_s__25, __pyx_n_s_yf, __pyx_n_s_fine999x, __pyx_n_s_fine999, __pyx_n_s_fine1, __pyx_n_s_msg, __pyx_n_s_coarse, __pyx_n_s_fine, __pyx_n_s_split, __pyx_n_s_enabled, __pyx_n_s_begin, __pyx_n_s_n, __pyx_n_s_sent, __pyx_n_s_tree); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(0, 0, 39, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_datastore_avcrane1_disco_dop_di, __pyx_n_s_test, 339, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_460 = PyInt_FromLong(460); if (unlikely(!__pyx_int_460)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initcoarsetofine(void); /*proto*/
PyMODINIT_FUNC initcoarsetofine(void)
#else
PyMODINIT_FUNC PyInit_coarsetofine(void); /*proto*/
PyMODINIT_FUNC PyInit_coarsetofine(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_coarsetofine(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("coarsetofine", __pyx_methods, __pyx_k_Project_selected_items_from_a_ch, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_discodop__coarsetofine) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "discodop.coarsetofine")) {
      if (unlikely(PyDict_SetItemString(modules, "discodop.coarsetofine", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(3, 9, __pyx_L1_error)
  __pyx_ptype_7cpython_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_7cpython_5array_array)) __PYX_ERR(1, 58, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_Grammar = __Pyx_ImportType("discodop.containers", "Grammar", sizeof(struct __pyx_obj_8discodop_10containers_Grammar), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_Grammar)) __PYX_ERR(2, 29, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_Grammar = (struct __pyx_vtabstruct_8discodop_10containers_Grammar*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_Grammar->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_Grammar)) __PYX_ERR(2, 29, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_Chart = __Pyx_ImportType("discodop.containers", "Chart", sizeof(struct __pyx_obj_8discodop_10containers_Chart), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_Chart)) __PYX_ERR(2, 78, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_Chart = (struct __pyx_vtabstruct_8discodop_10containers_Chart*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_Chart->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_Chart)) __PYX_ERR(2, 78, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_LexicalRule = __Pyx_ImportType("discodop.containers", "LexicalRule", sizeof(struct __pyx_obj_8discodop_10containers_LexicalRule), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_LexicalRule)) __PYX_ERR(2, 114, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_ChartItem = __Pyx_ImportType("discodop.containers", "ChartItem", sizeof(struct __pyx_obj_8discodop_10containers_ChartItem), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_ChartItem)) __PYX_ERR(2, 121, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_SmallChartItem = __Pyx_ImportType("discodop.containers", "SmallChartItem", sizeof(struct __pyx_obj_8discodop_10containers_SmallChartItem), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_SmallChartItem)) __PYX_ERR(2, 127, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_SmallChartItem = (struct __pyx_vtabstruct_8discodop_10containers_SmallChartItem*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_SmallChartItem->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_SmallChartItem)) __PYX_ERR(2, 127, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_FatChartItem = __Pyx_ImportType("discodop.containers", "FatChartItem", sizeof(struct __pyx_obj_8discodop_10containers_FatChartItem), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_FatChartItem)) __PYX_ERR(2, 133, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_FatChartItem = (struct __pyx_vtabstruct_8discodop_10containers_FatChartItem*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_FatChartItem->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_FatChartItem)) __PYX_ERR(2, 133, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_Edges = __Pyx_ImportType("discodop.containers", "Edges", sizeof(struct __pyx_obj_8discodop_10containers_Edges), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_Edges)) __PYX_ERR(2, 155, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_RankedEdge = __Pyx_ImportType("discodop.containers", "RankedEdge", sizeof(struct __pyx_obj_8discodop_10containers_RankedEdge), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_RankedEdge)) __PYX_ERR(2, 173, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_Ctrees = __Pyx_ImportType("discodop.containers", "Ctrees", sizeof(struct __pyx_obj_8discodop_10containers_Ctrees), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_Ctrees)) __PYX_ERR(2, 232, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_Ctrees = (struct __pyx_vtabstruct_8discodop_10containers_Ctrees*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_Ctrees->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_Ctrees)) __PYX_ERR(2, 232, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_Vocabulary = __Pyx_ImportType("discodop.containers", "Vocabulary", sizeof(struct __pyx_obj_8discodop_10containers_Vocabulary), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_Vocabulary)) __PYX_ERR(2, 263, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_Vocabulary = (struct __pyx_vtabstruct_8discodop_10containers_Vocabulary*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_Vocabulary->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_Vocabulary)) __PYX_ERR(2, 263, __pyx_L1_error)
  __pyx_ptype_8discodop_10containers_FixedVocabulary = __Pyx_ImportType("discodop.containers", "FixedVocabulary", sizeof(struct __pyx_obj_8discodop_10containers_FixedVocabulary), 1); if (unlikely(!__pyx_ptype_8discodop_10containers_FixedVocabulary)) __PYX_ERR(2, 280, __pyx_L1_error)
  __pyx_vtabptr_8discodop_10containers_FixedVocabulary = (struct __pyx_vtabstruct_8discodop_10containers_FixedVocabulary*)__Pyx_GetVtable(__pyx_ptype_8discodop_10containers_FixedVocabulary->tp_dict); if (unlikely(!__pyx_vtabptr_8discodop_10containers_FixedVocabulary)) __PYX_ERR(2, 280, __pyx_L1_error)
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("discodop.containers"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "log1e200", (void **)&__pyx_vp_8discodop_10containers_log1e200, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Function import code ---*/
  __pyx_t_2 = __Pyx_ImportModule("discodop.containers"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "CFGtoSmallChartItem", (void (**)(void))&__pyx_f_8discodop_10containers_CFGtoSmallChartItem, "struct __pyx_obj_8discodop_10containers_SmallChartItem *(uint32_t, __pyx_t_8discodop_10containers_Idx, __pyx_t_8discodop_10containers_Idx)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "CFGtoFatChartItem", (void (**)(void))&__pyx_f_8discodop_10containers_CFGtoFatChartItem, "struct __pyx_obj_8discodop_10containers_FatChartItem *(uint32_t, __pyx_t_8discodop_10containers_Idx, __pyx_t_8discodop_10containers_Idx)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "discodop/coarsetofine.pyx":5
 * from __future__ import print_function
 * from libc.stdint cimport uint8_t, uint32_t, uint64_t
 * from .tree import Tree             # <<<<<<<<<<<<<<
 * from .treetransforms import mergediscnodes, unbinarize, fanout, addbitsets
 * from .containers cimport Grammar, Chart, ChartItem, Edge, Edges, MoreEdges, \
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_Tree);
  __Pyx_GIVEREF(__pyx_n_s_Tree);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Tree);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_tree, __pyx_t_3, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Tree); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Tree, __pyx_t_3) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":6
 * from libc.stdint cimport uint8_t, uint32_t, uint64_t
 * from .tree import Tree
 * from .treetransforms import mergediscnodes, unbinarize, fanout, addbitsets             # <<<<<<<<<<<<<<
 * from .containers cimport Grammar, Chart, ChartItem, Edge, Edges, MoreEdges, \
 * 		LexicalRule, RankedEdge, cellidx, compactcellidx, \
 */
  __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_mergediscnodes);
  __Pyx_GIVEREF(__pyx_n_s_mergediscnodes);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_mergediscnodes);
  __Pyx_INCREF(__pyx_n_s_unbinarize);
  __Pyx_GIVEREF(__pyx_n_s_unbinarize);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_unbinarize);
  __Pyx_INCREF(__pyx_n_s_fanout);
  __Pyx_GIVEREF(__pyx_n_s_fanout);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_fanout);
  __Pyx_INCREF(__pyx_n_s_addbitsets);
  __Pyx_GIVEREF(__pyx_n_s_addbitsets);
  PyList_SET_ITEM(__pyx_t_4, 3, __pyx_n_s_addbitsets);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_treetransforms, __pyx_t_4, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_mergediscnodes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_mergediscnodes, __pyx_t_4) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_unbinarize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unbinarize, __pyx_t_4) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_fanout); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_fanout, __pyx_t_4) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_addbitsets); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_addbitsets, __pyx_t_4) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "discodop/coarsetofine.pyx":10
 * 		LexicalRule, RankedEdge, cellidx, compactcellidx, \
 * 		CFGtoSmallChartItem, CFGtoFatChartItem
 * from .kbest import lazykbest             # <<<<<<<<<<<<<<
 * import numpy as np
 * 
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_lazykbest);
  __Pyx_GIVEREF(__pyx_n_s_lazykbest);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_lazykbest);
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_kbest, __pyx_t_3, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_lazykbest); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_lazykbest, __pyx_t_3) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":11
 * 		CFGtoSmallChartItem, CFGtoFatChartItem
 * from .kbest import lazykbest
 * import numpy as np             # <<<<<<<<<<<<<<
 * 
 * include "constants.pxi"
 */
  __pyx_t_4 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_4) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":20
 * 
 * 
 * def prunechart(Chart coarsechart, Grammar fine, k,             # <<<<<<<<<<<<<<
 * 		bint splitprune, bint markorigin, bint finecfg, bint bitpar):
 * 	"""Produce a white list of selected chart items.
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_1prunechart, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_prunechart, __pyx_t_4) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":117
 * 
 * 
 * def bitparkbestitems(Chart chart, int k, bint finecfg):             # <<<<<<<<<<<<<<
 * 	"""Produce ChartItems occurring in a dictionary of derivations.
 * 
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_3bitparkbestitems, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitparkbestitems, __pyx_t_4) < 0) __PYX_ERR(0, 117, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":146
 * 
 * 
 * def posteriorthreshold(Chart chart, double threshold):             # <<<<<<<<<<<<<<
 * 	"""Prune labeled spans from chart below given posterior threshold.
 * 
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_5posteriorthreshold, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_posteriorthreshold, __pyx_t_4) < 0) __PYX_ERR(0, 146, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":179
 * 
 * 
 * def getinside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute inside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_7getinside, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_getinside, __pyx_t_4) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":228
 * 
 * 
 * def getoutside(Chart chart):             # <<<<<<<<<<<<<<
 * 	"""Compute outside probabilities for a chart given its parse forest."""
 * 	cdef size_t n
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_9getoutside, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_getoutside, __pyx_t_4) < 0) __PYX_ERR(0, 228, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":268
 * 
 * 
 * def doctftest(coarse, fine, sent, tree, k, split, verbose=False):             # <<<<<<<<<<<<<<
 * 	"""Test coarse-to-fine methods on a sentence."""
 * 	from . import plcfrs
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_11doctftest, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_doctftest, __pyx_t_4) < 0) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":339
 * 
 * 
 * def test():             # <<<<<<<<<<<<<<
 * 	import re
 * 	from time import clock
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_8discodop_12coarsetofine_13test, NULL, __pyx_n_s_discodop_coarsetofine); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":412
 * 		print("time elapsed", clock() - begin, "s")
 * 
 * __all__ = ['prunechart', 'bitparkbestitems', 'posteriorthreshold',             # <<<<<<<<<<<<<<
 * 		'getinside', 'getoutside']
 */
  __pyx_t_4 = PyList_New(5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_u_prunechart);
  __Pyx_GIVEREF(__pyx_n_u_prunechart);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_prunechart);
  __Pyx_INCREF(__pyx_n_u_bitparkbestitems);
  __Pyx_GIVEREF(__pyx_n_u_bitparkbestitems);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_bitparkbestitems);
  __Pyx_INCREF(__pyx_n_u_posteriorthreshold);
  __Pyx_GIVEREF(__pyx_n_u_posteriorthreshold);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_u_posteriorthreshold);
  __Pyx_INCREF(__pyx_n_u_getinside);
  __Pyx_GIVEREF(__pyx_n_u_getinside);
  PyList_SET_ITEM(__pyx_t_4, 3, __pyx_n_u_getinside);
  __Pyx_INCREF(__pyx_n_u_getoutside);
  __Pyx_GIVEREF(__pyx_n_u_getoutside);
  PyList_SET_ITEM(__pyx_t_4, 4, __pyx_n_u_getoutside);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_4) < 0) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "discodop/coarsetofine.pyx":1
 * """Project selected items from a chart to corresponding items in next grammar.             # <<<<<<<<<<<<<<
 * """
 * from __future__ import print_function
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_2, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "containers.pxd":401
 * 
 * 
 * cdef inline short termidx(short x):             # <<<<<<<<<<<<<<
 * 	"""Translate representation for terminal indices."""
 * 	return -x - 1
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init discodop.coarsetofine", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init discodop.coarsetofine");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* ArgTypeTest */
static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* GetModuleGlobalName */
  static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

/* PyFunctionFastCall */
    #if CYTHON_FAST_PYCALL
#include "frameobject.h"
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = PyThreadState_GET();
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = f->f_localsplus;
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif  // CPython < 3.6
#endif  // CYTHON_FAST_PYCALL

/* PyCFunctionFastCall */
    #if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
}
#endif  // CYTHON_FAST_PYCCALL

/* RaiseTooManyValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
    static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
    static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* PyIntBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

/* PyObjectCallMethO */
    #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
    #if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* SliceObject */
        static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* PyObjectCallMethod0 */
        static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *function = PyMethod_GET_FUNCTION(method);
            result = __Pyx_PyObject_CallOneArg(function, self);
            Py_DECREF(method);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

/* RaiseNoneIterError */
        static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
        static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError(index);
    }
}

/* UnpackTuple2 */
        static CYTHON_INLINE int __Pyx_unpack_tuple2(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                             int is_tuple, int has_known_size, int decref_tuple) {
    Py_ssize_t index;
    PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
    if (!is_tuple && unlikely(!PyTuple_Check(tuple))) {
        iternextfunc iternext;
        iter = PyObject_GetIter(tuple);
        if (unlikely(!iter)) goto bad;
        if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
        iternext = Py_TYPE(iter)->tp_iternext;
        value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
        value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
        if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
        Py_DECREF(iter);
    } else {
        if (!has_known_size && unlikely(PyTuple_GET_SIZE(tuple) != 2)) {
            __Pyx_UnpackTupleError(tuple, 2);
            goto bad;
        }
#if CYTHON_COMPILING_IN_PYPY
        value1 = PySequence_ITEM(tuple, 0);
        if (unlikely(!value1)) goto bad;
        value2 = PySequence_ITEM(tuple, 1);
        if (unlikely(!value2)) goto bad;
#else
        value1 = PyTuple_GET_ITEM(tuple, 0);
        value2 = PyTuple_GET_ITEM(tuple, 1);
        Py_INCREF(value1);
        Py_INCREF(value2);
#endif
        if (decref_tuple) { Py_DECREF(tuple); }
    }
    *pvalue1 = value1;
    *pvalue2 = value2;
    return 0;
unpacking_failed:
    if (!has_known_size && __Pyx_IterFinish() == 0)
        __Pyx_RaiseNeedMoreValuesError(index);
bad:
    Py_XDECREF(iter);
    Py_XDECREF(value1);
    Py_XDECREF(value2);
    if (decref_tuple) { Py_XDECREF(tuple); }
    return -1;
}

/* dict_iter */
        static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_source_is_dict) {
    is_dict = is_dict || likely(PyDict_CheckExact(iterable));
    *p_source_is_dict = is_dict;
#if !CYTHON_COMPILING_IN_PYPY
    if (is_dict) {
        *p_orig_length = PyDict_Size(iterable);
        Py_INCREF(iterable);
        return iterable;
    }
#endif
    *p_orig_length = 0;
    if (method_name) {
        PyObject* iter;
        iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
        if (!iterable)
            return NULL;
#if !CYTHON_COMPILING_IN_PYPY
        if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
            return iterable;
#endif
        iter = PyObject_GetIter(iterable);
        Py_DECREF(iterable);
        return iter;
    }
    return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
        PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
        PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
    PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
    if (source_is_dict) {
        PyObject *key, *value;
        if (unlikely(orig_length != PyDict_Size(iter_obj))) {
            PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
            return -1;
        }
        if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
            return 0;
        }
        if (pitem) {
            PyObject* tuple = PyTuple_New(2);
            if (unlikely(!tuple)) {
                return -1;
            }
            Py_INCREF(key);
            Py_INCREF(value);
            PyTuple_SET_ITEM(tuple, 0, key);
            PyTuple_SET_ITEM(tuple, 1, value);
            *pitem = tuple;
        } else {
            if (pkey) {
                Py_INCREF(key);
                *pkey = key;
            }
            if (pvalue) {
                Py_INCREF(value);
                *pvalue = value;
            }
        }
        return 1;
    } else if (PyTuple_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyTuple_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else if (PyList_CheckExact(iter_obj)) {
        Py_ssize_t pos = *ppos;
        if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
        *ppos = pos + 1;
        next_item = PyList_GET_ITEM(iter_obj, pos);
        Py_INCREF(next_item);
    } else
#endif
    {
        next_item = PyIter_Next(iter_obj);
        if (unlikely(!next_item)) {
            return __Pyx_IterFinish();
        }
    }
    if (pitem) {
        *pitem = next_item;
    } else if (pkey && pvalue) {
        if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
            return -1;
    } else if (pkey) {
        *pkey = next_item;
    } else {
        *pvalue = next_item;
    }
    return 1;
}

/* SetItemInt */
        static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* SliceTupleAndList */
          #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* Import */
          static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
          static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* GetItemInt */
          static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* ExtTypeTest */
          static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* PyFloatBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, CYTHON_UNUSED int inplace) {
    const double a = floatval;
    double b, result;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: b = 0.0; break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) (1L<<53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
        }
    } else {
        return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
    }
        PyFPE_START_PROTECT("add", return NULL)
        result = a + b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* WriteUnraisableException */
            static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* GetVTable */
            static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* CodeObjectCache */
            static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
            #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
            #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
            static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
            static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint32_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint32_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
            static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint8_t(uint8_t value) {
    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint8_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint8_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint8_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint8_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
            static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
            static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value) {
    const short neg_one = (short) -1, const_zero = (short) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(short) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(short) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(short) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(short) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(short) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(short),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
            static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
            static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
            static CYTHON_INLINE uint8_t __Pyx_PyInt_As_uint8_t(PyObject *x) {
    const uint8_t neg_one = (uint8_t) -1, const_zero = (uint8_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint8_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint8_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint8_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint8_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint8_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) >= 2 * PyLong_SHIFT) {
                            return (uint8_t) (((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) >= 3 * PyLong_SHIFT) {
                            return (uint8_t) (((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) >= 4 * PyLong_SHIFT) {
                            return (uint8_t) (((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (uint8_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint8_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint8_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint8_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint8_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint8_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint8_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint8_t) (((uint8_t)-1)*(((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint8_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint8_t) ((((((uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint8_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint8_t) (((uint8_t)-1)*(((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint8_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint8_t) ((((((((uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint8_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint8_t) (((uint8_t)-1)*(((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint8_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint8_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint8_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint8_t) ((((((((((uint8_t)digits[3]) << PyLong_SHIFT) | (uint8_t)digits[2]) << PyLong_SHIFT) | (uint8_t)digits[1]) << PyLong_SHIFT) | (uint8_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint8_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint8_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint8_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint8_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (uint8_t) -1;
        }
    } else {
        uint8_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint8_t) -1;
        val = __Pyx_PyInt_As_uint8_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint8_t");
    return (uint8_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint8_t");
    return (uint8_t) -1;
}

/* CIntFromPy */
            static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *x) {
    const short neg_one = (short) -1, const_zero = (short) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(short) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(short, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (short) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (short) 0;
                case  1: __PYX_VERIFY_RETURN_INT(short, digit, digits[0])
                case 2:
                    if (8 * sizeof(short) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 2 * PyLong_SHIFT) {
                            return (short) (((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(short) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 3 * PyLong_SHIFT) {
                            return (short) (((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(short) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) >= 4 * PyLong_SHIFT) {
                            return (short) (((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (short) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(short) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(short) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (short) 0;
                case -1: __PYX_VERIFY_RETURN_INT(short, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(short,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(short) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(short) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                            return (short) ((((((short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(short) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(short) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                            return (short) ((((((((short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(short) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 4 * PyLong_SHIFT) {
                            return (short) (((short)-1)*(((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(short) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(short) - 1 > 4 * PyLong_SHIFT) {
                            return (short) ((((((((((short)digits[3]) << PyLong_SHIFT) | (short)digits[2]) << PyLong_SHIFT) | (short)digits[1]) << PyLong_SHIFT) | (short)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(short) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(short) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(short, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            short val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (short) -1;
        }
    } else {
        short val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (short) -1;
        val = __Pyx_PyInt_As_short(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to short");
    return (short) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to short");
    return (short) -1;
}

/* CIntFromPy */
            static CYTHON_INLINE uint32_t __Pyx_PyInt_As_uint32_t(PyObject *x) {
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint32_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint32_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint32_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint32_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 2 * PyLong_SHIFT) {
                            return (uint32_t) (((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 3 * PyLong_SHIFT) {
                            return (uint32_t) (((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) >= 4 * PyLong_SHIFT) {
                            return (uint32_t) (((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (uint32_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint32_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint32_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint32_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint32_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint32_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint32_t) ((((((uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint32_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint32_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint32_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) (((uint32_t)-1)*(((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint32_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint32_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint32_t) ((((((((((uint32_t)digits[3]) << PyLong_SHIFT) | (uint32_t)digits[2]) << PyLong_SHIFT) | (uint32_t)digits[1]) << PyLong_SHIFT) | (uint32_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint32_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint32_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint32_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (uint32_t) -1;
        }
    } else {
        uint32_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint32_t) -1;
        val = __Pyx_PyInt_As_uint32_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint32_t");
    return (uint32_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint32_t");
    return (uint32_t) -1;
}

/* CIntFromPy */
            static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CheckBinaryVersion */
            static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* ModuleImport */
            #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* TypeImport */
            #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* VoidPtrImport */
            #ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* FunctionImport */
            #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
            static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
  #else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
  #endif
#else
  res = PyNumber_Int(x);
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
