o
    hQ                     @   s   d Z ddlmZ ddlZddlmZmZmZmZ ej	j
ej	jgZejdd Zejdd Zd	d
d Zdd
d Zdd
d Zdd Zdd Zdd Zdd Zdd ZdS )z<
Test a couple simple confusion matrices and output formats
    defaultdictN)format_confusionconfusion_to_f1confusion_to_macro_f1confusion_to_weighted_f1c                  C   sL   t dd } d| d d< d| d d< d| d d< d| d d< d| d	 d	< | S )
Nc                   S      t tS Nr   int r   r   ]/var/www/html/env_mimamsha/lib/python3.10/site-packages/stanza/tests/common/test_confusion.py<lambda>       z"simple_confusion.<locals>.<lambda>   B-ORGB-PERE-ORGE-PER   Or   	confusionr   r   r   simple_confusion   s   r   c                  C   sL   t dd } d| d d< d| d d< d| d d< d| d d< d	| d
 d
< | S )zV
    Same thing, but with a short name.  This should not be sorted by entity type
    c                   S   r   r	   r
   r   r   r   r   r      r   z!short_confusion.<locals>.<lambda>r   Ar   r   r   r   r   r   r   r   r   r   r   short_confusion   s   r   z
     t\p      O B-ORG E-ORG B-PER E-PER
        O     4     0     0     0     0
    B-ORG     0     1     0     1     0
    E-ORG     0     0     1     0     1
    B-PER     0     0     0     0     0
    E-PER     0     0     0     0     0
r   aC  
     t\p      O     A B-ORG B-PER E-ORG E-PER
        O     4     0     0     0     0     0
        A     0     0     1     0     0     0
    B-ORG     0     0     0     1     0     0
    B-PER     0     0     0     0     0     0
    E-ORG     0     0     0     0     1     1
    E-PER     0     0     0     0     0     0
z
     t\p      O B-ORG E-ORG B-PER E-PER
        O     4     0     0     0     0
        A     0     1     0     0     0
    B-ORG     0     0     0     1     0
    E-ORG     0     0     1     0     1
c                 C      t t| ksJ d S r	   )EXPECTED_SIMPLE_OUTPUTr   )r   r   r   r   test_simple_output>      r   c                 C   r   r	   )EXPECTED_SHORT_OUTPUTr   r   r   r   r   test_short_outputA   r    r#   c                 C   s   t t| ddks
J d S )NT)
hide_blank) EXPECTED_HIDE_BLANK_SHORT_OUTPUTr   r"   r   r   r   test_hide_blank_short_outputD   s   r&   c                 C   s0   t | tdksJ t |tdksJ d S )Ng?gq?)r   pytestapproxr   r   r   r   r   test_macro_f1G   s   r*   c                 C   sh   t | tdksJ t |tdksJ t | dgdtdks$J t |dgdtdks2J d S )Ngmਪ?gQUU?r   )excludegQUU?)r   r'   r(   r)   r   r   r   test_weighted_f1K   s    r,   )__doc__collectionsr   r'   stanza.utils.confusionr   r   r   r   marktravispipeline
pytestmarkfixturer   r   r   r!   r%   r   r#   r&   r*   r,   r   r   r   r   <module>   s.    
	
	
