| calculate_disease_by_group |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_analysis.py code served (permissive licence) · get_code("4d08d3d7dced2ae0") How it ranRan 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. 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.
import pandas as pd
import numpy as np
# Create sample data structures
medical_dict = {
'diabetes': 0,
'hypertension': 1,
'heart_disease': 2
}
gender_dict = {
'male': 0,
'female': 1,
'other': 2
}
racial_dict = {
'asian': 0,
'black': 1,
'white': 2,
'hispanic': 3
}
drug_dict = {
'aspirin': 0,
'metformin': 1,
'lisinopril': 2
}
# Create a sample dataframe with medical conditions and demographic/drug columns
# Columns: all medical conditions + all gender categories + all racial categories + all drug categories
all_columns = list(medical_dict.keys()) + list(gender_dict.keys()) + list(racial_dict.keys()) + list(drug_dict.keys())
# Create sample data: 5 rows representing patients
data = {
'diabetes': [1, 0, 1, 0, 1],
'hypertension': [1, 1, 0, 1, 0],
'heart_disease': [0, 1, 1, 0, 1],
'male': [1, 0, 1, 1, 0],
'female': [0, 1, 0, 0, 1],
'other': [0, 0, 0, 0, 0],
'asian': [1, 0, 0, 0, 0],
'black': [0, 1, 0, 0, 0],
'white': [0, 0, 1, 1, 0],
'hispanic': [0, 0, 0, 0, 1],
'aspirin': [1, 1, 0, 1, 0],
'metformin': [1, 0, 1, 0, 1],
'lisinopril': [0, 1, 1, 1, 0]
}
stack_dataframe = pd.DataFrame(data)
ARGS = {
'stack_dataframe': stack_dataframe,
'medical_dict': medical_dict,
'gender_dict': gender_dict,
'racial_dict': racial_dict,
'drug_dict': drug_dict
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is 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
|
| calculate_log_softmax_batch_non_seq2seq |
Ran ran, honoured the contract we drafted |
shan23chen/cross-care/logits_generate/hf_model.py code served (permissive licence) · get_code("9a58c6dbe3abe198") How it ranRan 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 torch
import torch.nn as nn
import torch.nn.functional as F
torch.manual_seed(0)
# Create a minimal tokenizer stand-in
class MinimalTokenizer:
def __init__(self):
self.eos_token_id = 2
self.pad_token_id = 2
self.eos_token = '<eos>'
self.padding_side = 'left'
self.pad_token = None
def __call__(self, texts, padding=True, return_tensors=None, return_attention_mask=False):
# Simple tokenization: map each text to token ids
# Return dict with input_ids and attention_mask
batch_size = len(texts)
seq_length = 3
input_ids = torch.randint(0, 10, (batch_size, seq_length))
attention_mask = torch.ones((batch_size, seq_length))
result = {'input_ids': input_ids}
if return_attention_mask:
result['attention_mask'] = attention_mask
return result
# Create a minimal model config stand-in
class MinimalConfig:
def __init__(self):
self.eos_token_id = 2
self.pad_token_id = 2
# Create a minimal model that returns logits
class MinimalModel(nn.Module):
def __init__(self):
super().__init__()
self.config = MinimalConfig()
self.embedding = nn.Embedding(10, 4)
self.linear = nn.Linear(4, 10)
def forward(self, input_ids, attention_mask=None):
# input_ids: (batch_size, seq_length)
# Return object with logits of shape (batch_size, seq_length, vocab_size)
embedded = self.embedding(input_ids) # (batch_size, seq_length, 4)
logits = self.linear(embedded) # (batch_size, seq_length, 10)
class Output:
pass
output = Output()
output.logits = logits
return output
# Prepare arguments
tokenizer = MinimalTokenizer()
model = MinimalModel()
texts = ["hello world", "foo bar"]
device = 'cpu'
ARGS = {
'texts': texts,
'tokenizer': tokenizer,
'model': model,
'device': device
}
- 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 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
|
| co_occurrence_within_window |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_analysis.py code served (permissive licence) · get_code("8bc7cb8d8bef7fc5") How it ranRan 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. 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.
import pandas as pd
from collections import defaultdict
import re
from tqdm import tqdm
# Setup code for co_occurrence_within_window function
# Create small sample data
data = [
"The patient has hypertension and is African American. Treatment includes lisinopril.",
"diabetes diagnosis in female patient. Prescribed metformin for management.",
"Male patient with asthma treated with albuterol inhaler. Hispanic ethnicity noted.",
]
# Create dictionaries of keywords categorized by keys
medical_dict = {
"cardiovascular": ["hypertension", "heart disease"],
"endocrine": ["diabetes", "thyroid"],
"respiratory": ["asthma", "bronchitis"],
}
racial_dict = {
"african_american": ["African American", "Black"],
"hispanic": ["Hispanic", "Latino"],
"caucasian": ["White", "Caucasian"],
}
gender_dict = {
"female": ["female", "woman", "girl"],
"male": ["male", "man", "boy"],
}
drug_dict = {
"antihypertensive": ["lisinopril", "atenolol"],
"antidiabetic": ["metformin", "insulin"],
"bronchodilator": ["albuterol", "salbutamol"],
}
window_size = 5
ARGS = {
"data": data,
"medical_dict": medical_dict,
"racial_dict": racial_dict,
"gender_dict": gender_dict,
"drug_dict": drug_dict,
"window_size": window_size,
"aggregate": True,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is 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
|
| create_keyword_pattern |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occ_analysis.py code served (permissive licence) · get_code("6f934cc1b439e9f8") How it ranRan 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 Pattern. 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.
import re
def create_keyword_pattern(keywords):
"""
Create a regex pattern for keyword matching.
"""
pattern = '(?:(?<=\\W)|(?<=^))(' + '|'.join(map(re.escape, keywords)) + ')(?=\\W|$)'
return re.compile(pattern, re.IGNORECASE)
# Setup code to construct valid arguments
keywords = ['python', 'regex', 'pattern', 'keyword']
ARGS = {
'keywords': keywords
}
- 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 Pattern — a Pattern output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Pattern 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
|
| create_keyword_pattern |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_analysis.py code served (permissive licence) · get_code("dd0d546bb4bf0215") How it ranRan 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 Pattern. 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.
import re
def create_keyword_pattern(keywords):
"""
Create a regex pattern for keyword matching.
Parameters:
keywords (list of str): A list of keywords to create a pattern for.
Returns:
re.Pattern: A compiled regex pattern that matches any of the provided keywords.
"""
pattern = '(?:(?<=\\W)|(?<=^))(' + '|'.join(map(re.escape, keywords)) + ')(?=\\W|$)'
return re.compile(pattern, re.IGNORECASE)
ARGS = {
"keywords": ["python", "regex", "pattern", "matching"]
}
- 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 Pattern — a Pattern output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Pattern 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
|
| create_keyword_pattern |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/jsonl_data_filtering_c4.py code served (permissive licence) · get_code("88ce89805a8ffe04") How it ranRan 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 Pattern. 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.
import re
ARGS = {
'keywords': ['python', 'javascript', 'regex', 'pattern', 'matching']
}
- 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 Pattern — a Pattern output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Pattern 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
|
| extract_total_count_from_message |
Ran ran, honoured the contract we drafted |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_infinigram_document_counts.py code served (permissive licence) · get_code("59281530c199bbdd") How it ranRan 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 int, ndim 0, dtype family int, shape () 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 re
def extract_total_count_from_message(message):
match = re.search('(\\d+) occurrences found', message)
if match:
return int(match.group(1))
else:
return 0
# Test case 1: message with occurrences count
message_with_count = "Search completed: 42 occurrences found in results"
# Test case 2: message without occurrences count
message_without_count = "Search completed: no results found"
# Test case 3: message with multiple numbers but matching pattern
message_multiple_numbers = "Processed 5 files, 123 occurrences found in total"
ARGS = {
'message': message_with_count
}
- 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 int, ndim 0, dtype family int, shape () — shape () 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
|
| find_co_occurrences |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occ_analysis.py code served (permissive licence) · get_code("1194ae31aea58742") How it ranRan 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 dict. 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.
import re
from collections import defaultdict
# Create simple regex patterns for medical, racial, gender, and drug terms
medical_patterns = {
'diabetes': re.compile(r'\bdiabetes\b', re.IGNORECASE),
'hypertension': re.compile(r'\bhypertension\b', re.IGNORECASE),
'multiple myeloma': re.compile(r'\bmultiple\s+myeloma\b', re.IGNORECASE),
}
racial_patterns = {
'African American': re.compile(r'\bAfrican\s+American\b', re.IGNORECASE),
'Caucasian': re.compile(r'\bCaucasian\b', re.IGNORECASE),
}
gender_patterns = {
'male': re.compile(r'\bmale\b', re.IGNORECASE),
'female': re.compile(r'\bfemale\b', re.IGNORECASE),
}
drug_patterns = {
'aspirin': re.compile(r'\baspirin\b', re.IGNORECASE),
'metformin': re.compile(r'\bmetformin\b', re.IGNORECASE),
}
# Create a sample text that contains medical terms and other pattern matches
text = (
"Patient is a 45 year old female with diabetes. "
"She is African American and takes metformin daily. "
"The patient has hypertension and is male according to recent records. "
"Aspirin is recommended for multiple myeloma treatment."
)
window_size = 5
ARGS = {
'text': text,
'medical_patterns': medical_patterns,
'racial_patterns': racial_patterns,
'gender_patterns': gender_patterns,
'drug_patterns': drug_patterns,
'window_size': window_size,
}
- 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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
|
| find_duplicates_in_file |
Ran ran, honoured the contract we drafted |
shan23chen/cross-care/co_occurrence_generate/check_keywords.py code served (permissive licence) · get_code("b894e1ed19d48aea") How it ranRan 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 int; 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 file with Python code that defines a list with duplicates
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.py')
temp_file.write("""
my_list = [1, 2, 3, 2, 4, 1, 5, 3, 2]
""")
temp_file.close()
file_path = temp_file.name
list_name = "my_list"
ARGS = {
"file_path": file_path,
"list_name": list_name,
}
- 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 int — 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
|
| generate_case_variations |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_infinigram.py code served (permissive licence) · get_code("f1d7a3870630867d") How it ranRan 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 set. 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.
import itertools
def generate_case_variations(term):
words = term.split()
variations_set = set()
for combination in itertools.product(*[(word, word.capitalize()) for word in words]):
variations_set.add(' '.join(combination))
variations_set.add(term.lower())
variations_set.add(term.upper())
return variations_set
ARGS = {
"term": "hello world"
}
- 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 set — a set output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a set 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
|
| process_file |
Ran ran on a synthesized input |
shan23chen/cross-care/co_occurrence_generate/jsonl_data_filtering.py code served (permissive licence) · get_code("293bc1ef76e375ef") How it ranRan 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. 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.
import re
from collections import defaultdict
import tempfile
import json
import os
# Create a temporary JSONL file for testing
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")
# Write sample JSONL data
sample_data = [
{
"text": "The patient has diabetes and hypertension. African American male, age 45.",
"meta": {"source": "medical_record", "date": "2023-01-01", "author": "Dr. Smith"}
},
{
"text": "Metformin prescribed for blood glucose control. Patient is Hispanic female.",
"meta": {"source": "prescription", "date": "2023-01-02", "author": "Dr. Jones"}
},
{
"text": "Cancer screening results pending. Asian male patient.",
"meta": {"source": "lab", "date": "2023-01-03", "author": "Dr. Brown"}
}
]
with open(temp_file, 'w', encoding='utf-8') as f:
for entry in sample_data:
f.write(json.dumps(entry) + '\n')
# Compile regex patterns
medical_patterns = {
"diabetes": re.compile(r'\bdiabetes\b', re.IGNORECASE),
"hypertension": re.compile(r'\bhypertension\b', re.IGNORECASE),
"blood_glucose": re.compile(r'\bblood glucose\b', re.IGNORECASE),
"cancer": re.compile(r'\bcancer\b', re.IGNORECASE),
}
racial_patterns = {
"african_american": re.compile(r'\bAfrican American\b', re.IGNORECASE),
"hispanic": re.compile(r'\bHispanic\b', re.IGNORECASE),
"asian": re.compile(r'\bAsian\b', re.IGNORECASE),
}
gender_patterns = {
"male": re.compile(r'\bmale\b', re.IGNORECASE),
"female": re.compile(r'\bfemale\b', re.IGNORECASE),
}
drug_patterns = {
"metformin": re.compile(r'\bMetformin\b', re.IGNORECASE),
"aspirin": re.compile(r'\baspirin\b', re.IGNORECASE),
}
cancer_patterns = {
"cancer_screening": re.compile(r'\bcancer screening\b', re.IGNORECASE),
"tumor": re.compile(r'\btumor\b', re.IGNORECASE),
}
metadata_keys = ["source", "date", "author"]
ARGS = {
"file_path": temp_file,
"medical_patterns": medical_patterns,
"racial_patterns": racial_patterns,
"gender_patterns": gender_patterns,
"drug_patterns": drug_patterns,
"cancer_patterns": cancer_patterns,
"metadata_keys": metadata_keys,
"remove_latex": 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 tuple — a tuple output has no array shape of its own; none is 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
|
| process_file |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/jsonl_data_filtering_c4.py code served (permissive licence) · get_code("fe4d91f2f027fe4e") How it ranRan 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. 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.
import re
from collections import defaultdict
import tempfile
import json
import os
# Create a temporary JSONL file for testing
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")
# Write sample JSONL data
sample_data = [
{
"text": "The patient has diabetes and hypertension. They are of African descent.",
"meta": {"source": "medical_db", "year": 2023}
},
{
"text": "Clinical notes: symptoms include fever and cough.",
"meta": {"source": "hospital", "year": 2022}
},
{
"text": "Patient presented with \\LaTeX command test.",
"meta": {"source": "research", "year": 2023}
}
]
with open(temp_file, 'w', encoding='utf-8') as f:
for item in sample_data:
f.write(json.dumps(item) + '\n')
# Compile regex patterns
medical_patterns = {
'diabetes': re.compile(r'diabetes', re.IGNORECASE),
'hypertension': re.compile(r'hypertension', re.IGNORECASE),
'fever': re.compile(r'fever', re.IGNORECASE),
'cough': re.compile(r'cough', re.IGNORECASE),
}
racial_patterns = {
'african': re.compile(r'african', re.IGNORECASE),
'european': re.compile(r'european', re.IGNORECASE),
}
gender_patterns = {
'male': re.compile(r'male', re.IGNORECASE),
'female': re.compile(r'female', re.IGNORECASE),
}
metadata_keys = ['source', 'year']
ARGS = {
'file_path': temp_file,
'medical_patterns': medical_patterns,
'racial_patterns': racial_patterns,
'gender_patterns': gender_patterns,
'metadata_keys': metadata_keys,
'remove_latex': 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 tuple — a tuple output has no array shape of its own; none is 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
|
| remove_latex_commands |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/jsonl_data_filtering.py code served (permissive licence) · get_code("c4a0e7d1de5f3a1c") How it ranRan 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.
import re
def remove_latex_commands(s):
"""
Remove LaTeX commands from a string.
Parameters:
s (str): The input string.
Returns:
str: The string with LaTeX commands removed.
"""
s = re.sub('\\\\[nrt]|[\\n\\r\\t]', ' ', s)
s = re.sub('\\\\[a-zA-Z]+', '', s)
s = re.sub('\\\\.', '', s)
s = re.sub('\\\\begin\\{.*?\\}.*?\\\\end\\{.*?\\}', '', s, flags=re.DOTALL)
s = re.sub('\\$.*?\\$', '', s)
s = re.sub('\\\\[.*?\\\\]', '', s)
s = re.sub('\\\\\\(.*?\\\\\\)', '', s)
s = re.sub('\\\\\\[.*?\\\\\\]', '', s)
s = re.sub('(?<=\\W)\\\\|\\\\(?=\\W)', '', s)
return s.strip()
# Test input with various LaTeX commands
test_string = r"This is \textbf{bold} and \emph{italic} text. Also \$x^2\$ math and \begin{equation}E=mc^2\end{equation} and \[integral\] content."
ARGS = {
"s": test_string
}
- 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
|
| remove_latex_commands |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/co_occurrence_generate/jsonl_data_filtering_c4.py code served (permissive licence) · get_code("a56f744d089c3d45") How it ranRan 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.
import re
def remove_latex_commands(s):
"""
Remove LaTeX commands from a string.
Parameters:
s (str): The input string.
Returns:
str: The string with LaTeX commands removed.
"""
s = re.sub('\\\\[nrt]|[\\n\\r\\t]', ' ', s)
s = re.sub('\\\\[a-zA-Z]+', '', s)
s = re.sub('\\\\.', '', s)
s = re.sub('\\\\begin\\{.*?\\}.*?\\\\end\\{.*?\\}', '', s, flags=re.DOTALL)
s = re.sub('\\$.*?\\$', '', s)
s = re.sub('\\\\[.*?\\\\]', '', s)
s = re.sub('\\\\\\(.*?\\\\\\)', '', s)
s = re.sub('\\\\\\[.*?\\\\\\]', '', s)
s = re.sub('(?<=\\W)\\\\|\\\\(?=\\W)', '', s)
return s.strip()
# Test string with various LaTeX commands
test_string = r"""
This is a \textbf{bold} text with \emph{emphasis}.
Math: $x^2 + y^2 = z^2$ and \[ a + b = c \].
Environment: \begin{equation}E=mc^2\end{equation}
Special chars: \n \r \t and \\command with \dots.
Inline math: \(f(x) = x^2\) here.
"""
ARGS = {
's': test_string
}
- 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
|
| search_documents_count |
Ran ran on a synthesized input |
shan23chen/cross-care/co_occurrence_generate/disease_document_count_infinigram.py code served (permissive licence) · get_code("94cf61296c1ba3b8") How it ranRan 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 dict. 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.
import requests
from unittest.mock import Mock, patch
import re
# Mock the requests.post to avoid actual network calls
def mock_search_documents_for_corpus(term, corpus, maxnum=10):
"""Mock the API response"""
mock_response = Mock()
mock_response.status_code = 200
mock_response.json.return_value = {
'message': f'Found 42 occurrences found in {corpus}',
'documents': []
}
return mock_response
# Set up ARGS for search_documents_count function
ARGS = {
'term': 'machine learning',
'corpora': ['v4_piletrain_llama'],
'maxnum': 10
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- requests — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
|
| tokenize_for_seq2seq |
Ran ran; our contract draft was wrong, not the code |
shan23chen/cross-care/logits_generate/hf_model.py code served (permissive licence) · get_code("f855d60484b63f8c") How it ranRan 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
torch.manual_seed(0)
# Stand-in tokenizer class with required attributes and methods
class StandInTokenizer:
def __init__(self):
self.eos_token_id = 2
self.pad_token = '<pad>'
self.eos_token = '<eos>'
self.padding_side = 'left'
def __call__(self, texts, return_tensors=None, padding=False, truncation=False,
max_length=None, add_special_tokens=False, return_attention_mask=False):
# Return a dict-like object with input_ids and attention_mask
batch_size = len(texts) if isinstance(texts, list) else 1
result = {
'input_ids': torch.randint(0, 100, (batch_size, 10)),
'attention_mask': torch.ones((batch_size, 10))
}
# Add a to() method to the result dict
class TokenizerOutput:
def __init__(self, data):
self.data = data
def __getitem__(self, key):
return self.data[key]
def to(self, device):
return self
return TokenizerOutput(result)
def as_target_tokenizer(self):
# Context manager that does nothing
class ContextManager:
def __enter__(self):
return self
def __exit__(self, *args):
pass
return ContextManager()
# Stand-in config class
class StandInConfig:
def __init__(self):
self.eos_token_id = 2
self.pad_token_id = 2
# Stand-in model class
class StandInModel(nn.Module):
def __init__(self):
super().__init__()
self.config = StandInConfig()
self.linear = nn.Linear(4, 4)
def to(self, device):
return super().to(device)
# Create instances
model = StandInModel()
tokenizer = StandInTokenizer()
device = 'cpu'
texts = ['Hello world', 'This is a test']
target_text = '1'
ARGS = {
'texts': texts,
'model': model,
'tokenizer': tokenizer,
'device': device,
'target_text': target_text
}
- 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 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
|
| calculate_log_softmax_batch_seq2seq |
Not yet run unverified (harvested, no recorded run) |
shan23chen/cross-care/logits_generate/hf_model.py code served (permissive licence) · get_code("23ba4360a5bd3294") How it ran |
| count_term |
Not yet run unverified (harvested, no recorded run) |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_infinigram.py code served (permissive licence) · get_code("4ea6258eabae7b12") How it ran |
| process_texts_in_parallel |
Not yet run unverified (harvested, no recorded run) |
shan23chen/cross-care/co_occurrence_generate/co_occ_analysis.py code served (permissive licence) · get_code("8d57c440e1ad8631") How it ran |
| search_documents_for_corpus |
Not yet run unverified (harvested, no recorded run) |
shan23chen/cross-care/co_occurrence_generate/co_occurrence_infinigram_document_counts.py code served (permissive licence) · get_code("bf0bc2de96cec2ca") How it ran |