笑話生成器_爸爸笑話發生器

笑話生成器

(If you’re just here for the generated jokes, scroll down to the bottom!)

(如果您只是在這里生成笑話,請向下滾動到底部!)

I thought: what is super easy to build, yet would still get an approving chuckle if someone found it on my github page? Obviously, a Dad Joke generator.

我以為:什么是超級容易構建的,但是如果有人在我的github頁面上找到它,仍然會發出歡笑嗎? 顯然,是爸爸的笑話發生器。

The first thing I did, was think: how exactly do dad jokes work? Let’s make up a few random dad jokes (these are pretty good, right?):

我做的第一件事是想:爸爸的笑話到底是如何工作的? 讓我們彌補一些隨機的父親笑話(這些都很好,對吧?):

What do you call a greedy animal living in the sea?
A selfish.Which australian animal is known for it’s southern hospitality?
A koalabamaWhat do you call a freezing, chicken-like creature?
A cold turkey.

Alright, so let’s try to create three types of jokes that follow this pattern.

好吧,讓我們嘗試創建遵循這種模式的三種笑話。

第1部分:數據集 (Part 1: The dataset)

I first tried to create a dataset of words and their definitions. My first instinct was to take a dictionary, but dictionary results are much too technical and, frankly, confusing. Look at this example for fish:

我首先嘗試創建單詞及其定義的數據集。 我的第一個本能是拿一本字典,但是字典的結果太技術性了,坦率地說,令人困惑。 看一下這個魚的例子:

fishany of various cold-blooded, aquatic vertebrates, having gills, commonly fins, and typically an elongated body covered with scales.(loosely) any of various other aquatic animals.the flesh of fishes used as food.(Informal) a person.a long strip of wood, iron, etc., used to strengthen a mast, joint, etc.

捕撈各種冷血,水生脊椎動物中的任何一種,具有g,通常為鰭,并且通常是被鱗片覆蓋的細長體。(疏松地)其他各種水生動物中的任何一種。 (非正式)一個人。 用來加固桅桿,接頭等的長條木頭,鐵等。

Alright, so how about wikipedia?

好了,那么維基百科呢?

Fish are gill-bearing aquatic craniate animals that lack limbs with digits

是g的水生cr動物,四肢沒有手指

Okay, so then my “selfish” joke would become something like:

好吧,這樣我的“自私”笑話就會變成:

What is greedy and are gill-bearing aquatic craniate animals that lack limbs with digits?
A sel-fish

That’s still a bit too technical for me. So where could I find descriptions of words that even a child would understand? Well, by using a children’s dictionary of course!

對我來說,這仍然有點技術性。 那么我在哪里可以找到甚至是孩子都能理解的單詞描述呢? 好吧,當然要使用兒童詞典 !

Fish: an animal that lives in water and has fins for swimming and gills for breathing

:生活在水中的動物,有鰭,可以游泳,g可以呼吸

That’s just perfect! That would turn my joke into:

太完美了! 那會把我的笑話變成:

What is greedy and an animal that lives in water and has fins for swimming and gills for breathing?
A sel-fish

Alright, that’s good enough. I created a dataset of words by scraping about 2000 words from that children’s dictionary to generate something like this:

好吧,這已經足夠了。 我通過從該兒童字典中抓取大約2000個單詞來生成單詞的數據集,以生成如下內容:

length:noun:the distance from one end of a thing to the other.
good:adjective:having qualities that are desired.
dog:noun:a furry animal with four legs, a pointed nose, and a tail.
prisoner:noun:a person who is held in a jail or prison while on trial or after being sentenced for a crime.
Image for post
What do you call a greedy animal living in the sea?
您怎么稱呼生活在海中的貪婪的動物?

第2部分:捉到一條小魚 (Part 2: Catching a sel-fish)

Okay, so now that we have a dataset, the first type of joke was pretty simple: looking at all possible pairs of our words, find words that end or start with the other word.

好的,現在我們有了數據集,第一個笑話類型非常簡單:查看所有可能的單詞對,找到以另一個單詞開頭或結尾的單詞。

for word1,desc1 in words:
for word2,desc2 in words:
if word2.startswith(word2):
print(f"What do you call a kind of {word1} that is {desc2}?")
print(f"a {word1+word2}")

Which generated something like this:

生成如下內容:

What do you call a kind of leg that is a group of people within a government that has the power to make or change laws?
A legislature

This wasn’t really working for me, and I also suddenly realized that joke 1 and joke 2 actually followed the same pattern: overlap between the words (whether whole or partial). So instead I wrote something that combined both.

這對我來說并不是真正的工作,我也突然意識到笑話1和笑話2實際上遵循相同的模式:單詞之間重疊(無論是整體還是局部)。 因此,我寫了一些結合了兩者的東西。

第3部分:去koalabama (Part 3: Going to koalabama)

Alright, so both for “koalabama” and for “selfish”, the key is that they have overlapping parts of the words. The only difference is that for selfish, the word “fish” is entire part of the word “selfish”, whereas “koala” and “alabama” both have characters that are not in the other word.

好吧,所以對于“ koalabama”和“自私”來說,關鍵是它們的單詞具有重疊部分。 唯一的區別是,為了自私,“魚”一詞是“自私”一詞的整個部分,而“考拉”和“阿拉巴馬”都具有另一個詞中沒有的字符。

Regardless, I rewrote the logic a little bit to something like this:

無論如何,我將邏輯改寫成這樣的東西:

for word1,desc1 in words:
for word2,desc2 in words:
if overlap(word1, word2):
print(f"What do you call a kind of {word1} that is {desc2}?")
print(f"a {combine(word1, word2)}")

Which yielded this:

結果如下:

What do you call a kind of energy that is a tiny section of a chromosome?
A genenergyWhat do you call a kind of tail that is a small item; a particular?
A detailWhat do you call a kind of anniversary that is a polite and honorable man?
A gentlemanniversaryWhat do you call a kind of era that is a play in which all or most of the words are sung and the music is played by an orchestra?
An opera

Alright, that’s working! the jokes are pretty lame, but that’s what dad jokes are supposed to be.

好吧,那很好! 這些笑話很la腳,但這就是爸爸的笑話。

Image for post
What do you call a freezing, chicken-like creature?
你怎么稱呼像雞的冰凍生物?

第四部分:去火雞 (Part 4: Going cold turkey)

So that's two of our first jokes tackled, let's tackle the third one. The funny thing about a “cold turkey” is that, aside from being “cold” and a “turkey”, it’s also something else entirely. So what we’re looking for is a set of words which together have another, third meaning.

這是我們解決的第一個笑話,其中兩個是我們解決的第三個笑話。 關于“冷火雞”的有趣之處在于,除了“冷”和“火雞”外,它還完全是另外一回事。 因此,我們正在尋找的是一組具有另一種第三種含義的單詞。

Given our limited dataset, let’s see what words we can combine to find a third word that is also in the data:

給定有限的數據集,讓我們看看可以組合哪些詞以找到數據中的第三個詞:

cat fish catfish
door way doorway
life time lifetime
share holder shareholder
frame work framework
cup board cupboard
fire wood firewood
mess age message
pass age passage
work shop workshop
percent age percentage
bed room bedroom
car pet carpet
rail way railway
cover age coverage
class room classroom
land lord landlord
sea lion sea lion
sea son season
blue whale blue whale
birth day birthday
rain forest rain forest
bath room bathroom
week end weekend

Okay, not so many combinations there, but we can create jokes with them, and increase the size of the dataset later. This is the pseudocode that I used to create the next jokes:

好的,那里沒有太多組合,但是我們可以用它們創建笑話,并在以后增加數據集的大小。 這是我用來創建下一個笑話的偽代碼:

for word1,desc1 in words:
for word2,desc2 in words:
for mix in [word1+word2, word1+"-"+word2, word1+" "+word2]:
if mix in words:
print(f"What do you call {combined_desc(desc1, desc2)}?")
print(f"a {mix}")

Which resulted in:

結果是:

What do you call a small, furry mammal with whiskers, short ears, and a long tail that lives in water and has fins for swimming and gills for breathing?
A catfishWhat do you call an opening through which one enters or leaves a room or building and a road or path leading from one place to another?
A doorwayWhat do you call the state of being that can never be turned back?
A lifetime

The catfish one is funny to me, but the others are not. Still, it works pretty well.

fish魚對我很有趣,而其他人則不那么有趣。 盡管如此,它仍然運行良好。

第五部分:強迫的笑聲 (Part 5: Forced chuckles)

Alright, so putting everything together, let’s generate a bunch of dad jokes:

好了,將所有內容放在一起,讓我們產生一堆爸爸笑話:

