The evaluation of the entropy of entanglement of the ground state in a wide family of one-dimensional quantum spin can be reduced to the Wiener-Hopf factorization of certain 2x2 algebraic matrix valued functions. We show how this factorization can be performed using the apparatus of the Riemann-Hilbert method and algebra-geometricintegration borrowed from the theory of integrable systems. We would like to thinkabout these calculations as a basis for a conjecture that the Wiener-Hopf factorization of a general algebraic matrix can be performed in terms of the Riemann theta functions associated with a certain algebraic curve. The talk is based on the speaker works with V. Korepin and B. Q. Jin and on his works with F. Mezzadri and M. Y. Mo.