Онлайн-степень MBA в области управления здравоохранением

  1. Метод: извлеките ключевые слова из вопроса, используя методы обработки естественного языка (NLP).

Пример кода:

import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
def extract_keywords(question):
    # Tokenize the question
    tokens = word_tokenize(question)

    # Remove stopwords
    stop_words = set(stopwords.words('english'))
    keywords = [token for token in tokens if token.lower() not in stop_words]

    return keywords
question = "mba healthcare management online degree"
keywords = extract_keywords(question)
print(keywords)

Выход:

['mba', 'healthcare', 'management', 'online', 'degree']

Пример кода:

import itertools
def generate_combinations(keywords):
    combinations = []
    for r in range(1, len(keywords)+1):
        combinations.extend(list(itertools.combinations(keywords, r)))
    return combinations
keyword_combinations = generate_combinations(keywords)
print(keyword_combinations)

Выход:

[('mba',), ('healthcare',), ('management',), ('online',), ('degree',),
 ('mba', 'healthcare'), ('mba', 'management'), ('mba', 'online'), ('mba', 'degree'),
 ('healthcare', 'management'), ('healthcare', 'online'), ('healthcare', 'degree'),
 ('management', 'online'), ('management', 'degree'), ('online', 'degree'),
 ('mba', 'healthcare', 'management'), ('mba', 'healthcare', 'online'), ('mba', 'healthcare', 'degree'),
 ('mba', 'management', 'online'), ('mba', 'management', 'degree'),
 ('mba', 'online', 'degree'), ('healthcare', 'management', 'online'),
 ('healthcare', 'management', 'degree'), ('healthcare', 'online', 'degree'),
 ('management', 'online', 'degree'), ('mba', 'healthcare', 'management', 'online'),
 ('mba', 'healthcare', 'management', 'degree'), ('mba', 'healthcare', 'online', 'degree'),
 ('mba', 'management', 'online', 'degree'), ('healthcare', 'management', 'online', 'degree'),
 ('mba', 'healthcare', 'management', 'online', 'degree')]

Пример кода:

def create_title(keyword_combinations):
    # Select the combination with the highest number of keywords
    title = max(keyword_combinations, key=lambda x: len(x))
    return ' '.join(title)
title = create_title(keyword_combinations)
print(title)

Выход:

mba healthcare management online degree

Пример кода:

def create_tags(keyword_combinations):
    tags = [' '.join(combination) for combination in keyword_combinations]
    return tags
tags = create_tags(keyword_combinations)
print(tags)

Выход:

['mba', 'healthcare', 'management', 'online', 'degree',
 'mba healthcare', 'mba management', 'mba online', 'mba degree',
 'healthcare management', 'healthcare online', 'healthcare degree',
 'management online', 'management degree', 'online degree',
 'mba healthcare management', 'mba healthcare online', 'mba healthcare degree',
 'mba management online', 'mba management degree',
 'mba online degree', 'healthcare management online',
 'healthcare management degree', 'healthcare online degree',
 'management online degree', 'mba healthcare management online',
 'mba healthcare management degree', 'mba healthcare online degree',
 'mba management online degree', 'healthcare management online degree',
 'mba healthcare management online degree']