Download scripts/Helper/counter.py from FiendHunter/Github_bot_scripts: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/datasets/FiendHunter/Github_bot_scripts/resolve/9f045d9a99d37ef16bb0bc285b184bc0d8cb618a/scripts/Helper/counter.py
- Command line
-
hf download hf://datasets/FiendHunter/Github_bot_scripts@9f045d9a99d37ef16bb0bc285b184bc0d8cb618a/scripts/Helper/counter.py
-
curl -L -o counter.py https://huggingface.co/datasets/FiendHunter/Github_bot_scripts/resolve/9f045d9a99d37ef16bb0bc285b184bc0d8cb618a/scripts/Helper/counter.py
1.45 kB
| import pandas as pd | |
| # Read the CSV, forcing it into a single column by specifying an unusual separator | |
| df = pd.read_csv(r'C:\Users\91745\OneDrive\Desktop\Github_analyser\output\local_repo\final_repo\llamaedge_repopack.csv', sep='\n', header=None) | |
| # Rename the column to 'Content' | |
| df.columns = ['Content'] | |
| # Define the word count function | |
| def count_words(text): | |
| if isinstance(text, str): | |
| return len(text.split()) | |
| else: | |
| return 0 | |
| # Apply the word count function and add the result as a new column | |
| df['Content_Word_Count'] = df['Content'].apply(count_words) | |
| # Write to a new CSV without headers | |
| df.to_csv('wasmedge_quickjs.csv', index=False, header=False) | |
| ''' | |
| import pandas as pd | |
| from transformers import AutoModel | |
| model = AutoModel.from_pretrained("Xenova/gpt-4") | |
| tokenizer = GPT2TokenizerFast.from_pretrained('Xenova/gpt-4') | |
| df = pd.read_csv('/home/aru/Desktop/Github_analyser/Output/summary/eth_md_summary.csv') | |
| def count_words(text): | |
| return len(text.split()) | |
| def count_tokens(text): | |
| tokens = tokenizer.encode(text) | |
| return len(tokens) | |
| df['Content_Word_Count'] = df['Content'].apply(count_words) | |
| df['Summary_QnA_Word_Count'] = df['Summary and Q&A'].apply(count_words) | |
| df['Content_Token_Count'] = df['Content'].apply(count_tokens) | |
| df['Summary_QnA_Token_Count'] = df['Summary and Q&A'].apply(count_tokens) | |
| df.to_csv('output_file.csv', index=False) | |
| ''' |