from collatex import *

"""
Explanation: Collating for real with Collatex (2)
Here we can repeat the same steps done in the previous exercise, with a new and slightly more complicated text case. You can create a new notebook for this exercise and follow the instructions below.
We will be using different editions of Virginia Woolf's "To the lighthouse":
- USA = New York: Harcourt, Brace & Company, 1927 (1st USA edition)
- UK = Londond: R & R Clark Limited, 1827 (1st UK edition)
- EM (EVERYMAN) = London: J. M. Dent & Sons LTD, 1938 (reprint 1952)
The facsimiles and trascriptions of the editions are available at http://woolfonline.com/ 
First exercise
Try to reproduce what you have done with the Darwin text.
Import the collatex Python library
End of explanation
"""


collation = Collation()

"""
Explanation: Create a collation object
End of explanation
"""


with open( "../fixtures/Woolf/Lighthouse-1/Lighthouse-1-USA.txt", encoding='utf-8' ) as witness_USA, \
    open( "../fixtures/Woolf/Lighthouse-1/Lighthouse-1-UK.txt", encoding='utf-8' ) as witness_UK, \
    open( "../fixtures/Woolf/Lighthouse-1/Lighthouse-1-EM.txt", encoding='utf-8' ) as witness_EM:
    collation.add_plain_witness( "USA", witness_USA.read() )
    collation.add_plain_witness( "UK", witness_UK.read() )
    collation.add_plain_witness( "EM", witness_EM.read() )

"""
Explanation: Now open the texts in "../fixtures/Woolf/Lighthouse-1", read them, and add them to the collation:
End of explanation
"""


alignment_table = collate(collation, layout='vertical', output='html')

"""
Explanation: Align, using the HTML output option
End of explanation
"""


collation = Collation()
witness_USA = open( "../fixtures/Woolf/Lighthouse-2/Lighthouse-2-USA.txt", encoding='utf-8' ).read()
witness_UK = open( "../fixtures/Woolf/Lighthouse-2/Lighthouse-2-UK.txt", encoding='utf-8' ).read()
witness_EM = open( "../fixtures/Woolf/Lighthouse-2/Lighthouse-2-EM.txt", encoding='utf-8' ).read()
collation.add_plain_witness( "USA", witness_USA )
collation.add_plain_witness( "UK", witness_UK )
collation.add_plain_witness( "EM", witness_EM )
alignment_table = collate(collation, output='html2')

"""
Explanation: If you want to know more about this text:
Look at the sources
- USA, p. 14
http://woolfonline.com/?node=content/text/transcriptions&project=1&parent=2&taxa=19&content=2817&pos=15
- UK, pp. 16-17
http://woolfonline.com/?node=content/text/transcriptions&project=1&parent=2&taxa=20&content=3139&pos=19
- EVERYMAN, p. 7
http://woolfonline.com/?node=content/text/transcriptions&project=1&parent=2&taxa=22&content=3804&pos=24
Start thinking about how to handle situation like the following (proof with corrections in the margin)
- http://woolfonline.com/?node=content/text/transcriptions&project=1&parent=2&taxa=18&content=4172&pos=14
Second exercise
In the second exercise, repeat the previous steps, now using the texts at "../fixtures/Woolf/Lighthouse-2" and visualizing the output with the more sophisticated HTML option (html2).
End of explanation
"""


alignment_table = collate(collation, output='html', layout='vertical')

"""
Explanation: If you don’t like the colors, you can use the html output option:
End of explanation
"""


