Count number of relations (hops) in input_text.
(input_text)
| 114 | |
| 115 | |
| 116 | def 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 | |
| 124 | def train_model(model, dataloader, test_dataloader, args, test_type, start_epoch=0, start_time=time.time(), |
no outgoing calls
no test coverage detected