from collections import OrderedDict
from unittest import TestCase, mock
from xrennerjsonnlp import XrennerPipeline
import pytest
import pyjsonnlp
from . import mocks

pyjsonnlp.__version__ = '0.2.6'


class TestXrenner(TestCase):
    @mock.patch('xrennerjsonnlp.CoreNLP.dep_parse')
    def test_process(self, dep_parse):
        dep_parse.return_value = """1	John	John	NNP	NNP	_	2	compound	_	_
2	Smith	Smith	NNP	NNP	_	3	nsubj	_	_
3	visited	visit	VBD	VBD	_	0	ROOT	_	_
4	Spain	Spain	NNP	NNP	_	3	dobj	_	_
5	.	.	.	.	_	3	punct	_	_

1	His	he	PRP$	PRP$	_	2	nmod:poss	_	_
2	visit	visit	NN	NN	_	3	nsubj	_	_
3	went	go	VBD	VBD	_	0	ROOT	_	_
4	well	well	RB	RB	_	3	advmod	_	_
5	.	.	.	.	_	3	punct	_	_
"""
        actual = XrennerPipeline().process("John Smith visited Spain. His visit went well.", 'en')
        expected = OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('documents', {1: OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.source', 'Xrenner 2.0'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('id', 1), ('tokenList', {1: {'id': 1, 'text': 'John', 'lemma': 'John', 'upos': 'NNP', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes')])}, 2: {'id': 2, 'text': 'Smith', 'lemma': 'Smith', 'upos': 'NNP', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes')])}, 3: {'id': 3, 'text': 'visited', 'lemma': 'visit', 'upos': 'VBD', 'xpos': 'VBD', 'features': OrderedDict([('Overt', 'Yes')])}, 4: {'id': 4, 'text': 'Spain', 'lemma': 'Spain', 'upos': 'NNP', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes')])}, 5: {'id': 5, 'text': '.', 'lemma': '.', 'upos': '.', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes')])}, 6: {'id': 6, 'text': 'His', 'lemma': 'he', 'upos': 'PRP$', 'xpos': 'PRP$', 'features': OrderedDict([('Overt', 'Yes')])}, 7: {'id': 7, 'text': 'visit', 'lemma': 'visit', 'upos': 'NN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes')])}, 8: {'id': 8, 'text': 'went', 'lemma': 'go', 'upos': 'VBD', 'xpos': 'VBD', 'features': OrderedDict([('Overt', 'Yes')])}, 9: {'id': 9, 'text': 'well', 'lemma': 'well', 'upos': 'RB', 'xpos': 'RB', 'features': OrderedDict([('Overt', 'Yes')])}, 10: {'id': 10, 'text': '.', 'lemma': '.', 'upos': '.', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes')])}}), ('sentences', {0: {'id': 0, 'conllId': '', 'tokenFrom': 1, 'tokenTo': 6, 'tokens': [1, 2, 3, 4, 5]}, 1: {'id': 1, 'conllId': '', 'tokenFrom': 6, 'tokenTo': 11, 'tokens': [6, 7, 8, 9, 10]}}), ('dependencies', [{'style': 'universal', 'arcs': {1: [{'label': 'compound', 'governor': 2, 'dependent': 1}], 2: [{'label': 'nsubj', 'governor': 3, 'dependent': 2}], 3: [{'label': 'root', 'governor': 0, 'dependent': 3}], 4: [{'label': 'dobj', 'governor': 3, 'dependent': 4}], 5: [{'label': 'punct', 'governor': 3, 'dependent': 5}], 6: [{'label': 'nmod:poss', 'governor': 7, 'dependent': 6}], 7: [{'label': 'nsubj', 'governor': 8, 'dependent': 7}], 8: [{'label': 'root', 'governor': 0, 'dependent': 8}], 9: [{'label': 'advmod', 'governor': 8, 'dependent': 9}], 10: [{'label': 'punct', 'governor': 8, 'dependent': 10}]}}, {'style': 'enhanced', 'arcs': {}}]), ('coreferences', [{'id': 0, 'representative': {'entity': 'person', 'tokens': [1, 2], 'head': 2}, 'referents': [{'type': 'ana', 'tokens': [6], 'head': 6}]}, {'id': 1, 'representative': {'entity': 'event', 'tokens': [3], 'head': 3}, 'referents': [{'type': 'coref', 'tokens': [6, 7], 'head': 7}]}]), ('expressions', [{'type': 'NP', 'head': 2, 'tokens': [1, 2]}]), ('text', 'John Smith visited Spain. His visit went well.')])})])
        assert expected == actual, actual

    def test_process_conll_spacy(self):
        conll = """# newdoc id = 1
# sent id = 1
1	Autonomous	autonomous	ADJ	JJ	Overt=Yes|Stop=No|Alpha=Yes|Degree=Pos|Foreign=No	2	amod	_	_
2	cars	car	NOUN	NNS	Overt=Yes|Stop=No|Alpha=Yes|Number=Plur|Foreign=No	0	root	_	_
3	from	from	ADP	IN	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	2	prep	_	_
4	the	the	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	5	det	_	_
5	countryside	countryside	NOUN	NN	Overt=Yes|Stop=No|Alpha=Yes|Number=Sing|Foreign=No	3	pobj	_	_
6	of	of	ADP	IN	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	5	prep	_	_
7	France	france	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	10	compound	_	_
8	shift	shift	VERB	VBP	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Fin|Tense=Pres|Foreign=No	9	compound	_	_
9	insurance	insurance	NOUN	NN	Overt=Yes|Stop=No|Alpha=Yes|Number=Sing|Foreign=No	10	compound	_	_
10	liability	liability	NOUN	NN	Overt=Yes|Stop=No|Alpha=Yes|Number=Sing|Foreign=No	6	pobj	_	_
11	toward	toward	ADP	IN	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	10	prep	_	_
12	manufacturers	manufacturer	NOUN	NNS	Overt=Yes|Stop=No|Alpha=Yes|Number=Plur|Foreign=No	11	pobj	_	_
13	.	.	PUNCT	.	Overt=Yes|Stop=No|Alpha=No|PunctType=Peri|Foreign=No	2	punct	_	_

# sent id = 2
1	People	people	NOUN	NNS	Overt=Yes|Stop=No|Alpha=Yes|Number=Plur|Foreign=No	2	nsubj	_	_
2	are	be	VERB	VBP	Overt=Yes|Stop=Yes|Alpha=Yes|VerbForm=Fin|Tense=Pres|Foreign=No	0	root	_	_
3	afraid	afraid	ADJ	JJ	Overt=Yes|Stop=No|Alpha=Yes|Degree=Pos|Foreign=No	2	acomp	_	_
4	that	that	ADP	IN	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	7	mark	_	_
5	they	they	PRON	PRP	Overt=Yes|Stop=Yes|Alpha=Yes|PronType=Prs|Foreign=No	7	nsubj	_	_
6	will	will	VERB	MD	Overt=Yes|Stop=Yes|Alpha=Yes|VerbType=Mod|Foreign=No	7	aux	_	_
7	crash	crash	VERB	VB	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Inf|Foreign=No	3	ccomp	_	_
8	.	.	PUNCT	.	Overt=Yes|Stop=No|Alpha=No|PunctType=Peri|Foreign=No	2	punct	_	_"""
        actual = XrennerPipeline().process_conll(conll, )
        expected = OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('documents', {1: OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.source', 'Xrenner 2.0'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('id', 1), ('conllId', '1'), ('tokenList', {1: {'id': 1, 'text': 'Autonomous', 'lemma': 'autonomous', 'upos': 'ADJ', 'xpos': 'JJ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 2: {'id': 2, 'text': 'cars', 'lemma': 'car', 'upos': 'NOUN', 'xpos': 'NNS', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Plur'), ('Foreign', 'No')])}, 3: {'id': 3, 'text': 'from', 'lemma': 'from', 'upos': 'ADP', 'xpos': 'IN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 4: {'id': 4, 'text': 'the', 'lemma': 'the', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 5: {'id': 5, 'text': 'countryside', 'lemma': 'countryside', 'upos': 'NOUN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Sing'), ('Foreign', 'No')])}, 6: {'id': 6, 'text': 'of', 'lemma': 'of', 'upos': 'ADP', 'xpos': 'IN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 7: {'id': 7, 'text': 'France', 'lemma': 'france', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 8: {'id': 8, 'text': 'shift', 'lemma': 'shift', 'upos': 'VERB', 'xpos': 'VBP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Pres'), ('Foreign', 'No')])}, 9: {'id': 9, 'text': 'insurance', 'lemma': 'insurance', 'upos': 'NOUN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Sing'), ('Foreign', 'No')])}, 10: {'id': 10, 'text': 'liability', 'lemma': 'liability', 'upos': 'NOUN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Sing'), ('Foreign', 'No')])}, 11: {'id': 11, 'text': 'toward', 'lemma': 'toward', 'upos': 'ADP', 'xpos': 'IN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 12: {'id': 12, 'text': 'manufacturers', 'lemma': 'manufacturer', 'upos': 'NOUN', 'xpos': 'NNS', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Plur'), ('Foreign', 'No')])}, 13: {'id': 13, 'text': '.', 'lemma': '.', 'upos': 'PUNCT', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Peri'), ('Foreign', 'No')])}, 14: {'id': 14, 'text': 'People', 'lemma': 'people', 'upos': 'NOUN', 'xpos': 'NNS', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Plur'), ('Foreign', 'No')])}, 15: {'id': 15, 'text': 'are', 'lemma': 'be', 'upos': 'VERB', 'xpos': 'VBP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Pres'), ('Foreign', 'No')])}, 16: {'id': 16, 'text': 'afraid', 'lemma': 'afraid', 'upos': 'ADJ', 'xpos': 'JJ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 17: {'id': 17, 'text': 'that', 'lemma': 'that', 'upos': 'ADP', 'xpos': 'IN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 18: {'id': 18, 'text': 'they', 'lemma': 'they', 'upos': 'PRON', 'xpos': 'PRP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('PronType', 'Prs'), ('Foreign', 'No')])}, 19: {'id': 19, 'text': 'will', 'lemma': 'will', 'upos': 'VERB', 'xpos': 'MD', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('VerbType', 'Mod'), ('Foreign', 'No')])}, 20: {'id': 20, 'text': 'crash', 'lemma': 'crash', 'upos': 'VERB', 'xpos': 'VB', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Inf'), ('Foreign', 'No')])}, 21: {'id': 21, 'text': '.', 'lemma': '.', 'upos': 'PUNCT', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Peri'), ('Foreign', 'No')])}}), ('sentences', {0: {'id': 0, 'conllId': '', 'tokenFrom': 1, 'tokenTo': 14, 'tokens': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]}, 1: {'id': 1, 'conllId': '', 'tokenFrom': 14, 'tokenTo': 22, 'tokens': [14, 15, 16, 17, 18, 19, 20, 21]}}), ('dependencies', [{'style': 'universal', 'arcs': {1: [{'label': 'amod', 'governor': 2, 'dependent': 1}], 2: [{'label': 'root', 'governor': 0, 'dependent': 2}], 3: [{'label': 'prep', 'governor': 2, 'dependent': 3}], 4: [{'label': 'det', 'governor': 5, 'dependent': 4}], 5: [{'label': 'pobj', 'governor': 3, 'dependent': 5}], 6: [{'label': 'prep', 'governor': 5, 'dependent': 6}], 7: [{'label': 'compound', 'governor': 10, 'dependent': 7}], 8: [{'label': 'compound', 'governor': 9, 'dependent': 8}], 9: [{'label': 'compound', 'governor': 10, 'dependent': 9}], 10: [{'label': 'pobj', 'governor': 6, 'dependent': 10}], 11: [{'label': 'prep', 'governor': 10, 'dependent': 11}], 12: [{'label': 'pobj', 'governor': 11, 'dependent': 12}], 13: [{'label': 'punct', 'governor': 2, 'dependent': 13}], 14: [{'label': 'nsubj', 'governor': 15, 'dependent': 14}], 15: [{'label': 'root', 'governor': 0, 'dependent': 15}], 16: [{'label': 'acomp', 'governor': 15, 'dependent': 16}], 17: [{'label': 'mark', 'governor': 20, 'dependent': 17}], 18: [{'label': 'nsubj', 'governor': 20, 'dependent': 18}], 19: [{'label': 'aux', 'governor': 20, 'dependent': 19}], 20: [{'label': 'ccomp', 'governor': 16, 'dependent': 20}], 21: [{'label': 'punct', 'governor': 15, 'dependent': 21}]}}, {'style': 'enhanced', 'arcs': {}}])])})])
        assert expected == actual, actual

    def test_process_conll_spacy_2(self):
        conll = """# newdoc id = 1
# sent id = 1
1	The	the	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	3	det	_	_
2	Mueller	mueller	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	3	compound	_	_
3	Report	report	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	4	nsubj	_	_
4	is	be	VERB	VBZ	Overt=Yes|Stop=Yes|Alpha=Yes|VerbForm=Fin|Tense=Pres|Number=Sing|Person=3|Foreign=No	0	root	_	_
5	a	a	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	8	det	_	_
6	very	very	ADV	RB	Overt=Yes|Stop=Yes|Alpha=Yes|Degree=Pos|Foreign=No	7	advmod	_	_
7	long	long	ADJ	JJ	Overt=Yes|Stop=No|Alpha=Yes|Degree=Pos|Foreign=No	8	amod	_	_
8	report	report	NOUN	NN	Overt=Yes|Stop=No|Alpha=Yes|Number=Sing|Foreign=No	4	attr	_	_
9	.	.	PUNCT	.	Overt=Yes|Stop=No|Alpha=No|PunctType=Peri|Foreign=No	4	punct	_	_

# sent id = 2
1	We	we	PRON	PRP	Overt=Yes|Stop=Yes|Alpha=Yes|PronType=Prs|Foreign=No	2	nsubj	_	_
2	spent	spend	VERB	VBD	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Fin|Tense=Past|Foreign=No	0	root	_	_
3	a	a	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	5	det	_	_
4	long	long	ADJ	JJ	Overt=Yes|Stop=No|Alpha=Yes|Degree=Pos|Foreign=No	5	amod	_	_
5	time	time	NOUN	NN	Overt=Yes|Stop=No|Alpha=Yes|Number=Sing|Foreign=No	2	dobj	_	_
6	analyzing	analyze	VERB	VBG	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Part|Tense=Pres|Aspect=Prog|Foreign=No	2	xcomp	_	_
7	it	it	PRON	PRP	Overt=Yes|Stop=Yes|Alpha=Yes|PronType=Prs|Foreign=No	6	dobj	_	_
8	.	.	PUNCT	.	Overt=Yes|Stop=No|Alpha=No|PunctType=Peri|Foreign=No	2	punct	_	_

# sent id = 3
1	Trump	trump	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	2	nsubj	_	_
2	wishes	wish	VERB	VBZ	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Fin|Tense=Pres|Number=Sing|Person=3|Foreign=No	0	root	_	_
3	we	we	PRON	PRP	Overt=Yes|Stop=Yes|Alpha=Yes|PronType=Prs|Foreign=No	4	nsubj	_	_
4	did	do	VERB	VBD	Overt=Yes|Stop=Yes|Alpha=Yes|VerbForm=Fin|Tense=Past|Foreign=No	2	ccomp	_	_
5	not	not	ADV	RB	Overt=Yes|Stop=Yes|Alpha=Yes|Degree=Pos|Foreign=No	4	neg	_	_
6	,	,	PUNCT	,	Overt=Yes|Stop=No|Alpha=No|PunctType=Comm|Foreign=No	2	punct	_	_
7	but	but	CCONJ	CC	Overt=Yes|Stop=Yes|Alpha=Yes|ConjType=Coor|Foreign=No	2	cc	_	_
8	that	that	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	11	nsubj	_	_
9	did	do	VERB	VBD	Overt=Yes|Stop=Yes|Alpha=Yes|VerbForm=Fin|Tense=Past|Foreign=No	11	aux	_	_
10	not	not	ADV	RB	Overt=Yes|Stop=Yes|Alpha=Yes|Degree=Pos|Foreign=No	11	neg	_	_
11	stop	stop	VERB	VB	Overt=Yes|Stop=No|Alpha=Yes|VerbForm=Inf|Foreign=No	2	conj	_	_
12	the	the	DET	DT	Overt=Yes|Stop=Yes|Alpha=Yes|Foreign=No	15	det	_	_
13	intrepid	intrepid	ADJ	JJ	Overt=Yes|Stop=No|Alpha=Yes|Degree=Pos|Foreign=No	15	amod	_	_
14	Nlp	nlp	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	15	compound	_	_
15	Lab	lab	PROPN	NNP	Overt=Yes|Stop=No|Alpha=Yes|NounType=Prop|Number=Sing|Foreign=No	11	dobj	_	_
16	.	.	PUNCT	.	Overt=Yes|Stop=No|Alpha=No|PunctType=Peri|Foreign=No	11	punct	_	_"""
        actual = XrennerPipeline().process_conll(conll, )
        expected = OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('documents', {1: OrderedDict([('meta', OrderedDict([('DC.conformsTo', '0.2.6'), ('DC.source', 'Xrenner 2.0'), ('DC.created', '2019-01-25T17:04:34'), ('DC.date', '2019-01-25T17:04:34')])), ('id', 1), ('conllId', '1'), ('tokenList', {1: {'id': 1, 'text': 'The', 'lemma': 'the', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 2: {'id': 2, 'text': 'Mueller', 'lemma': 'mueller', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 3: {'id': 3, 'text': 'Report', 'lemma': 'report', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 4: {'id': 4, 'text': 'is', 'lemma': 'be', 'upos': 'VERB', 'xpos': 'VBZ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Pres'), ('Number', 'Sing'), ('Person', '3'), ('Foreign', 'No')])}, 5: {'id': 5, 'text': 'a', 'lemma': 'a', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 6: {'id': 6, 'text': 'very', 'lemma': 'very', 'upos': 'ADV', 'xpos': 'RB', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 7: {'id': 7, 'text': 'long', 'lemma': 'long', 'upos': 'ADJ', 'xpos': 'JJ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 8: {'id': 8, 'text': 'report', 'lemma': 'report', 'upos': 'NOUN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Sing'), ('Foreign', 'No')])}, 9: {'id': 9, 'text': '.', 'lemma': '.', 'upos': 'PUNCT', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Peri'), ('Foreign', 'No')])}, 10: {'id': 10, 'text': 'We', 'lemma': 'we', 'upos': 'PRON', 'xpos': 'PRP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('PronType', 'Prs'), ('Foreign', 'No')])}, 11: {'id': 11, 'text': 'spent', 'lemma': 'spend', 'upos': 'VERB', 'xpos': 'VBD', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Past'), ('Foreign', 'No')])}, 12: {'id': 12, 'text': 'a', 'lemma': 'a', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 13: {'id': 13, 'text': 'long', 'lemma': 'long', 'upos': 'ADJ', 'xpos': 'JJ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 14: {'id': 14, 'text': 'time', 'lemma': 'time', 'upos': 'NOUN', 'xpos': 'NN', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Number', 'Sing'), ('Foreign', 'No')])}, 15: {'id': 15, 'text': 'analyzing', 'lemma': 'analyze', 'upos': 'VERB', 'xpos': 'VBG', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Part'), ('Tense', 'Pres'), ('Aspect', 'Prog'), ('Foreign', 'No')])}, 16: {'id': 16, 'text': 'it', 'lemma': 'it', 'upos': 'PRON', 'xpos': 'PRP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('PronType', 'Prs'), ('Foreign', 'No')])}, 17: {'id': 17, 'text': '.', 'lemma': '.', 'upos': 'PUNCT', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Peri'), ('Foreign', 'No')])}, 18: {'id': 18, 'text': 'Trump', 'lemma': 'trump', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 19: {'id': 19, 'text': 'wishes', 'lemma': 'wish', 'upos': 'VERB', 'xpos': 'VBZ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Pres'), ('Number', 'Sing'), ('Person', '3'), ('Foreign', 'No')])}, 20: {'id': 20, 'text': 'we', 'lemma': 'we', 'upos': 'PRON', 'xpos': 'PRP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('PronType', 'Prs'), ('Foreign', 'No')])}, 21: {'id': 21, 'text': 'did', 'lemma': 'do', 'upos': 'VERB', 'xpos': 'VBD', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Past'), ('Foreign', 'No')])}, 22: {'id': 22, 'text': 'not', 'lemma': 'not', 'upos': 'ADV', 'xpos': 'RB', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 23: {'id': 23, 'text': ',', 'lemma': ',', 'upos': 'PUNCT', 'xpos': ',', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Comm'), ('Foreign', 'No')])}, 24: {'id': 24, 'text': 'but', 'lemma': 'but', 'upos': 'CCONJ', 'xpos': 'CC', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('ConjType', 'Coor'), ('Foreign', 'No')])}, 25: {'id': 25, 'text': 'that', 'lemma': 'that', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 26: {'id': 26, 'text': 'did', 'lemma': 'do', 'upos': 'VERB', 'xpos': 'VBD', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('VerbForm', 'Fin'), ('Tense', 'Past'), ('Foreign', 'No')])}, 27: {'id': 27, 'text': 'not', 'lemma': 'not', 'upos': 'ADV', 'xpos': 'RB', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 28: {'id': 28, 'text': 'stop', 'lemma': 'stop', 'upos': 'VERB', 'xpos': 'VB', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('VerbForm', 'Inf'), ('Foreign', 'No')])}, 29: {'id': 29, 'text': 'the', 'lemma': 'the', 'upos': 'DET', 'xpos': 'DT', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'Yes'), ('Alpha', 'Yes'), ('Foreign', 'No')])}, 30: {'id': 30, 'text': 'intrepid', 'lemma': 'intrepid', 'upos': 'ADJ', 'xpos': 'JJ', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('Degree', 'Pos'), ('Foreign', 'No')])}, 31: {'id': 31, 'text': 'Nlp', 'lemma': 'nlp', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 32: {'id': 32, 'text': 'Lab', 'lemma': 'lab', 'upos': 'PROPN', 'xpos': 'NNP', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'Yes'), ('NounType', 'Prop'), ('Number', 'Sing'), ('Foreign', 'No')])}, 33: {'id': 33, 'text': '.', 'lemma': '.', 'upos': 'PUNCT', 'xpos': '.', 'features': OrderedDict([('Overt', 'Yes'), ('Stop', 'No'), ('Alpha', 'No'), ('PunctType', 'Peri'), ('Foreign', 'No')])}}), ('sentences', {0: {'id': 0, 'conllId': '', 'tokenFrom': 1, 'tokenTo': 10, 'tokens': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, 1: {'id': 1, 'conllId': '', 'tokenFrom': 10, 'tokenTo': 18, 'tokens': [10, 11, 12, 13, 14, 15, 16, 17]}, 2: {'id': 2, 'conllId': '', 'tokenFrom': 18, 'tokenTo': 34, 'tokens': [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]}}), ('dependencies', [{'style': 'universal', 'arcs': {1: [{'label': 'det', 'governor': 3, 'dependent': 1}], 2: [{'label': 'compound', 'governor': 3, 'dependent': 2}], 3: [{'label': 'nsubj', 'governor': 4, 'dependent': 3}], 4: [{'label': 'root', 'governor': 0, 'dependent': 4}], 5: [{'label': 'det', 'governor': 8, 'dependent': 5}], 6: [{'label': 'advmod', 'governor': 7, 'dependent': 6}], 7: [{'label': 'amod', 'governor': 8, 'dependent': 7}], 8: [{'label': 'attr', 'governor': 4, 'dependent': 8}], 9: [{'label': 'punct', 'governor': 4, 'dependent': 9}], 10: [{'label': 'nsubj', 'governor': 11, 'dependent': 10}], 11: [{'label': 'root', 'governor': 0, 'dependent': 11}], 12: [{'label': 'det', 'governor': 14, 'dependent': 12}], 13: [{'label': 'amod', 'governor': 14, 'dependent': 13}], 14: [{'label': 'dobj', 'governor': 11, 'dependent': 14}], 15: [{'label': 'xcomp', 'governor': 11, 'dependent': 15}], 16: [{'label': 'dobj', 'governor': 15, 'dependent': 16}], 17: [{'label': 'punct', 'governor': 11, 'dependent': 17}], 18: [{'label': 'nsubj', 'governor': 19, 'dependent': 18}], 19: [{'label': 'root', 'governor': 0, 'dependent': 19}], 20: [{'label': 'nsubj', 'governor': 21, 'dependent': 20}], 21: [{'label': 'ccomp', 'governor': 19, 'dependent': 21}], 22: [{'label': 'neg', 'governor': 21, 'dependent': 22}], 23: [{'label': 'punct', 'governor': 19, 'dependent': 23}], 24: [{'label': 'cc', 'governor': 19, 'dependent': 24}], 25: [{'label': 'nsubj', 'governor': 28, 'dependent': 25}], 26: [{'label': 'aux', 'governor': 28, 'dependent': 26}], 27: [{'label': 'neg', 'governor': 28, 'dependent': 27}], 28: [{'label': 'conj', 'governor': 19, 'dependent': 28}], 29: [{'label': 'det', 'governor': 32, 'dependent': 29}], 30: [{'label': 'amod', 'governor': 32, 'dependent': 30}], 31: [{'label': 'compound', 'governor': 32, 'dependent': 31}], 32: [{'label': 'dobj', 'governor': 28, 'dependent': 32}], 33: [{'label': 'punct', 'governor': 28, 'dependent': 33}]}}, {'style': 'enhanced', 'arcs': {}}])])})])
        assert expected == actual, actual

    def test_iso2xrenner(self):
        actual = XrennerPipeline().iso2xrenner('en')
        assert 'eng' == actual, actual

        with pytest.raises(TypeError):
            XrennerPipeline().iso2xrenner('martian')
