MCPcopy Create free account
hub / github.com/OSU-NLP-Group/Loop-Think-Generalize / count_hops

Function count_hops

train_extrapolation.py:116–121  ·  view source on GitHub ↗

Count number of relations (hops) in input_text.

(input_text)

Source from the content-addressed store, hash-verified

114
115
116def count_hops(input_text):
117 """Count number of relations (hops) in input_text."""
118 token_pattern = re.compile(r'<[^>]+>')
119 tokens = token_pattern.findall(input_text)
120 # First token is entity, rest are relations
121 return len(tokens) - 1
122
123
124def train_model(model, dataloader, test_dataloader, args, test_type, start_epoch=0, start_time=time.time(),

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected