| Server IP : 54.37.205.81 / Your IP : 216.73.216.76 Web Server : nginx/1.22.1 System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64 User : debian ( 1000) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/nltk/app/__pycache__/ |
Upload File : |
�
T�czN � �^ � d Z ddlZddlZddlmZmZmZmZm Z m
Z
mZmZm
Z
mZ ddlmZmZ ddlmZ ddlmZmZ ddlmZmZmZ ddlmZmZmZmZm Z m!Z! dd l"m#Z#m$Z$ dd
l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 G d
� de� � Z4 G d� d� � Z5 G d� d� � Z6 G d� d� � Z7 G d� d� � Z8 G d� d� � Z9 G d� de9e.� � Z: G d� de9e'� � Z; G d� de9e&� � Z< G d� d e9e+� � Z= G d!� d"� � Z>d#� Z?e@d$k r
e?� � d%gZAdS )&a�
A graphical tool for exploring chart parsing.
Chart parsing is a flexible parsing algorithm that uses a data
structure called a "chart" to record hypotheses about syntactic
constituents. Each hypothesis is represented by a single "edge" on
the chart. A set of "chart rules" determine when new edges can be
added to the chart. This set of rules controls the overall behavior
of the parser (e.g. whether it parses top-down or bottom-up).
The chart parsing tool demonstrates the process of parsing a single
sentence, with a given grammar and lexicon. Its display is divided
into three sections: the bottom section displays the chart; the middle
section displays the sentence; and the top section displays the
partial syntax tree corresponding to the selected edge. Buttons along
the bottom of the window are used to control the execution of the
algorithm.
The chart parsing tool allows for flexible control of the parsing
algorithm. At each step of the algorithm, you can select which rule
or strategy you wish to apply. This allows you to experiment with
mixing different strategies (e.g. top-down and bottom-up). You can
exercise fine-grained control over the algorithm by selecting which
edge you wish to apply a rule to.
� N)
�Button�Canvas�Checkbutton�Frame�IntVar�Label�Menu� Scrollbar�Tk�Toplevel)�askopenfilename�asksaveasfilename)�Font)� showerror�showinfo)� CFGEditor�TreeSegmentWidget�tree_to_treesegment)�CanvasFrame�
ColorizedList�EntryDialog�MutableOptionMenu�ShowText�SymbolWidget)�CFG�Nonterminal)
�BottomUpPredictCombineRule�BottomUpPredictRule�Chart�LeafEdge�LeafInitRule�SingleEdgeFundamentalRule�SteppingChartParser�TopDownInitRule�TopDownPredictRule�TreeEdge)�Tree)�in_idlec �4 � e Zd Zej d Zd� Zd� ZdS )�EdgeList�
rightarrowc �� � |� dd�� � |� ddd�� � |� dd �� � |� d
dd�
� � d S )N�terminalz#006000)�
foreground�arrow�symbol�0)�font� underline�dotz#000000�nonterminal�blue)� helvetica���bold)r. r2 )�
tag_config)�self�
textwidget�optionss �:/usr/lib/python3/dist-packages/nltk/app/chartparser_app.py�_init_colortagszEdgeList._init_colortags^ s~ � ����j�Y��?�?�?����g�H���D�D�D����e� ��:�:�:�����f�3M� �
�
�
�
�
� c �L � g }|� d|� � � z df� � |� | j df� � t |� � � � � D ]�\ }}||� � � k r|� d� � t
|t � � r-|� d|� � � z df� � �t|� d|z df� � ��|� � � r|� d� � |S )Nz%s r5 r/ )z *r4 z %sz %rr- )
�append�lhs�ARROW� enumerate�rhsr4 �
isinstancer r0 �is_complete)r; �item�contents�i�elts r>