rpryzant / delete_retrieve_generate

PyTorch implementation of the Delete, Retrieve Generate style transfer algorithm
MIT License
132 stars 26 forks source link

Question about producing attribute vocab #6

Closed wusj18 closed 5 years ago

wusj18 commented 5 years ago

In tools/make_attribute_vocab.py have code like this:

for tok in vocab: if max(sc.salience(tok, attribute='pre'), sc.salience(tok, attribute='post')) > r: print(tok)

I wonder what's the meaning of "max" operation? cuz I thought if I want to get the attribute markers that associate with "humor" attribute, I should find words that appear in the humor corpus but do not appear in the romantic corpus.

rpryzant commented 5 years ago

That line is saying "if the word's salience is bigger than the threshold (r) from the perspective of EITHER style then include it in the attribute vocab". The max does the "either style" bit.

If you just wanted words that are associated with one style (e.g. humor or romantic) then you would delete the max and do something like

for tok in vocab:
    sc.salience(tok, attribute='<pre or post depending on what style you want>') > r:
        print(tok)
wusj18 commented 5 years ago

I get it, thank you very much!