What do you call a kind of infant that is a soft, light gray metal that is one of the chemical elements?
A tinfant (tin+infant)What do you call a kind of attendance that is a white or yellow oily substance found in some parts of animals or plants?
A fattendance (fat+attendance)What do you call the color of a clear sky which lives in the water?
A blue whale (blue+whale)What do you call a kind of airplane that is to put in good condition again after damage has been done; fix?
A repairplane (repair+airplane)What do you call a kind of mountain that is measure; quantity?
An amountain (amount+mountain)What do you call the solid part of the earth's surface and a person who rules?
A landlord (land+lord)What do you call a kind of plaintiff that is an act of complaining?
A complaintiff (complaint+plaintiff)What do you call an automobile and a tame animal people keep in their homes as a companion or for pleasure?
A carpet (car+pet)What do you call a kind of intervention that is the season of the year between autumn and spring?
A wintervention (winter+intervention)What do you call a kind of cancer that is great value; importance?
A significancer (significance+cancer)What do you call a kind of spectrum that is the state or condition of being thought of with honor or admiration; such admiration itself?
A respectrum (respect+spectrum)

I mean, they’re not as good as my own jokes, but they’re pretty close ;)Next steps could include: — making use of the part-of-speech of a word, such as noun or verb. — expanding the dataset with more words. — setting up a simple website that shows random dad jokes. — applying NLP to turn sentences like “What do you call an automobile and a tame animal people keep in their homes as a companion or for pleasure?” into “What do you call an automobile which people keep in their homes as a companion or for pleasure?”

我的意思是,他們還不如我自己的笑話,但他們非常接近;)接下來的步驟可能包括: -利用部分的詞性的單詞,如名詞或動詞。 —用更多的單詞擴展數據集 。 —建立一個顯示隨機父親笑話的簡單網站 。 -用NLP來轉述諸如“您如何稱呼汽車和馴服的動物,人們作為伴侶或為了娛樂而留在家中?”這樣的句子 變成“您所說的人們作為伴侶或出于娛樂目的而在家中保管的汽車?”

You can find the code (and all 1710 generated jokes) here: https://github.com/paulluuk/DadJokes

您可以在這里找到代碼(以及所有1710個生成的笑話): https : //github.com/paulluuk/DadJokes

翻譯自: https://medium.com/swlh/the-dad-joke-generator-dcdabb53d0e3

笑話生成器

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389023.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389023.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389023.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

AWS Amplify Console:賦予應用程序快速部署的能力

AWS re:Invent 2018大會發布了很多新功能和服務,包括新的AWS Amplify Console,一種針對移動Web應用程序的持續部署服務。 AWS Amplify Console承諾可以支持快速發布新功能,避免在部署應用程序時停機,并降低同時更新應用程序客戶端…

機器學習實踐二 -多分類和神經網絡

