Update
Browse filesFiles changed (2)
- inspired_unicrs.py+17-2
- utils.py-16
12345678import jsonfrom typing import Listimport datasetsfrom .utils import markup_entitylogger = datasets.logging.get_logger(__name__)1234567891011121314151617181920212223import jsonfrom typing import Listimport datasetsimport reENTITY = 'entity'ENTITY_PATTERN = r'<entity> {} </entity>'def markup_entity(utt: str, entities: List[str]):# If entities like "action movie" and "action" appear at the same time, we only mark the longer oneentities = sorted(list(set(entities)), key=lambda x: len(x), reverse=True)for i, entity in enumerate(entities):valid = entity not in ENTITYfor prev in entities[:i]:if entity in prev:valid = Falseif valid:utt = re.sub(entity, ENTITY_PATTERN.format(entity), utt)return uttlogger = datasets.logging.get_logger(__name__)
4 unmodified lines5678910111213141516171819202122232425264 unmodified linesfrom datasets import load_dataset, Value, Sequenceimport jsonENTITY = 'entity'ENTITY_PATTERN = r'<entity> (.*?) </entity>'def markup_entity(utt: str, entities: List[str]):# If entities like "action movie" and "action" appear at the same time, we only mark the longer oneentities = sorted(list(set(entities)), key=lambda x: len(x), reverse=True)for i, entity in enumerate(entities):valid = entity not in ENTITYfor prev in entities[:i]:if entity in prev:valid = Falseif valid:utt = re.sub(entity, ENTITY_PATTERN.format(entity), utt)return uttdef print_dataset_info(dataset):# Print the featuresprint("features:")4 unmodified lines56789104 unmodified linesfrom datasets import load_dataset, Value, Sequenceimport jsondef print_dataset_info(dataset):# Print the featuresprint("features:")
inspired_unicrs.py+17-2
utils.py-16