SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2021.acl-long.205 · ACL · 2021

N -ary Constituent Tree Parsing with Recursive Semi-Markov Model

Jinlong Li, Zeqi Tan, Xin Xin

Code that ran

6 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-24; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2021.acl-long.205.json · badge: /api/ran/2021.acl-long.205.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
NP-NET-research/Recursive-Semi-Markov-Model canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
FunctionStatusWhere it lives
arabic Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/transliterate.py
code served (permissive licence) · get_code("c6fbc9f36f128a4d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for arabic() function

ARGS = {
    'inp': 'bism'
}

# Test with a Buckwalter escape sequence
ARGS_ESCAPED = {
    'inp': '-LRB-test-RRB-'
}

# Test with mixed content
ARGS_MIXED = {
    'inp': "b'Asoma"
}

# Primary test case
ARGS = {
    'inp': 'bism'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_bert Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/transformer.py
code served (permissive licence) · get_code("ed72beb4515f20ac")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import Mock, MagicMock

torch.manual_seed(0)

class MockBertTokenizer:
    """Stand-in for BertTokenizer"""
    def __init__(self):
        self.vocab_size = 30522
    
    @classmethod
    def from_pretrained(cls, model_name, do_lower_case=True):
        return cls()

class MockBertModel(nn.Module):
    """Stand-in for BertModel"""
    def __init__(self):
        super().__init__()
        self.embeddings = nn.Embedding(30522, 768)
    
    @classmethod
    def from_pretrained(cls, model_name):
        return cls()
    
    def forward(self, input_ids):
        return self.embeddings(input_ids)

# Mock the transformers module imports in the function
import sys
from unittest.mock import MagicMock

mock_transformers = MagicMock()
mock_transformers.BertTokenizer = MockBertTokenizer
mock_transformers.BertModel = MockBertModel

sys.modules['transformers'] = mock_transformers

ARGS = {
    'bert_model': 'bert-base-uncased',
    'bert_do_lower_case': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
hebrew Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/transliterate.py
code served (permissive licence) · get_code("98db1b220dd2ecb7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for the hebrew function

ARGS = {
    'inp': 'ABGH'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_trees Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/trees.py
code served (permissive licence) · get_code("5aa11900408131f7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os

# Create a temporary treebank file with sample parse trees
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("""(TOP (S (NP (DT The) (NN cat)) (VP (VBZ sits))))
(TOP (S (NP (DT A) (NN dog)) (VP (VBZ runs))))
""")
temp_file.close()

ARGS = {
    'path': temp_file.name,
    'strip_top': True,
    'strip_spmrl_features': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
my_gen_clique_spans Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/myutil.py
code served (permissive licence) · get_code("7fc3c5f80977977a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for my_gen_clique_spans

def my_gen_clique_spans(span_list):
    start_2_goldspan = {}
    end_2_goldspan = {}
    max_right = -1
    for span in span_list:
        left, right, label = span
        if right > max_right:
            max_right = right
        if start_2_goldspan.get(left) is None:
            start_2_goldspan[left] = []
        if end_2_goldspan.get(right) is None:
            end_2_goldspan[right] = []
        start_2_goldspan.get(left).append((left, right, label))
        end_2_goldspan.get(right).append((left, right, label))
    gold_index = []
    for i in range(1, max_right):
        if start_2_goldspan.get(i) is not None and end_2_goldspan.get(i) is not None:
            spans_start = start_2_goldspan.get(i)
            spans_end = end_2_goldspan.get(i)
            max_start_spn = None
            max_start_lbl = None
            tmp_len = 0
            for span in spans_start:
                left, right, label = span
                if right - left > tmp_len:
                    tmp_len = right - left
                    max_start_spn = (left, right)
                    max_start_lbl = label
            max_end_spn = None
            max_end_lbl = None
            tmp_len = 0
            for span in spans_end:
                left, right, label = span
                if right - left > tmp_len:
                    tmp_len = right - left
                    max_end_spn = (left, right)
                    max_end_lbl = label
            gold_index.append((max_end_spn[0], max_start_spn[0], max_start_spn[1], max_end_lbl, max_start_lbl))
    return gold_index

# Construct valid span_list
# Each span is (left, right, label) where left < right
span_list = [
    (1, 3, "NP"),
    (1, 5, "VP"),
    (2, 4, "DET"),
    (3, 5, "VERB"),
]

ARGS = {
    "span_list": span_list,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
my_index_select Ran
ran on a synthesized input
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/myutil.py
code served (permissive licence) · get_code("555c069dea95c889")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct a small data tensor
# Shape: (2, 3, 4) - 2 batches, 3 rows, 4 columns
data = torch.randn(2, 3, 4)

# Construct index tensor
# ixs should have last dimension matching number of index dimensions we want
# For indexing into first 2 dimensions of data, we need ixs.size(-1) = 2
# Shape: (2, 2) - 2 indices, each with 2 coordinates
ixs = torch.tensor([[0, 1], [1, 2]], dtype=torch.long)

ARGS = {
    'data': data,
    'ixs': ixs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tree_from_str Not yet run
unverified (harvested, no recorded run)
NP-NET-research/Recursive-Semi-Markov-Model/src_cn/trees.py
code served (permissive licence) · get_code("1be51ebb6a7c65f5")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
arabic 3 other papers
3 dated earlier
1805.01052 (2018-05)
Constituency Parsing with a Self-Attentive Encoder
1812.11760 (2018-12)
Multilingual Constituency Parsing with Self-Attention and Pre-Training
1907.02684 (2019-07)
Head-Driven Phrase Structure Grammar Parsing on Penn Treebank
hebrew 3 other papers
3 dated earlier
1805.01052 (2018-05)
Constituency Parsing with a Self-Attentive Encoder
1812.11760 (2018-12)
Multilingual Constituency Parsing with Self-Attention and Pre-Training
1907.02684 (2019-07)
Head-Driven Phrase Structure Grammar Parsing on Penn Treebank
tree_from_str 1 other paper
1 dated earlier
1805.01052 (2018-05)
Constituency Parsing with a Self-Attentive Encoder

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In this paper, we study the task of graph-based constituent parsing in the setting that binarization is not conducted as a pre-processing step, where a constituent tree may consist of nodes with more than two children. Previous graphbased methods on this setting typically generate hidden nodes with the dummy label inside the n-ary nodes, in order to transform the tree into a binary tree for prediction. The limitation is that the hidden nodes break the sibling relations of the n-ary node's children. Consequently, the dependencies of such sibling constituents might not be accurately modeled and is being ignored. To solve this limitation, we propose a novel graph-based framework, which is called "recursive semi-Markov model". The main idea is to utilize 1-order semi-Markov model to predict the immediate children sequence of a constituent candidate, which then recursively serves as a child candidate of its parent. In this manner, the dependencies of sibling constituents can be described by 1-order transition features, which solves the above limitation. Through experiments, the proposed framework obtains the F1 of 95.92% and 92.50% on the datasets of PTB and CTB 5.1 respectively. Specially, the recursive semi-Markov model shows advantages in modeling nodes with more than two children, whose average F1 can be improved by 0.3-1.1 points in PTB and 2.3-6.8 points in CTB 5.1.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2021.acl-long.205")
get_code_for_paper("2021.acl-long.205")
have("2021.acl-long.205")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2021.acl-long.205.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2021.acl-long.205.svg)](https://syntology.ai/paper/2021.acl-long.205)

Connect an agent — have() is free.