# ChatGPT
>ChatGPT(Chat Generative Pre-trained Transformer)由OpenAI開發的一個聊天AI,在2022年11月推出;基於GPT-3.5架構建造。
#### ChatGPT 在今年(2023年),對人類社會帶來了可謂“奇異點”般的改變,他的出現,讓有的人開始思考會不會被取代;也讓有的人利用來更快速完成自己的工作,所以,他對人類的未來有什麼影響?
## 程式碼編譯方面
>ChatGPT 能夠幫助工程師進行簡易的程式碼編譯,但很顯然的,他編譯的程式碼如涉及到硬體(如:Arduino...),或生成App(如:以Xcode進行操作),很可能發生失誤,需要工程師進行手動排除;但就效率來說,還是比從頭思考框架並進行編譯來的方便。
>但如果以進行類似Apcs題目的解題來說,ChatGPT效率遠超一般人,如以下:
``` python=
article=list(map(str,input().split(" "))) #map函數+split函數
article.sort() #sort排列
delete=[',','.','?','!',':',';','\'s','\'t','n\'t','\'ll','\'d','\"','\'','\'re','\'ve','\'m'] #要刪除的字元
word=[] #儲存單字種類
num=[] #儲存單字數量
x=-1
for i in article:
i=i.lower() #變成小寫
for u in delete:
i=i.replace(u,"") #刪除字元
if i not in word:
x+=1
word.append(i) #增加單字種類
num.append(1) #設定單字數量(1)
else:
num[x]+=1 #增加單字數量
artdict=dict(zip(word,num)) #做成Dictionary
artdict=sorted(artdict.items(), key=lambda y:(-y[1],y[0]) #排序
print('前十名為:')
for i in range(10):
print(f"第{i+1}名:{artdict[i][0]} {artdict[i][1]}個")
```
> 以上是我一個學弟花了約完整一天(? 的時間,上網查資料並自行整合成的程式碼
``` python =
import re
import collections
import nltk
nltk.download('punkt')
def get_word_freq(text):
# 刪除特殊符號
text = re.sub(r'[^\w\s]', ' ', text)
# 將單字轉換為小寫
text = text.lower()
# 斷詞
words = nltk.word_tokenize(text)
# 去除停用詞
stopwords = nltk.corpus.stopwords.words('english')
words = [word for word in words if word not in stopwords]
# 計算單字頻率
word_freq = collections.Counter(words)
return word_freq
if __name__ == '__main__':
# 讀取文本檔案
with open('article.txt', 'r') as f:
text = f.read()
# 計算單字頻率
word_freq = get_word_freq(text)
# 列出前十名單字
top_words = word_freq.most_common(10)
for i, word in enumerate(top_words):
print('{0}: {1} - {2}'.format(i+1, word[0], word[1]))
#請將程式儲存為word_freq.py,並且將要統計的文章放在與程式同一目錄下,並以article.txt作為檔名。程式執行後,會輸出出現頻率前十名的單字及其出現次數。
```
#### 以上是ChatGPT在10秒內輸出的內容,運用多個函式庫,程式碼也相對簡潔;可以看出,在處理這種簡單的程式問題時,利用這種“工具”,能更快速的完成工作
#### 尤其,在製作規模龐大的專題時,他能幫你處理零碎的部件,讓你能專心解決核心問題
## 文章生成
## 資料整理