Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| def classifyA(text): | |
| """ | |
| Extracts labels and scores from the input data, | |
| maps the labels using the provided mapping dictionary, | |
| and returns a list of formatted label-score strings. | |
| """ | |
| from transformers import pipeline | |
| classification = pipeline(task="text-classification", model="Hashuz/AS_MentalQAU", return_all_scores=True) | |
| result = [] | |
| mapping = { | |
| 'info': 'ุชูุฏูู ู ุนููู ุฉ', | |
| 'guid': 'ุชูุฌูู ุฃู ุงุฑุดุงุฏ', | |
| 'support': 'ุฏุนู ููุณู' | |
| } | |
| output = classification(text) | |
| for item in output[0]: | |
| label = item['label'] | |
| label = mapping.get(label) | |
| score = item['score'] | |
| if score > 0.5: | |
| result.append(label) | |
| return ', '.join(result) | |
| def classifyQ(text): | |
| """ | |
| Extracts labels and scores from the input data, | |
| maps the labels using the provided mapping dictionary, | |
| and returns a list of formatted label-score strings. | |
| """ | |
| from transformers import pipeline | |
| classification = pipeline(task="text-classification", model="Hashuz/QT_MentalQA", return_all_scores=True) | |
| result = [] | |
| mapping = { | |
| 'diagnosis': 'ูุญุต', | |
| 'treatment': 'ุนูุงุฌ', | |
| 'anatomy': 'ุงูุชุดุฑูุญ', | |
| 'epidemiology': 'ุงูุฃูุจุฆุฉ', | |
| 'lifestyle': 'ูู ุท ุงูุญูุงุฉ', | |
| 'provider': 'ู ูุฏู ุงูุฎุฏู ุฉ', | |
| 'other': 'ุบูุฑ ู ุญุฏุฏ' | |
| } | |
| output = classification(text) | |
| for item in output[0]: | |
| label = item['label'] | |
| label = mapping.get(label) | |
| score = item['score'] | |
| if score > 0.5: | |
| result.append(label) | |
| return ', '.join(result) | |