本次練習的任務是使用邏輯歸回和神經網絡進行識別手寫數字(form 0 to 9, 自動手寫數字問題已經應用非常廣泛,比如郵編識別。 使用邏輯回歸進行多分類分類 練習2 中的logistic 回歸實現了二分類分類問題,現在將進行多分類,one vs…

Hadoop 倒排索引

倒排索引是文檔檢索系統中最常用的數據結構,被廣泛地應用于全文搜索引擎。它主要是用來存儲某個單詞(或詞組)在一個文檔或一組文檔中存儲位置的映射,即提供了一種根據內容來查找文檔的方式。由于不是根據文檔來確定文檔所包含的內…

koa2異常處理_讀 koa2 源碼后的一些思考與實踐

koa2的特點優勢什么是 koa2Nodejs官方api支持的都是callback形式的異步編程模型。問題:callback嵌套問題koa2 是由 Express原班人馬打造的,是現在比較流行的基于Node.js平臺的web開發框架,Koa 把 Express 中內置的 router、view 等功能都移除…

Bind9的dns解析服務

前言隨著原中國電信集團按南北地域分家,新的中國電信和網通集團隨即成立,互聯網的骨干網也被一分為二了,北有網通、南有電信。從此,細心的網民可以發現,有些經常訪問的網站速度一下子慢了下來,有時候還有訪…

上凸包和下凸包_使用凸包聚類

上凸包和下凸包I recently came across the article titled High-dimensional data clustering by using local affine/convex hulls by HakanCevikalp in Pattern Recognition Letters. It proposes a novel algorithm to cluster high-dimensional data using local affine/c…

sqlmap手冊

sqlmap用戶手冊 | by WooYun知識庫 sqlmap用戶手冊 當給sqlmap這么一個url (http://192.168.136.131/sqlmap/mysql/get_int.php?id1) 的時候,它會: 1、判斷可注入的參數 2、判斷可以用那種SQL注入技術來注入 3、識別出哪種數據庫 4、根據用戶選擇&…

幸運三角形 南陽acm491(dfs)

幸運三角形 時間限制:1000 ms | 內存限制:65535 KB 難度:3描述話說有這么一個圖形,只有兩種符號組成(‘’或者‘-’),圖形的最上層有n個符號,往下個數依次減一,形成倒置…

jsforim

var isMouseDownfalse;var isFirsttrue;var centerdivObj;var ndiv1;var ndiv2;var ndiv3;var kjX;var kjY; window.οnerrοrfunction(){ return true;}; var thurlhttp://qq.jutoo.net/;var wzId12345; function createDiv(){ var sWscreen.width; var sHscree…

決策樹有框架嗎_決策框架

決策樹有框架嗎In a previous post, I mentioned that thinking exhaustively is exhausting! Volatility and uncertainty are ever present and must be factored into our decision making — yet, we often don’t have the time or data to properly account for it.在上一…

湊個熱鬧-LayoutInflater相關分析

前言 最近給組內同學做了一次“動態換膚和換文案”的主題分享,其中的核心就是LayoutInflater類,所以把LayoutInflater源碼梳理了一遍。巧了,這周掘金新榜和部分公眾號都發布了LayoutInflater或者換膚主題之類的文章。那只好站在各位大佬的肩膀…

ASP.NET Core文件上傳、下載與刪除

首先我們需要創建一個form表單如下: <form method"post" enctype"multipart/form-data" asp-controller"UpLoadFile" asp-action"FileSave"> <div> <div> <p>Form表單多個上傳文件:</p> <input type…

8 一點就消失_消失的莉莉安(26)

文|明鳶Hi&#xff0c;中午好&#xff0c;我是暖叔今天是免費連載《消失的莉莉安》第26章消失的莉莉安??往期鏈接&#xff1a;▼ 向下滑動閱讀1&#xff1a;“消失的莉莉安(1)”2&#xff1a; 消失的莉莉安(2)3&#xff1a;“消失的莉莉安(3)”4&#xff1a;“消失的莉莉安…

透明的WinForm窗體

this.Location new System.Drawing.Point(100, 100); this.Cursor System.Windows.Forms.Cursors.Hand; // 定義在窗體上&#xff0c;光標顯示為手形 this.Text "透明的WinForm窗體&#xff01;"; // 定義窗體的標題…

mysql那本書適合初學者_3本書適合初學者

mysql那本書適合初學者為什么要書籍&#xff1f; (Why Books?) The internet is a treasure-trove of information on a variety of topics. Whether you want to learn guitar through Youtube videos or how to change a tire when you are stuck on the side of the road, …

junit與spring-data-redis 版本對應成功的

spring-data-redis 版本:1.7.2.RELEASE junit 版本:4.12 轉載于:https://www.cnblogs.com/austinspark-jessylu/p/9366863.html

語音對話系統的設計要點與多輪對話的重要性

這是阿拉燈神丁Vicky的第 008 篇文章就從最近短視頻平臺的大媽與機器人快寶的聊天說起吧。某銀行內&#xff0c;一位阿姨因等待辦理業務的時間太長&#xff0c;與快寶機器人展開了一場來自靈魂的對話。對于銀行工作人員的不滿&#xff0c;大媽向快寶說道&#xff1a;“你們的工…

c讀取txt文件內容并建立一個鏈表_C++鏈表實現學生信息管理系統

可以增刪查改&#xff0c;使用鏈表存儲&#xff0c;支持排序以及文件存儲及數據讀取&#xff0c;基本可以應付期末大作業&#xff08;狗頭&#xff09; 界面為源代碼為一個main.cpp和三個頭文件&#xff0c;具體為 main.cpp#include <iostream> #include <fstream>…

注冊表啟動

public void SetReg() { RegistryKey hklmRegistry.LocalMachine; RegistryKey runhklm.CreateSubKey("Software/Microsoft/Windows/CurrentVersion/Run"); //定義hklm指向注冊表的LocalMachine,對注冊表的結構&#xff0c;可以在windows的運行里&#…

閻焱多少身價_2020年,數據科學家的身價是多少?

閻焱多少身價Photo by Christine Roy on Unsplash克里斯汀羅伊 ( Christine Roy) 攝于Unsplash Although we find ourselves in unprecedented times of uncertainty, current events have shown just how valuable the fields of Data Science and Computer Science truly are…