New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Translating" novels with sentence embeddings #22
Comments
That's interesting, especially if you go with sentence vectors. |
I did some work on "translating" from one book to another with sentence vectors. I'll put up code and a full 50,000 word novel soon. It didn't turn out as well as I thought, but it's still pretty cool. Here's a sample, Lincoln's Gettysburg Address composed entirely of sentences from a corpus of works by Winston Churchill:
|
I added a repo here. I'll put most of my updates there, but I'll add samples and full output here as I complete ideas. |
I got a full novel. It's 109,483 words according to |
Here's a sample (from Northanger Abbey with sentences from Sir Arthur Conan Doyle) with the original sentences in italics: CHAPTER 1 No one who had ever seen Catherine Morland in her infancy would have supposed her born to be an heroine. Her situation in life, the character of her father and mother, her own person and disposition, were all equally against her. Her father was a clergyman, without being neglected, or poor, and a very respectable man, though his name was Richard-- and he had never been handsome. He had a considerable independence besides two good livings-- and he was not in the least addicted to locking up his daughters. Her mother was a woman of useful plain sense, with a good temper, and, what is more remarkable, with a good constitution. She had three sons before Catherine was born; and instead of dying in bringing the latter into the world, as anybody might expect, she still lived on-- lived to have six children more-- to see them growing up around her, and to enjoy excellent health herself. |
Wow, this looks a lot better than I expected (from my experiments with
style transfer using word2vec). What mechanisms are you using?
…On Thu, Nov 1, 2018 at 10:10 PM Matthew Dangerfield < ***@***.***> wrote:
Here's a sample (from Northanger Abbey with sentences from Sir Arthur
Conan Doyle) with the original sentences in italics:
*CHAPTER 1 No one who had ever seen Catherine Morland in her infancy would
have supposed her born to be an heroine.*
Everything which the girl said seemed to be meant as an insult to me, and
yet I could not imagine how I had ever offended her.
*Her situation in life, the character of her father and mother, her own
person and disposition, were all equally against her.*
Her whole life was a round of devotion and of love, which was divided
between her husband and her only son, Harold.
*Her father was a clergyman, without being neglected, or poor, and a very
respectable man, though his name was Richard-- and he had never been
handsome.*
`` You must know, Sir Charles, that though my son knew nothing of his
parents, we were both alive, and had never lost sight of him.
*He had a considerable independence besides two good livings-- and he was
not in the least addicted to locking up his daughters.*
Now that they had not only ceased to protect him, but had themselves
become a source of trouble to him, he began to understand how great the
blessing was which he had enjoyed, and to sigh for the happy days before
his girls had come under the influence of his neighbor.
*Her mother was a woman of useful plain sense, with a good temper, and,
what is more remarkable, with a good constitution.*
In her pure and earnest mind her mother's memory was enshrined as that of
a saint, and the thought that any one should take her place seemed a
terrible desecration.
*She had three sons before Catherine was born; and instead of dying in
bringing the latter into the world, as anybody might expect, she still
lived on-- lived to have six children more-- to see them growing up around
her, and to enjoy excellent health herself.*
He was married to the second daughter of Sir James Ovington; and as I have
seen three of his grandchildren within the week, I fancy that if any of Sir
Lothian's descendants have their eye upon the property, they are likely to
be as disappointed as their ancestor was before them.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#22 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAd6GWgetvWhQxB0ibg3Ocm-6GRh9oTVks5uq6migaJpZM4X_tm_>
.
|
I used sentence embeddings from Facebook's InferSent model. For each sentence in the "to translate" text, it finds the semantically closest sentence in the "source" text based on cosine distance between sentence vectors. This makes it so it's guaranteed to be coherent on the sentence level. You can see the code here (full repo is here, but for some reason Github isn't able to render the notebook). |
I've been messing around with this sentence "translation" idea some more, and I found something pretty cool. I translated the sermon on the mount (Matthew chapters 5-7, from the New Testament) using sentences from the Quran. The results were pretty interesting. Hopefully I'm not offending anyone by doing this. SampleBible in italics, Quran below. "Blessed are the poor in spirit, for theirs is the kingdom of heaven. Blessed are those who mourn, for they will be comforted. Blessed are the meek, for they will inherit the earth. Blessed are those who hunger and thirst for righteousness, for they will be filled. Blessed are the merciful, for they will be shown mercy. Blessed are the pure in heart, for they will see God. Blessed are the peacemakers, for they will be called children of God. Blessed are those who are persecuted because of righteousness, for theirs is the kingdom of heaven. "Blessed are you when people insult you, persecute you and falsely say all kinds of evil against you because of me. Rejoice and be glad, because great is your reward in heaven, for in the same way they persecuted the prophets who were before you. |
Careful now... when I first put MegaHAL on the web back in 1997 someone spent all night chatting to it in a futile attempt to have it not say something blasphemous ;) |
Not sure exactly what I'll have time to do, but I have a lot of random ideas. I'll definitely not be able to get through all of them, but I'm committing to get at least one of them done.
I also have some vague ideas about using neural networks to extract hierarchical formulaic story structures, but that's probably overambitious. I sort of approached this problem the last couple of years, but never got very far.
The text was updated successfully, but these errors were encountered: