jwzimmer-zz / tv-tropening

1 stars 0 forks source link

Lolita - analysis of linear embedding matrix #21

Open jwzimmer-zz opened 2 years ago

jwzimmer-zz commented 2 years ago

Somewhat surprisingly, based on SVD on LoTR embedding matrix not yielding obvious results, it looks like there might be something to the results from the Lolita linear embedding matrix.

To do:

jwzimmer-zz commented 2 years ago

SVD Without Removing Mean

Using this function to make the bar charts:

def vector_barchart(vector_names,vector,n,style="by_mag",ascending=False):
    """ vector_names should be the labels for the values in the vector
        vector should be the vector (ndarray)
        n should be the number of values you want displayed in the chart
        style should be the format of the chart
        ascending=False will be most relevant traits by magnitude,
        ascending=True will be least relevant traits by magnitude"""
    n=min(n,len(vector_names))
    vectordf = pd.DataFrame()
    vectordf["Trait"] = vector_names
    vectordf["Values"] = vector

    if style=="by_mag":
        vectordf["Magnitude"] = vectordf.apply(lambda row: abs(row["Values"]), axis = 1)
        sorteddf = vectordf.sort_values(by="Magnitude",ascending=ascending)
        #plotguy = sorteddf.iloc[-2*n:].iloc[::-1]
        plotguy = sorteddf.iloc[0:2*n]
    if style=="by_sign":
        vectordf["Signed_Magnitude"] = vectordf.apply(lambda row: row["Values"], axis = 1)
        sorteddf = vectordf.sort_values(by="Signed_Magnitude",ascending=ascending)
        #plotguy = sorteddf.iloc[-2*n:].iloc[::-1]
        plotguy = sorteddf.iloc[0:2*n]
    sns.barplot(plotguy["Values"],plotguy["Trait"])
    #sns.set(font_scale = 1)
    return vectordf, plotguy

To sort by signed magnitude: vector_barchart(lolitawords,lv[0,:],10,style="by_sign",ascending=True) To sort by abs_val of magnitude: vector_barchart(lolitawords,lv[0,:],10,style="by_mag",ascending=False)

To load the linear embedding-based character x trait matrix from https://github.com/AttackPenguin/csys300_project/: lolitadf = pd.read_csv("lolita_non_specific_adjacency.csv")

Screen Shot 2021-11-10 at 10 23 25 AM

To get the list of character names: lolitanames = list(lolitadf["Unnamed: 0"])

To run SVD on the original matrix (without removing means): ldf, lu, ld, lv, lsig, lx, lrex = runSVD(lolitadf, dropcols = ["Unnamed: 0"])

To get the list of words that are our "traits" in the original matrix: lolitawords = lolitadf.columns[1:]

Screen Shot 2021-11-10 at 10 40 02 AM

First dimension (row of V^T) vector_barchart(lolitawords,lv[0,:],10)

The magnitudes associated with the words fall off quickly: image

Screen Shot 2021-11-10 at 10 43 07 AM

First trait dimension sorted by absolute value of magnitude (all the high vals have the same sign so sorting by signed magnitude won't make a difference in this case): vector_barchart(lolitawords,lv[0,:],10) image image image

First column of U, so the characters most associated with those traits: vector_barchart(lolitanames,lu[:,0],10) image image image

Second dimension

Second row of V^T image image image

Second column of U image

Sorted by signed magnitude image image

Third dimension

Third row of V^T image

image image

Third column of U

Characters by abs_val of magnitude image

Characters by signed magnitude image image

Fourth dimension

Fourth row of V^T image image image

Fourth row of U image image image

jwzimmer-zz commented 2 years ago

Sigma values

Looks like we can safely truncate after the 4th dimension -- it drops off a lot and they behave qualitatively differently after that point: image image

The non-zero sigma values, normalized: var = [(x/sum(ld))*100 for x in ld]

Screen Shot 2021-11-10 at 11 31 20 AM
jwzimmer-zz commented 2 years ago

Removing the mean

The mean is very close to 0, so I don't think it will make much difference.

lolitadf.mean().mean()
Out[967]: 0.0011573909781657545

Sigma values look similar.

First dimension (column of U) image image image

Looks like the patterns aren't drastically different

jwzimmer-zz commented 2 years ago

Easier to read visuals for SVD (with mean removed)

Screen Shot 2021-11-10 at 1 37 30 PM Screen Shot 2021-11-10 at 1 37 45 PM Screen Shot 2021-11-10 at 1 38 00 PM Screen Shot 2021-11-10 at 1 38 07 PM
jwzimmer-zz commented 2 years ago

Character Chart for selected characters

Trigger warning: abuse, sexual abuse, sexual abuse of children, sex work, violence, guns, sexism, misogyny, sexualization of children, fatphobia, murder, racism, racist terms

Character Name Quote Quote Source
Dr. Ivor Quilty "Next time I expect to see fat old Ivor in the ivory. He is really a freak, that man. Last time he told me a completely indecent story about his nephew. It appears—" Jean
"“We have,” said Haze, “an excellent dentist. Our neighbor, in fact. Dr. Quilty. Uncle or cousin, I think, of the playwright." Charlotte Haze
"A white-smocked, gray-haired man, with a crew cut and the big flat cheeks of a politician, Dr. Quilty perched on the corner of his desk, one foot dreamily and seductively rocking as he launched on a glorious long-range plan." Narrator (HH)
"That fat dentist? You must be confusing me with some other fast little article." Lolita (Lo)
"Clare’s uncle remained sitting on the desk, still looking dreamy, but his foot had stopped push-rocking the cradle of rosy anticipation." Narrator (HH)
Monique "They all answer “dix-huit”—a trim twitter, a note of finality and wistful deceit which they emit up to ten times per day, the poor little creatures. But in Monique’s case there could be no doubt she was, if anything, adding one or two years to her age. This I deduced from many details of her compact, neat, curiously immature body. Having shed her clothes with fascinating rapidity, she stood for a moment partly wrapped in the dingy gauze of the window curtain listening with infantile pleasure, as pat as pat could be, to an organ-grinder in the dust-brimming courtyard below. When I examined her small hands and drew her attention to their grubby fingernails, she said with a naïve frown “Oui, ce n’est pas bien,” and went to the washbasin, but I said it did not matter, did not matter at all. With her brown bobbed hair, luminous gray eyes and pale skin, she looked perfectly charming. Her hips were no bigger than those of a squatting lad; in fact, I do not hesitate to say (and indeed this is the reason why I linger gratefully in that gauze-gray room of memory with little Monique) that among the eighty or so grues I had had operate upon me, she was the only one that gave me a pang of genuine pleasure." Narrator (HH)
"She came hardly up to my chest hair and had the kind of dimpled round little face French girls so often have, and I liked her long lashes and tight-fitting tailored dress sheathing in pearl-gray her young body which still retained—and that was the nymphic echo, the chill of delight, the leap in my loins—a childish something mingling with the professional frétillement of her small agile rump." Narrator (HH)
"...my last vision that night of long-lashed Monique is touched up with a gaiety that I find seldom associated with any event in my humiliating, sordid, taciturn love life" Narrator (HH)
"So let her remain, sleek, slender Monique, as she was for a minute or two: a delinquent nymphet shining through the matter-of-fact young whore." Narrator (HH)
Vivian Darkbloom* "...the bare shoulders of a hawk-like, black-haired, strikingly tall woman." Narrator (HH)
"Vivian is quite a woman. I am sure we saw her yesterday..." Narrator (HH)
"“Sometimes,” said Lo, “you are quite revoltingly dumb. First, Vivian is the male author, the gal author is Clare; and second, she is forty, married and has Negro blood.”" Lolita (Lo)
"Author of The Little Nymph, The Lady Who Loved Lightning (in collaboration with Vivian Darkbloom), Dark Age, The Strange Mushroom, Fatherly Love, and others. His many plays for children are notable." Narrator reading a diegetic text
Clare Quilty ""I thought," I said kidding her, "Quilty was an ancient flame of yours, in the days when you loved me, in sweet old Ramsdale."" Narrator (HH)
"...but let me jot down this: I had preserved in the alcohol of a clouded memory the toad of a face. In the course of a few glimpses, I had noticed its slight resemblance to a cheery and rather repulsive wine dealer, a relative of mine in Switzerland. With his dumbbells and stinking tricot, and fat hairy arms, and bald patch, and pig-faced servant-concubine, he was on the whole a harmless old rascal. Too harmless, in fact, to be confused with my prey." Narrator (HH)
"He had not visited with the rascal since 1946, but supposed he could be found at his ancestral home..." Narrator (HH) quoting Dr. Ivor Quilty
"It had become completely engulfed by the face of Clare Quilty—as represented, with artistic precision, by an easeled photograph of him that stood on his uncle’s desk." Narrator (HH)
"I won again, and with another abrupt movement Clare the Impredictable sat down before the piano and played several atrociously vigorous, fundamentally hysterical, plangent chords, his jowls quivering..." Narrator (HH)
"...as he rent the air—still shaking with the rich black music—head thrown back in a howl, hand pressed to his brow, and with his other hand clutching his armpit as if stung by a hornet..." Narrator (HH)
"...he would say under his breath, with a phoney British accent—all the while dreadfully twitching, shivering, smirking, but withal talking in a curiously detached and even amiable manner: “Ah, that hurts, sir, enough!" Narrator (HH)
"“Does not he look exactly, but exactly, like Quilty?” said Lo in a soft voice, her sharp brown elbow not pointing, but visibly burning to point, at the lone diner in the loud checks, in the far corner of the room." Lolita (Lo)
Valeria "My informant, a doctor, swore he had seen with his own eyes obese Valechka and her colonel, by then gray-haired and also quite corpulent, diligently crawling about the well-swept floors of a brightly lit set of rooms..." Narrator (HH)
"In the good old days, by merely twisting fat Valechka’s brittle wrist (the one she had fallen upon from a bicycle) I could make her change her mind instantly..." Narrator (HH)
"To Valeria I might have said: “Look here, you fat fool..." Narrator (HH)
"...the cold and scaly quality of my displeased silence, used to frighten Valeria out of her wits. She used to whimper and wail..." Narrator (HH)
Gaston Godin "...the young loveliness of my daughter and the naïve charm of Gaston Godin" Narrator (HH) quoting Miss Fabian
"A word about Gaston Godin. The main reason why I enjoyed—or at least tolerated with relief—his company was the spell of absolute security that his ample person cast on my secret... He was a flabby, dough-faced, melancholy bachelor tapering upward to a pair of narrow, not quite level shoulders and a conical pear-head which had sleek black hair on one side and only a few plastered wisps on the other. But the lower part of his body was enormous, and he ambulated with a curious elephantine stealth by means of phenomenally stout legs. ...everybody considered him to be a supremely lovable, lovably freakish fellow! Neighbors pampered him; he knew by name all the small boys in our vicinity (he lived a few blocks away from me) and had some of them clean his sidewalk and burn leaves in his back yard, and bring wood from his shed, and even perform simple chores about the house, and he would feed them fancy chocolates, with real liqueurs inside—in the privacy of an orientally furnished den in his basement, with amusing daggers and pistols arrayed on the moldy, rug-adorned walls among the camouflaged hot-water pipes. Narrator (HH)
"I need him for my defense. There he was, devoid of any talent whatsoever, a mediocre teacher, a worthless scholar, a glum repulsive fat old invert, highly contemptuous of the American way of life, triumphantly ignorant of the English language—there he was in priggish New England, crooned over by the old and caressed by the young—oh, having a grand time and fooling everybody; and here was I." Narrator (HH)
Frederick "...hummingbird pencil deftly and delicately flying from one point to another, Frederick demonstrated his absolute innocence and the recklessness of my wife..." Narrator (HH)
"I said it was certainly not his fault, and the inquest upheld my view." Narrator (HH)
"Breathing violently through jet-black tense nostrils, he shook his head and my hand; then, with an air of perfect savoir vivre and gentlemanly generosity, he offered to pay the funeral-home expenses. He expected me to refuse his offer. With a drunken sob of gratitude I accepted it. This took him aback. Slowly, incredulously, he repeated what he had said. I thanked him again, even more profusely than before. In result of that weird interview, the numbness of my soul was for a moment resolved. And no wonder! I had actually seen the agent of fate. I had palpated the very flesh of fate—and its padded shoulder." Narrator (HH)
Charlie "I answered I did not know what game she and Charlie had played. “You mean you have never—?”—her features twisted into a stare of disgusted incredulity." Narrator (HH)
"...Charlie Holmes, the camp mistress’ son, aged thirteen—and the only human male for a couple of miles around (excepting an old meek stone-deaf handyman, and a farmer in an old Ford..." Narrator (HH)
"...silent, coarse and surly but indefatigable Charlie, who had as much sex appeal as a raw carrot..." Narrator (HH)
Dolores "...Lolita always had an absolutely enchanting smile for strangers, a tender furry slitting of the eyes, a dreamy sweet radiance of all her features which did not mean a thing of course, but was so beautiful, so endearing that one found it hard to reduce such sweetness to but a magic gene automatically lighting up her face in atavistic token of some ancient rite of welcome—hospitable prostitution, the coarse reader may say." Narrator (HH)
"Lolita, I am glad to say, held Charlie’s mind and manners in the greatest contempt" Narrator (HH)
"Lolita, light of my life, fire of my loins. My sin, my soul. Lo-lee-ta: the tip of the tongue taking a trip of three steps down the palate to tap, at three, on the teeth. Lo. Lee. Ta. She was Lo, plain Lo, in the morning, standing four feet ten in one sock. She was Lola in slacks. She was Dolly at school. She was Dolores on the dotted line. But in my arms she was always Lolita." Narrator (HH)
"...on that intangible island of entranced time where Lolita plays with her likes. Within the same age limits the number of true nymphets is strikingly inferior to that of provisionally plain, or just nice, or “cute,” or even “sweet” and “attractive,” ordinary, plumpish, formless, cold-skinned, essentially human little girls, with tummies and pigtails, who may or may not turn into adults of great beauty..." Narrator (HH)
"...the twofold nature of this nymphet—of every nymphet, perhaps; this mixture in my Lolita of tender dreamy childishness and a kind of eerie vulgarity..." Narrator (HH)
"Of course, moodiness is a common concomitant of growing up, but Lo exaggerates." Narrator (HH)
Annabel "Annabel was, like the writer, of mixed parentage: half-English, half-Dutch, in her case. I remember her features far less distinctly today than I did a few years ago, before I knew Lolita. There are two kinds of visual memory: one when you skillfully recreate an image in the laboratory of your mind, with your eyes open (and then I see Annabel in such general terms as: “honey-colored skin,” “thin arms,” “brown bobbed hair,” “long lashes,” “big bright mouth”); and the other when you instantly evoke, with shut eyes, on the dark innerside of your eyelids, the objective, absolutely optical replica of a beloved face, a little ghost in natural colors (and this is how I see Lolita). ...she was a lovely child a few months my junior. Her parents were old friends of my aunt’s, and as stuffy as she. ...Bald brown Mr. Leigh and fat, powdered Mrs. Leigh (born Vanessa van Ness)." Narrator (HH)
"All at once we were madly, clumsily, shamelessly, agonizingly in love with each other; hopelessly, I should add, because that frenzy of mutual possession might have been assuaged only by our actually imbibing and assimilating every particle of each other’s soul and flesh; but there we were, unable even to mate as slum children would have so easily found an opportunity to do. After one wild attempt we made to meet at night in her garden (of which more later), the only privacy we were allowed was to be out of earshot but not out of sight on the populous part of the plage. There, on the soft sand, a few feet away from our elders, we would sprawl all morning, in a petrified paroxysm of desire, and take advantage of every blessed quirk in space and time to touch each other: her hand, half-hidden in the sand, would creep toward me, its slender brown fingers sleepwalking nearer and nearer; then, her opalescent knee would start on a long cautious journey; sometimes a chance rampart built by younger children granted us sufficient concealment to graze each other’s salty lips; these incomplete contacts drove our healthy and inexperienced young bodies to such a state of exasperation that not even the cold blue water, under which we still clawed at each other, could bring relief." Narrator (HH)
Harold Haze "...a sublime, purified, analyzed, deified Harold Haze..." Narrator (HH)

*I think our linear embedding script just looked for "Vivian"; the quotes here are about the more important character, Vivian Darkbloom, but there is a reference to another character, Vivian McCrystal. Similarly, there is the Frederick character who kills Charlotte Haze, but there are additional brief references to other Fredericks.

jwzimmer-zz commented 2 years ago

Ok, so after poking around at the SVD results and the original text, I don't think what we did works that well, because it does not capture refined details about specific characters. However, I do think that it captures something about the way in which the narrator, Humbert Humbert, views the characters (maybe more accurate to say, the way in which Nabokov crafted Humbert Humbert's view of the other characters). To Humbert Humbert, the world broadly breaks down into graceful, vivacious (as in, innately full of life) nymphets, who are worthy of admiration and the object of his lust, and everyone else, who is repulsive and a pathetic echo or imitation of the characteristics nymphets effortlessly possess. More concretely, there are two categories of people: {innocent-yet-sexual, unsophisticated, graceful, warm, glowing, healthy, lithe, slim} and {fat, old, bald, pallid, lumbering, degraded, lascivious, cold, rotten, conniving, forced}. With a more fine-toothed lens, there would be more detail within those groups. For example, the latter group breaks down into the people HH finds useful (Frederick, Gaston) versus the people that he views as competitors or threats (Clare Quilty, Charlie), and, of course, adult women, especially those who become his romantic partner (Charlotte Haze, Valeria), receive from HH an especially vivid and hateful contempt. However, at the most fundamental level, those are the two categories he puts people in, and it does seem that our SVD results picked up (imperfectly) on that.

Screen Shot 2021-11-10 at 4 16 59 PM Screen Shot 2021-11-10 at 4 20 48 PM Screen Shot 2021-11-10 at 4 23 08 PM
jwzimmer-zz commented 2 years ago

An excerpt from the text that I think shows these two main categorizations: the {young, alive, and beautiful}, and the {old, bumbling, desperate}. Headmistress Pratt is repulsive, clueless, idiotic, foolish, laughable, and HH depicts himself as worn-out, conniving and desperate. The adults almost seem afraid of some innate power in Lolita, which they both seek to tear down and destroy, although in different ways for different purposes.

"“She is attractive, bright though careless” (breathing heavily, without leaving her perch, the woman took time out to look at the lovely child’s report sheet on the desk at her right). “Her marks are getting worse and worse. Now I wonder, Mr. Haze—” Again the false meditation.

“Well,” she went on with zest, “as for me, I do smoke, and, as dear Dr. Pierce used to say: I’m not proud of it but I jeest love it.” She lit up and the smoke she exhaled from her nostrils was like a pair of tusks.

“Let me give you a few details, it won’t take a moment. Now let me see [rummaging among her papers]. She is defiant toward Miss Redcock and impossibly rude to Miss Cormorant. Now here is one of our special research reports: Enjoys singing with group in class though mind seems to wander. Crosses her knees and wags left leg to rhythm. Type of by-words: a two-hundred-forty-two word area of the commonest pubescent slang fenced in by a number of obviously European polysyllables. Sighs a good deal in class. Let me see. Yes. Now comes the last week in November. Sighs a good deal in class. Chews gum vehemently. Does not bite her nails though if she did, this would conform better to her general pattern—scientifically speaking, of course. Menstruation, according to the subject, well established. Belongs at present to no church organization. By the way, Mr. Haze, her mother was—? Oh, I see. And you are—? Nobody’s business is, I suppose, God’s business. Something else we wanted to know. She has no regular home duties, I understand. Making a princess of your Dolly, Mr. Haze, eh? Well, what else have we got here? Handles books gracefully. Voice pleasant. Giggles rather often. A littly dreamy. Has private jokes of her own, transposing for instance the first letters of some of her teachers’ names. Hair light and dark brown, lustrous—well [laughing] you are aware of that, I suppose. Nose unobstructed, feet high-arched, eyes—let me see, I had here somewhere a still more recent report. Aha, here we are. Miss Gold says Dolly’s tennis form is excellent to superb, even better than Linda Hall’s, but concentration and point-accumulation are just “poor to fair.” Miss Cormorant cannot decide whether Dolly has exceptional emotional control or none at all. Miss Horn reports she—I mean, Dolly—cannot verbalize her emotions, while according to Miss Cole Dolly’s metabolic efficiency is superfine. Miss Molar thinks Dolly is myopic and should see a good ophthalmologist, but Miss Redcock insists that the girl simulates eye-strain to get away with scholastic incompetence. And to conclude, Mr. Haze, our researchers are wondering about something really crucial. Now I want to ask you something. I want to know if your poor wife, or yourself, or anyone else in the family—I understand she has several aunts and a maternal grandfather in California?—oh, had!—I’m sorry—well, we all wonder if anybody in the family has instructed Dolly in the process of mammalian reproduction. The general impression is that fifteen-year-old Dolly remains morbidly uninterested in sexual matters, or to be exact, represses her curiosity in order to save her ignorance and self-dignity. All right—fourteen. You see, Mr. Haze, Beardsley School does not believe in bees and blossoms, and storks and love birds, but it does believe very strongly in preparing its students for mutually satisfactory mating and successful child rearing. We feel Dolly could make excellent progress if only she would put her mind to her work. Miss Cormorant’s report is significant in that respect. Dolly is inclined to be, mildly speaking, impudent. But all feel that primo, you should have your family doctor tell her the facts of life and, secundo, that you allow her to enjoy the company of her schoolmates’ brothers at the Junior Club or in Dr. Rigger’s organization, or in the lovely homes of our parents.”

“She may meet boys at her own lovely home,” I said.

“I hope she will,” said Pratt buoyantly. “When we questioned her about her troubles, Dolly refused to discuss the home situation, but we have spoken to some of her friends and really—well, for example, we insist you un-veto her nonparticipation in the dramatic group. You just must allow her to take part in The Hunted Enchanters. She was such a perfect little nymph in the try-out, and sometime in spring the author will stay for a few days at Beardsley College and may attend a rehearsal or two in our new auditorium. I mean it is all part of the fun of being young and alive and beautiful. You must understand—”

“I always thought of myself,” I said, “as a very understanding father.”

“Oh no doubt, no doubt, but Miss Cormorant thinks, and I am inclined to agree with her, that Dolly is obsessed by sexual thoughts for which she finds no outlet, and will tease and martyrize other girls, or even our younger instructors because they do have innocent dates with boys.”

Shrugged my shoulders. A shabby émigré.

“Let us put our two heads together, Mr. Haze. What on earth is wrong with that child?”

“She seems quite normal and happy to me,” I said (disaster coming at last? was I found out? had they got some hypnotist?).

“What worries me,” said Miss Pratt looking at her watch and starting to go over the whole subject again, “is that both teachers and schoolmates find Dolly antagonistic, dissatisfied, cagey—and everybody wonders why you are so firmly opposed to all the natural recreations of a normal child.”

“Do you mean sex play?” I asked jauntily, in despair, a cornered old rat."