<jupyter_start><jupyter_text><jupyter_code>!pip install git+https://github.com/LIAAD/yake
import yake
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
text = pd.read_csv("/content/drive/MyDrive/Education_ISCB/Bioschemas/ISCB_events.csv")
text['abstract'] = text['abstract'].astype('string')
language = "en"
max_ngram_size = 2
deduplication_threshold = 0.3
deduplication_algo = 'seqm'
windowsSize=1
numOfKeywords = 5

custom_kw_extractor = yake.KeywordExtractor(lan=language, 
                                            n=max_ngram_size, 
                                            dedupFunc=deduplication_algo, dedupLim=deduplication_threshold,
                                            top=numOfKeywords, 
                                            features=None)
#keywords = custom_kw_extractor.extract_keywords(abstract)

extract_keywords = lambda x: ', '.join(k[0] for k in custom_kw_extractor.extract_keywords(x))

text['TopKeyword'] = text['abstract'].apply(extract_keywords)

text.to_csv('/content/drive/MyDrive/Education_ISCB/Bioschemas/keywords.csv') 

text.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10877192982456141, 'fraction_numerical': 0.005263157894736842, 'mean_word_length': 3.075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '666258', 'license': 'MIT', 'n_tokens_mistral': 364, 'n_tokens_neox': 344, 'n_words': 50, 'path': 'key_words.ipynb', 'repo_name': 'ISCB-Academy/keywords', 'size': '1140'}