MCPcopy
hub / github.com/nltk/nltk / _remove_variables

Function _remove_variables

nltk/featstruct.py:1307–1324  ·  view source on GitHub ↗
(fstruct, fs_class, visited)

Source from the content-addressed store, hash-verified

1305
1306
1307def _remove_variables(fstruct, fs_class, visited):
1308 if id(fstruct) in visited:
1309 return
1310 visited.add(id(fstruct))
1311
1312 if _is_mapping(fstruct):
1313 items = list(fstruct.items())
1314 elif _is_sequence(fstruct):
1315 items = list(enumerate(fstruct))
1316 else:
1317 raise ValueError("Expected mapping or sequence")
1318
1319 for fname, fval in items:
1320 if isinstance(fval, Variable):
1321 del fstruct[fname]
1322 elif isinstance(fval, fs_class):
1323 _remove_variables(fval, fs_class, visited)
1324 return fstruct
1325
1326
1327######################################################################

Callers 1

remove_variablesFunction · 0.85

Calls 4

_is_mappingFunction · 0.85
_is_sequenceFunction · 0.85
itemsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…