def analyze_field_tag(self, doc_unified: str, tag: str): """ Given a unified document title and a tag, tries to identify a research field Updates references accordingly :param doc_unified: :param tag: :return: """ if not is_field_tag(tag): return # Build the unified name of the found research field tag field_unified, field_real = unify_field_title(tag) # Check if that research field already exists if field_unified in self._unified_field_title_to_field: # If yes check if it (CacheField) needs to be updated existing_field = self._unified_field_title_to_field[field_unified] if len(existing_field.title) < len(field_real): existing_field.title = field_real existing_field_docs = self._unified_field_title_to_documents[ field_unified] existing_field_docs.add(doc_unified) else: # If not add a new CacheField and create a new list for field_to_docs self._unified_field_title_to_field[field_unified] = CacheField( title=field_real, unified_title=field_unified) field_documents = set() field_documents.add(doc_unified) self._unified_field_title_to_documents[ field_unified] = field_documents
def analyze_field_tag(self, doc_unified: str, tag: str): """ Given a unified document title and a tag, tries to identify a research field Updates references accordingly :param doc_unified: :param tag: :return: """ if not is_field_tag(tag): return # Build the unified name of the found research field tag field_unified, field_real = unify_field_title(tag) # Check if that research field already exists if field_unified in self._unified_field_title_to_field: # If yes check if it (CacheField) needs to be updated existing_field = self._unified_field_title_to_field[field_unified] if len(existing_field.title) < len(field_real): existing_field.title = field_real existing_field_docs = self._unified_field_title_to_documents[field_unified] existing_field_docs.add(doc_unified) else: # If not add a new CacheField and create a new list for field_to_docs self._unified_field_title_to_field[field_unified] = CacheField( title=field_real, unified_title=field_unified) field_documents = set() field_documents.add(doc_unified) self._unified_field_title_to_documents[field_unified] = field_documents
def test_is_field_tag(self): self.assertTrue(is_field_tag("cyber-physical-systems"))