Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
wzm | 84618cc26d | 1 day ago |
wzm | 7c691763d9 | 3 weeks ago |
张荣杰 | de667a2b17 | 3 weeks ago |
张荣杰 | bb625c67b8 | 3 weeks ago |
张荣杰 | 57aa171824 | 2 months ago |
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1,534 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DBNavigator.Project.DDLFileAttachmentManager">
|
||||
<mappings />
|
||||
<preferences />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DataEditorManager">
|
||||
<record-view-column-sorting-type value="BY_INDEX" />
|
||||
<value-preview-text-wrapping value="false" />
|
||||
<value-preview-pinned value="false" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseBrowserManager">
|
||||
<autoscroll-to-editor value="false" />
|
||||
<autoscroll-from-editor value="true" />
|
||||
<show-object-properties value="false" />
|
||||
<loaded-nodes />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseConsoleManager">
|
||||
<connection id="cd894dbb-c4e6-4017-8a04-275b1069cb92">
|
||||
<console name="Connection" type="STANDARD" schema="mysql" session="Main" />
|
||||
</connection>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseEditorStateManager">
|
||||
<last-used-providers />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseFileManager">
|
||||
<open-files />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatabaseSessionManager">
|
||||
<connection id="cd894dbb-c4e6-4017-8a04-275b1069cb92" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.DatasetFilterManager">
|
||||
<filter-actions connection-id="cd894dbb-c4e6-4017-8a04-275b1069cb92" dataset="mysql.columns_priv" active-filter-id="" />
|
||||
<filter-actions connection-id="cd894dbb-c4e6-4017-8a04-275b1069cb92" dataset="sakila.actor" active-filter-id="" />
|
||||
<filter-actions connection-id="cd894dbb-c4e6-4017-8a04-275b1069cb92" dataset="mysql.db" active-filter-id="" />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.ObjectQuickFilterManager">
|
||||
<last-used-operator value="EQUAL" />
|
||||
<filters />
|
||||
</component>
|
||||
<component name="DBNavigator.Project.Settings">
|
||||
<connections>
|
||||
<connection id="cd894dbb-c4e6-4017-8a04-275b1069cb92" active="true" signed="true">
|
||||
<database>
|
||||
<name value="Connection" />
|
||||
<description value="test1" />
|
||||
<database-type value="MYSQL" />
|
||||
<config-type value="BASIC" />
|
||||
<database-version value="8.0" />
|
||||
<driver-source value="BUNDLED" />
|
||||
<driver-library value="" />
|
||||
<driver value="" />
|
||||
<url-type value="DATABASE" />
|
||||
<host value="localhost" />
|
||||
<port value="3306" />
|
||||
<database value="mysql" />
|
||||
<tns-folder value="" />
|
||||
<tns-profile value="" />
|
||||
<type value="USER_PASSWORD" />
|
||||
<user value="root" />
|
||||
<deprecated-pwd value="MTIzNDU2" />
|
||||
</database>
|
||||
<properties>
|
||||
<auto-commit value="true" />
|
||||
</properties>
|
||||
<ssh-settings>
|
||||
<active value="false" />
|
||||
<proxy-host value="" />
|
||||
<proxy-port value="22" />
|
||||
<proxy-user value="" />
|
||||
<deprecated-proxy-pwd value="" />
|
||||
<auth-type value="PASSWORD" />
|
||||
<key-file value="" />
|
||||
<key-passphrase value="" />
|
||||
</ssh-settings>
|
||||
<ssl-settings>
|
||||
<active value="false" />
|
||||
<certificate-authority-file value="" />
|
||||
<client-certificate-file value="" />
|
||||
<client-key-file value="" />
|
||||
</ssl-settings>
|
||||
<details>
|
||||
<charset value="UTF-8" />
|
||||
<session-management value="true" />
|
||||
<ddl-file-binding value="true" />
|
||||
<database-logging value="true" />
|
||||
<connect-automatically value="true" />
|
||||
<restore-workspace value="true" />
|
||||
<restore-workspace-deep value="false" />
|
||||
<environment-type value="default" />
|
||||
<connectivity-timeout value="30" />
|
||||
<idle-time-to-disconnect value="30" />
|
||||
<idle-time-to-disconnect-pool value="5" />
|
||||
<credential-expiry-time value="10" />
|
||||
<max-connection-pool-size value="7" />
|
||||
<alternative-statement-delimiter value="" />
|
||||
</details>
|
||||
<debugger>
|
||||
<compile-dependencies value="true" />
|
||||
<tcp-driver-tunneling value="false" />
|
||||
<tcp-host-address value="" />
|
||||
<tcp-port-from value="4000" />
|
||||
<tcp-port-to value="4999" />
|
||||
<debugger-type value="JDBC" />
|
||||
</debugger>
|
||||
<object-filters hide-empty-schemas="false" hide-pseudo-columns="false" hide-audit-columns="false">
|
||||
<object-filters />
|
||||
<object-type-filter use-master-settings="true">
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="true" />
|
||||
<object-type name="ROLE" enabled="true" />
|
||||
<object-type name="PRIVILEGE" enabled="true" />
|
||||
<object-type name="CHARSET" enabled="true" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||
<object-type name="NESTED_TABLE" enabled="true" />
|
||||
<object-type name="COLUMN" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="true" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||
<object-type name="ARGUMENT" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="true" />
|
||||
<object-type name="CLUSTER" enabled="true" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</object-type-filter>
|
||||
</object-filters>
|
||||
</connection>
|
||||
</connections>
|
||||
<browser-settings>
|
||||
<general>
|
||||
<display-mode value="TABBED" />
|
||||
<navigation-history-size value="100" />
|
||||
<show-object-details value="false" />
|
||||
<enable-sticky-paths value="true" />
|
||||
</general>
|
||||
<filters>
|
||||
<object-type-filter>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="true" />
|
||||
<object-type name="ROLE" enabled="true" />
|
||||
<object-type name="PRIVILEGE" enabled="true" />
|
||||
<object-type name="CHARSET" enabled="true" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||
<object-type name="NESTED_TABLE" enabled="true" />
|
||||
<object-type name="COLUMN" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="true" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||
<object-type name="ARGUMENT" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="true" />
|
||||
<object-type name="CLUSTER" enabled="true" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</object-type-filter>
|
||||
</filters>
|
||||
<sorting>
|
||||
<object-type name="COLUMN" sorting-type="NAME" />
|
||||
<object-type name="FUNCTION" sorting-type="NAME" />
|
||||
<object-type name="PROCEDURE" sorting-type="NAME" />
|
||||
<object-type name="ARGUMENT" sorting-type="POSITION" />
|
||||
<object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" />
|
||||
</sorting>
|
||||
<default-editors>
|
||||
<object-type name="VIEW" editor-type="SELECTION" />
|
||||
<object-type name="PACKAGE" editor-type="SELECTION" />
|
||||
<object-type name="TYPE" editor-type="SELECTION" />
|
||||
</default-editors>
|
||||
</browser-settings>
|
||||
<navigation-settings>
|
||||
<lookup-filters>
|
||||
<lookup-objects>
|
||||
<object-type name="SCHEMA" enabled="true" />
|
||||
<object-type name="USER" enabled="false" />
|
||||
<object-type name="ROLE" enabled="false" />
|
||||
<object-type name="PRIVILEGE" enabled="false" />
|
||||
<object-type name="CHARSET" enabled="false" />
|
||||
<object-type name="TABLE" enabled="true" />
|
||||
<object-type name="VIEW" enabled="true" />
|
||||
<object-type name="MATERIALIZED VIEW" enabled="true" />
|
||||
<object-type name="INDEX" enabled="true" />
|
||||
<object-type name="CONSTRAINT" enabled="true" />
|
||||
<object-type name="DATASET TRIGGER" enabled="true" />
|
||||
<object-type name="DATABASE TRIGGER" enabled="true" />
|
||||
<object-type name="SYNONYM" enabled="false" />
|
||||
<object-type name="SEQUENCE" enabled="true" />
|
||||
<object-type name="PROCEDURE" enabled="true" />
|
||||
<object-type name="FUNCTION" enabled="true" />
|
||||
<object-type name="PACKAGE" enabled="true" />
|
||||
<object-type name="TYPE" enabled="true" />
|
||||
<object-type name="DIMENSION" enabled="false" />
|
||||
<object-type name="CLUSTER" enabled="false" />
|
||||
<object-type name="DBLINK" enabled="true" />
|
||||
</lookup-objects>
|
||||
<force-database-load value="false" />
|
||||
<prompt-connection-selection value="true" />
|
||||
<prompt-schema-selection value="true" />
|
||||
</lookup-filters>
|
||||
</navigation-settings>
|
||||
<dataset-grid-settings>
|
||||
<general>
|
||||
<enable-zooming value="true" />
|
||||
<enable-column-tooltip value="true" />
|
||||
</general>
|
||||
<sorting>
|
||||
<nulls-first value="true" />
|
||||
<max-sorting-columns value="4" />
|
||||
</sorting>
|
||||
<audit-columns>
|
||||
<column-names value="" />
|
||||
<visible value="true" />
|
||||
<editable value="false" />
|
||||
</audit-columns>
|
||||
</dataset-grid-settings>
|
||||
<dataset-editor-settings>
|
||||
<text-editor-popup>
|
||||
<active value="false" />
|
||||
<active-if-empty value="false" />
|
||||
<data-length-threshold value="100" />
|
||||
<popup-delay value="1000" />
|
||||
</text-editor-popup>
|
||||
<values-actions-popup>
|
||||
<show-popup-button value="true" />
|
||||
<element-count-threshold value="1000" />
|
||||
<data-length-threshold value="250" />
|
||||
</values-actions-popup>
|
||||
<general>
|
||||
<fetch-block-size value="100" />
|
||||
<fetch-timeout value="30" />
|
||||
<trim-whitespaces value="true" />
|
||||
<convert-empty-strings-to-null value="true" />
|
||||
<select-content-on-cell-edit value="true" />
|
||||
<large-value-preview-active value="true" />
|
||||
</general>
|
||||
<filters>
|
||||
<prompt-filter-dialog value="true" />
|
||||
<default-filter-type value="BASIC" />
|
||||
</filters>
|
||||
<qualified-text-editor text-length-threshold="300">
|
||||
<content-types>
|
||||
<content-type name="Text" enabled="true" />
|
||||
<content-type name="Properties" enabled="true" />
|
||||
<content-type name="XML" enabled="true" />
|
||||
<content-type name="DTD" enabled="true" />
|
||||
<content-type name="HTML" enabled="true" />
|
||||
<content-type name="XHTML" enabled="true" />
|
||||
<content-type name="SQL" enabled="true" />
|
||||
<content-type name="PL/SQL" enabled="true" />
|
||||
<content-type name="JSON" enabled="true" />
|
||||
<content-type name="JSON5" enabled="true" />
|
||||
<content-type name="YAML" enabled="true" />
|
||||
</content-types>
|
||||
</qualified-text-editor>
|
||||
<record-navigation>
|
||||
<navigation-target value="VIEWER" />
|
||||
</record-navigation>
|
||||
</dataset-editor-settings>
|
||||
<code-editor-settings>
|
||||
<general>
|
||||
<show-object-navigation-gutter value="false" />
|
||||
<show-spec-declaration-navigation-gutter value="true" />
|
||||
<enable-spellchecking value="true" />
|
||||
<enable-reference-spellchecking value="false" />
|
||||
</general>
|
||||
<confirmations>
|
||||
<save-changes value="false" />
|
||||
<revert-changes value="true" />
|
||||
<exit-on-changes value="ASK" />
|
||||
</confirmations>
|
||||
</code-editor-settings>
|
||||
<code-completion-settings>
|
||||
<filters>
|
||||
<basic-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="false" />
|
||||
<filter-element type="OBJECT" id="view" selected="false" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="false" />
|
||||
<filter-element type="OBJECT" id="index" selected="false" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="false" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="false" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="false" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="false" />
|
||||
<filter-element type="OBJECT" id="function" selected="false" />
|
||||
<filter-element type="OBJECT" id="package" selected="false" />
|
||||
<filter-element type="OBJECT" id="type" selected="false" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="false" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="false" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="false" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</basic-filter>
|
||||
<extended-filter>
|
||||
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||
<filter-element type="OBJECT" id="user" selected="true" />
|
||||
<filter-element type="OBJECT" id="role" selected="true" />
|
||||
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||
<user-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</user-schema>
|
||||
<public-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</public-schema>
|
||||
<any-schema>
|
||||
<filter-element type="OBJECT" id="table" selected="true" />
|
||||
<filter-element type="OBJECT" id="view" selected="true" />
|
||||
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||
<filter-element type="OBJECT" id="index" selected="true" />
|
||||
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||
<filter-element type="OBJECT" id="function" selected="true" />
|
||||
<filter-element type="OBJECT" id="package" selected="true" />
|
||||
<filter-element type="OBJECT" id="type" selected="true" />
|
||||
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||
</any-schema>
|
||||
</extended-filter>
|
||||
</filters>
|
||||
<sorting enabled="true">
|
||||
<sorting-element type="RESERVED_WORD" id="keyword" />
|
||||
<sorting-element type="RESERVED_WORD" id="datatype" />
|
||||
<sorting-element type="OBJECT" id="column" />
|
||||
<sorting-element type="OBJECT" id="table" />
|
||||
<sorting-element type="OBJECT" id="view" />
|
||||
<sorting-element type="OBJECT" id="materialized view" />
|
||||
<sorting-element type="OBJECT" id="index" />
|
||||
<sorting-element type="OBJECT" id="constraint" />
|
||||
<sorting-element type="OBJECT" id="trigger" />
|
||||
<sorting-element type="OBJECT" id="synonym" />
|
||||
<sorting-element type="OBJECT" id="sequence" />
|
||||
<sorting-element type="OBJECT" id="procedure" />
|
||||
<sorting-element type="OBJECT" id="function" />
|
||||
<sorting-element type="OBJECT" id="package" />
|
||||
<sorting-element type="OBJECT" id="type" />
|
||||
<sorting-element type="OBJECT" id="dimension" />
|
||||
<sorting-element type="OBJECT" id="cluster" />
|
||||
<sorting-element type="OBJECT" id="dblink" />
|
||||
<sorting-element type="OBJECT" id="schema" />
|
||||
<sorting-element type="OBJECT" id="role" />
|
||||
<sorting-element type="OBJECT" id="user" />
|
||||
<sorting-element type="RESERVED_WORD" id="function" />
|
||||
<sorting-element type="RESERVED_WORD" id="parameter" />
|
||||
</sorting>
|
||||
<format>
|
||||
<enforce-code-style-case value="true" />
|
||||
</format>
|
||||
</code-completion-settings>
|
||||
<execution-engine-settings>
|
||||
<statement-execution>
|
||||
<fetch-block-size value="100" />
|
||||
<execution-timeout value="20" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<focus-result value="false" />
|
||||
<prompt-execution value="false" />
|
||||
</statement-execution>
|
||||
<script-execution>
|
||||
<command-line-interfaces />
|
||||
<execution-timeout value="300" />
|
||||
</script-execution>
|
||||
<method-execution>
|
||||
<execution-timeout value="30" />
|
||||
<debug-execution-timeout value="600" />
|
||||
<parameter-history-size value="10" />
|
||||
</method-execution>
|
||||
</execution-engine-settings>
|
||||
<operation-settings>
|
||||
<transactions>
|
||||
<uncommitted-changes>
|
||||
<on-project-close value="ASK" />
|
||||
<on-disconnect value="ASK" />
|
||||
<on-autocommit-toggle value="ASK" />
|
||||
</uncommitted-changes>
|
||||
<multiple-uncommitted-changes>
|
||||
<on-commit value="ASK" />
|
||||
<on-rollback value="ASK" />
|
||||
</multiple-uncommitted-changes>
|
||||
</transactions>
|
||||
<session-browser>
|
||||
<disconnect-session value="ASK" />
|
||||
<kill-session value="ASK" />
|
||||
<reload-on-filter-change value="false" />
|
||||
</session-browser>
|
||||
<compiler>
|
||||
<compile-type value="KEEP" />
|
||||
<compile-dependencies value="ASK" />
|
||||
<always-show-controls value="false" />
|
||||
</compiler>
|
||||
</operation-settings>
|
||||
<ddl-file-settings>
|
||||
<extensions>
|
||||
<mapping file-type-id="VIEW" extensions="vw" />
|
||||
<mapping file-type-id="TRIGGER" extensions="trg" />
|
||||
<mapping file-type-id="PROCEDURE" extensions="prc" />
|
||||
<mapping file-type-id="FUNCTION" extensions="fnc" />
|
||||
<mapping file-type-id="PACKAGE" extensions="pkg" />
|
||||
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
|
||||
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
|
||||
<mapping file-type-id="TYPE" extensions="tpe" />
|
||||
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
|
||||
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
|
||||
</extensions>
|
||||
<general>
|
||||
<lookup-ddl-files value="true" />
|
||||
<create-ddl-files value="false" />
|
||||
<synchronize-ddl-files value="true" />
|
||||
<use-qualified-names value="false" />
|
||||
<make-scripts-rerunnable value="true" />
|
||||
</general>
|
||||
</ddl-file-settings>
|
||||
<general-settings>
|
||||
<regional-settings>
|
||||
<date-format value="MEDIUM" />
|
||||
<number-format value="UNGROUPED" />
|
||||
<locale value="SYSTEM_DEFAULT" />
|
||||
<use-custom-formats value="false" />
|
||||
</regional-settings>
|
||||
<environment>
|
||||
<environment-types>
|
||||
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
|
||||
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
|
||||
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
|
||||
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
|
||||
</environment-types>
|
||||
<visibility-settings>
|
||||
<connection-tabs value="true" />
|
||||
<dialog-headers value="true" />
|
||||
<object-editor-tabs value="true" />
|
||||
<script-editor-tabs value="false" />
|
||||
<execution-result-tabs value="true" />
|
||||
</visibility-settings>
|
||||
</environment>
|
||||
</general-settings>
|
||||
</component>
|
||||
<component name="DBNavigator.Project.StatementExecutionManager">
|
||||
<execution-variables />
|
||||
<execution-variable-types />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
|
@ -0,0 +1,455 @@
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, ttk
|
||||
import pymysql
|
||||
import datetime
|
||||
import time
|
||||
import 评论总结
|
||||
import 招生信息
|
||||
import pyperclip
|
||||
#import ttkbootstrap as ttk
|
||||
from test import QuestionnaireGUI
|
||||
|
||||
class MasterChargeSystem(tk.Tk):
|
||||
current_username=None
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.login_frame = None
|
||||
self.register_frame = None
|
||||
self.test_frame = None
|
||||
self.detail_window = None
|
||||
self.summary_window = None
|
||||
self.create_login_window()
|
||||
|
||||
def register_database(self, username, password):
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql = "INSERT INTO user1(username, password) VALUES (%s, %s)"
|
||||
cursor.execute(sql, (username, password))
|
||||
connection.commit()
|
||||
|
||||
def login(self):
|
||||
global current_username
|
||||
username = self.username_entry.get().strip()
|
||||
password = self.password_entry.get().strip()
|
||||
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
current_username=username
|
||||
sql = "SELECT password FROM user1 WHERE username = %s"
|
||||
cursor.execute(sql, (username,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if result:
|
||||
stored_password = result[0]
|
||||
if stored_password == password:
|
||||
messagebox.showinfo("登录", "登陆成功")
|
||||
self.show_main_window()
|
||||
else:
|
||||
messagebox.showerror("登录", "用户名或密码错误")
|
||||
else:
|
||||
messagebox.showerror("登录", "用户名不存在")
|
||||
|
||||
def register(self):
|
||||
username = self.username_entry.get().strip()
|
||||
password = self.password_entry.get().strip()
|
||||
confirm_password = self.confirm_password_entry.get().strip()
|
||||
|
||||
if username and password:
|
||||
if password == confirm_password:
|
||||
self.register_database(username, password)
|
||||
messagebox.showinfo("注册", "注册成功")
|
||||
self.create_login_window()
|
||||
else:
|
||||
messagebox.showerror("注册", "两次输入的密码不匹配")
|
||||
else:
|
||||
messagebox.showerror("注册", "用户名或密码为空")
|
||||
|
||||
def show_main_window(self):
|
||||
if self.login_frame:
|
||||
self.login_frame.pack_forget()
|
||||
if self.detail_window:
|
||||
self.detail_window.pack_forget()
|
||||
if self.test_frame:
|
||||
self.test_frame.pack_forget()
|
||||
|
||||
self.title("考研信息系统")
|
||||
self.attributes('-fullscreen',True)
|
||||
|
||||
self.main_frame = tk.Frame(self)
|
||||
self.main_frame.pack(fill=tk.BOTH, expand=True, padx=50, pady=50)
|
||||
|
||||
main_label = tk.Label(self.main_frame, text="欢迎来到考研信息系统!")
|
||||
main_label.pack(pady=10)
|
||||
|
||||
|
||||
try:
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
|
||||
# 添加搜索框
|
||||
search_frame = tk.Frame(self.main_frame)
|
||||
search_frame.pack(pady=10)
|
||||
|
||||
search_label = tk.Label(search_frame, text="搜索:地区")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
cursor.execute("select distinct 省份 from universities_beijing")
|
||||
location = cursor.fetchall()
|
||||
|
||||
self.search2_entry = ttk.Combobox(search_frame, values=location)
|
||||
self.search2_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
cursor.execute("select distinct 招生年份 from universities_beijing")
|
||||
year = cursor.fetchall()
|
||||
|
||||
search_label = tk.Label(search_frame, text=" 年份")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search3_entry = ttk.Combobox(search_frame, values=year)
|
||||
self.search3_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
cursor.execute("select distinct 学校类型 from universities_beijing")
|
||||
time = cursor.fetchall()
|
||||
|
||||
search_label = tk.Label(search_frame, text=" 学校类型")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search4_entry = ttk.Combobox(search_frame, values=time)
|
||||
self.search4_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
search_label = tk.Label(search_frame, text=" 院校")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search1_entry = tk.Entry(search_frame)
|
||||
self.search1_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
search_label = tk.Label(search_frame, text=" 评论总结")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search5_entry = tk.Entry(search_frame)
|
||||
self.search5_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
affirm_button = tk.Button(search_frame, text="确认", command=self.search_data)
|
||||
affirm_button.pack(side=tk.RIGHT)
|
||||
|
||||
|
||||
# 创建一个用于 Treeview 和滚动条的框架
|
||||
tree_frame = tk.Frame(self.main_frame)
|
||||
tree_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
self.tree = ttk.Treeview(tree_frame)
|
||||
|
||||
self.vertical_scrollbar = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL, command=self.tree.yview)
|
||||
|
||||
self.tree.configure(yscrollcommand=self.vertical_scrollbar.set)
|
||||
|
||||
# 获取列名
|
||||
cursor.execute("SELECT * FROM universities_beijing LIMIT 0") # 替换为您的表名
|
||||
self.columns = [description[0] for description in cursor.description]
|
||||
|
||||
# 获取数据
|
||||
cursor.execute("SELECT * FROM universities_beijing") # 获取所有数据
|
||||
self.data = cursor.fetchall()
|
||||
|
||||
# 设置列
|
||||
self.tree['columns'] = self.columns
|
||||
self.tree.column("#0", width=0, stretch=tk.NO) # 隐藏第一个空列
|
||||
|
||||
# 动态设置列和列名
|
||||
for column in self.columns:
|
||||
self.tree.column(column, anchor=tk.W, width=50, stretch=tk.YES) # 设置为自适应宽度
|
||||
self.tree.heading(column, text=column, anchor=tk.W)
|
||||
|
||||
# 将 treeview 和滚动条放置到 tree_frame
|
||||
self.tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||
self.vertical_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
||||
|
||||
# 插入数据
|
||||
for row in self.data:
|
||||
self.tree.insert("", tk.END, values=row)
|
||||
|
||||
# 绑定点击事件
|
||||
self.tree.bind("<Double-1>", self.show_university_details)
|
||||
|
||||
except pymysql.Error as err:
|
||||
messagebox.showerror("数据库错误", str(err))
|
||||
|
||||
update_button=tk.Button(self.main_frame,text="更新数据",command=self.update)
|
||||
update_button.pack(pady=10,padx=10)
|
||||
|
||||
exit_button = tk.Button(self.main_frame, text="退出", command=self.quit)
|
||||
exit_button.pack(pady=10,padx=20)
|
||||
|
||||
comment_button = tk.Button(self.main_frame, text="自测", command=self.testYouself)
|
||||
comment_button.pack(pady=10,padx=30)
|
||||
|
||||
def update(self):
|
||||
response = messagebox.askyesno("确认", "您确定要更新吗?")
|
||||
if response == True:
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
招生信息.star()
|
||||
sql="""LOAD DATA INFILE "D:\\software\\test2\\pythonProject(1)\\student1.csv"
|
||||
INTO TABLE mynewdb.universities_beijing
|
||||
FIELDS TERMINATED BY ','
|
||||
ENCLOSED BY '"'
|
||||
LINES TERMINATED BY '\r\n'
|
||||
IGNORE 1 ROWS;"""
|
||||
cursor.execute(sql)
|
||||
|
||||
else:
|
||||
messagebox.showinfo("更新取消","已取消")
|
||||
|
||||
|
||||
|
||||
def show_university_details(self, event):
|
||||
selected_item = self.tree.selection()[0] # 获取选中的行
|
||||
university_data = self.tree.item(selected_item, 'values') # 获取行数据
|
||||
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb')as connection:
|
||||
cursor= connection.cursor()
|
||||
|
||||
|
||||
if university_data:
|
||||
self.detail_window = tk.Toplevel(self) # 创建新窗口
|
||||
self.detail_window.title("大学详细信息")
|
||||
self.detail_window.attributes('-fullscreen', True)
|
||||
|
||||
cursor.execute("SELECT * FROM universities_beijing LIMIT 0") # 替换为您的表名
|
||||
columns = [desc[0] for desc in cursor.description]
|
||||
tree_detail = ttk.Treeview(self.detail_window, columns=[1,2], show='headings')
|
||||
# 显示大学的其他信息
|
||||
i=0
|
||||
while i < len(columns):
|
||||
for detail in university_data:
|
||||
tree_detail.insert("","end",values=(columns[i]+":",detail))
|
||||
i+=1
|
||||
tree_detail.pack(expand=True, fill='both')
|
||||
#添加评论搜索框
|
||||
search_label = tk.Label(self.detail_window, text="搜索评论内容:")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search1_comment_entry = tk.Entry(self.detail_window)
|
||||
self.search1_comment_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
affirm_button = tk.Button(self.detail_window, text="确认", command=self.search_comment)
|
||||
affirm_button.pack(side=tk.LEFT)
|
||||
# 添加评论框
|
||||
self.tree_comment=ttk.Treeview(self.detail_window,columns=[1,2,3,4],show='headings')
|
||||
self.tree_comment.column('1',width=300)
|
||||
self.tree_comment.column('2', width=300)
|
||||
self.tree_comment.column('3', width=800)
|
||||
self.tree_comment.column('4',width=200)
|
||||
self.tree_comment.pack(expand=True,fill='both')
|
||||
sql="select * FROM comments where university_name=%s Order by comment_time desc"
|
||||
cursor.execute(sql,(university_data[0],))
|
||||
self.comment_result = cursor.fetchall()
|
||||
for row in self.comment_result:
|
||||
self.tree_comment.insert("", tk.END, values=row)
|
||||
comment_label = tk.Label(self.detail_window, text="添加评论:")
|
||||
comment_label.pack(pady=10)
|
||||
|
||||
self.comment_entry = tk.Entry(self.detail_window)
|
||||
self.comment_entry.pack(pady=5)
|
||||
|
||||
submit_comment_button = tk.Button(self.detail_window, text="提交评论",command=lambda: self.submit_comment(university_data[0]))
|
||||
submit_comment_button.pack(pady=10)
|
||||
|
||||
delete_button = tk.Button(self.detail_window,text="删除评论",command=self.delete_comment)
|
||||
delete_button.pack(pady=10)
|
||||
|
||||
summary_button = tk.Button(self.detail_window, text="总结词条",command=self.show_summary(university_data[0]))
|
||||
summary_button.pack(pady=10)
|
||||
|
||||
back_button = tk.Button(self.detail_window, text="返回", command=self.detail_window.destroy)
|
||||
back_button.pack(pady=10)
|
||||
|
||||
cursor.close()
|
||||
|
||||
def search_comment(self):
|
||||
search1_term = self.search1_comment_entry.get()
|
||||
|
||||
|
||||
# 清空当前Treeview
|
||||
self.tree_comment.delete(*self.tree_comment.get_children())
|
||||
|
||||
# 重新插入符合搜索条件的数据
|
||||
for row in self.comment_result:
|
||||
if any((search1_term in str(value).lower() for value in row)):
|
||||
self.tree_comment.insert("", tk.END, values=row)
|
||||
|
||||
|
||||
def show_summary(self,university_name):
|
||||
if self.detail_window:
|
||||
self.detail_window.destroy
|
||||
|
||||
self.tree_summary = tk.Toplevel(self.detail_window)
|
||||
|
||||
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql="select comment from comments where university_name=%s"
|
||||
cursor.execute(sql,(university_name,))
|
||||
result=cursor.fetchall()
|
||||
|
||||
file1=open("评论内容.txt","w+",encoding="utf-8")
|
||||
for line in result:
|
||||
file1.writelines(line)
|
||||
file1.write("\n")
|
||||
file1.close()
|
||||
|
||||
评论总结.main()
|
||||
|
||||
file2 = open(r"keys_TFIDF.csv","r",encoding="utf-8")
|
||||
datas = file2.readlines()
|
||||
datas = str(datas)
|
||||
wenben_text_area = tk.Text(self.tree_summary, height=5, width=73)
|
||||
wenben_text_area.grid(row=3, columnspan=3, sticky="w")
|
||||
original_text = datas.replace('\n', '')
|
||||
for data in original_text:
|
||||
wenben_text_area.insert(tk.END, data)
|
||||
file2.close()
|
||||
|
||||
|
||||
|
||||
def submit_comment(self, university_name):
|
||||
global current_username
|
||||
comment = self.comment_entry.get()
|
||||
if comment:
|
||||
# Store comment in the database (add your SQL query here)
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
comment_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
sql = "INSERT INTO comments (username,university_name, comment,comment_time) VALUES (%s,%s, %s, %s)"
|
||||
cursor.execute(sql, (current_username,university_name, comment,comment_time))
|
||||
connection.commit()
|
||||
|
||||
messagebox.showinfo("评论", "评论提交成功")
|
||||
self.comment_entry.delete(0, tk.END) # 清空输入框
|
||||
else:
|
||||
messagebox.showerror("评论", "评论不能为空")
|
||||
|
||||
def delete_comment(self):
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql="""
|
||||
"""
|
||||
|
||||
def testYouself(self):
|
||||
if self.main_frame:
|
||||
self.main_frame.pack_forget()
|
||||
|
||||
self.title("自测界面")
|
||||
sw = self.winfo_screenwidth()
|
||||
sh = self.winfo_screenheight()
|
||||
Width = 400
|
||||
Height = 300
|
||||
cen_x = (sw - Width) / 2
|
||||
cen_y = (sh - Height) / 2
|
||||
self.geometry('%dx%d+%d+%d' % (Width, Height, cen_x, cen_y))
|
||||
self.test_frame = tk.Frame(self)
|
||||
self.test_frame.pack(padx=20, pady=20)
|
||||
app = QuestionnaireGUI(self.test_frame)
|
||||
app.generate_next_question()
|
||||
|
||||
self.back_button = tk.Button(self.test_frame, text="退出", command=self.show_main_window)
|
||||
self.back_button.pack(pady=10)
|
||||
|
||||
|
||||
def search_data(self):
|
||||
search1_term = self.search1_entry.get()
|
||||
search2_term = self.search2_entry.get()
|
||||
search3_term = self.search3_entry.get()
|
||||
search4_term = self.search4_entry.get()
|
||||
search5_term = self.search5_entry.get()
|
||||
|
||||
# 清空当前Treeview
|
||||
self.tree.delete(*self.tree.get_children())
|
||||
|
||||
# 重新插入符合搜索条件的数据
|
||||
for row in self.data:
|
||||
if any((search1_term in str(value).lower() for value in row)):
|
||||
if any((search2_term in str(value).lower() for value in row)):
|
||||
if any((search3_term in str(value).lower() for value in row)):
|
||||
if any((search4_term in str(value).lower() for value in row)):
|
||||
if any((search5_term in str(value).lower() for value in row)):
|
||||
self.tree.insert("", tk.END, values=row)
|
||||
|
||||
|
||||
def show_register_window(self):
|
||||
if self.login_frame:
|
||||
self.login_frame.pack_forget()
|
||||
self.title("用户注册界面")
|
||||
sw = self.winfo_screenwidth()
|
||||
sh = self.winfo_screenheight()
|
||||
Width = 400
|
||||
Height = 300
|
||||
cen_x = (sw - Width) / 2
|
||||
cen_y = (sh - Height) / 2
|
||||
self.geometry('%dx%d+%d+%d' % (Width, Height, cen_x, cen_y))
|
||||
|
||||
self.register_frame = tk.Frame(self)
|
||||
self.register_frame.pack(padx=20, pady=20)
|
||||
|
||||
self.username_label = tk.Label(self.register_frame, text="用户名:")
|
||||
self.username_label.grid(row=0, column=0)
|
||||
self.username_entry = tk.Entry(self.register_frame)
|
||||
self.username_entry.grid(row=0, column=1)
|
||||
|
||||
self.password_label = tk.Label(self.register_frame, text="密码:")
|
||||
self.password_label.grid(row=1, column=0)
|
||||
self.password_entry = tk.Entry(self.register_frame, show="*")
|
||||
self.password_entry.grid(row=1, column=1)
|
||||
|
||||
self.confirm_password_label = tk.Label(self.register_frame, text="再次输入密码:")
|
||||
self.confirm_password_label.grid(row=2, column=0)
|
||||
self.confirm_password_entry = tk.Entry(self.register_frame, show="*")
|
||||
self.confirm_password_entry.grid(row=2, column=1)
|
||||
|
||||
self.register_button = tk.Button(self.register_frame, text="注册", command=self.register)
|
||||
self.register_button.grid(row=3, column=0)
|
||||
|
||||
self.back_button = tk.Button(self.register_frame, text="返回", command=self.create_login_window)
|
||||
self.back_button.grid(row=3, column=1)
|
||||
|
||||
def create_login_window(self):
|
||||
if self.register_frame:
|
||||
self.register_frame.pack_forget()
|
||||
self.title("登录界面")
|
||||
sw = self.winfo_screenwidth()
|
||||
sh = self.winfo_screenheight()
|
||||
Width = 400
|
||||
Height = 300
|
||||
cen_x = (sw - Width) / 2
|
||||
cen_y = (sh - Height) / 2
|
||||
self.geometry('%dx%d+%d+%d' % (Width, Height, cen_x, cen_y))
|
||||
|
||||
self.login_frame = tk.Frame(self)
|
||||
self.login_frame.pack(padx=20, pady=20)
|
||||
|
||||
self.username_label = tk.Label(self.login_frame, text="用户名:")
|
||||
self.username_label.grid(row=0, column=0)
|
||||
self.username_entry = tk.Entry(self.login_frame)
|
||||
self.username_entry.grid(row=0, column=1)
|
||||
|
||||
self.password_label = tk.Label(self.login_frame, text="密码:")
|
||||
self.password_label.grid(row=1, column=0)
|
||||
self.password_entry = tk.Entry(self.login_frame, show="*")
|
||||
self.password_entry.grid(row=1, column=1)
|
||||
|
||||
self.login_button = tk.Button(self.login_frame, text="登录", command=self.login)
|
||||
self.login_button.grid(row=2, column=0)
|
||||
|
||||
self.back_button = tk.Button(self.login_frame, text="退出", command=self.quit)
|
||||
self.back_button.grid(row=2, column=1)
|
||||
|
||||
self.register_button = tk.Button(self.login_frame, text="注册", command=self.show_register_window)
|
||||
self.register_button.grid(row=3, column=0)
|
||||
|
||||
self.deiconify()
|
||||
|
||||
|
||||
# Start the application
|
||||
if __name__ == "__main__":
|
||||
app = MasterChargeSystem()
|
||||
app.mainloop()
|
File diff suppressed because it is too large
Load Diff
|
File diff suppressed because it is too large
Load Diff
|
|
|
|
|
|
Binary file not shown.
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,82 @@
|
||||
上海交通大学的校园环境非常美丽,绿树成荫,教学楼和实验室设施都很先进。
|
||||
作为一名上海交通大学的学生,我深感这里的教学质量非常高,教授们都很专业,学术氛围浓厚。
|
||||
我很喜欢上海交大的国际化氛围,许多外国留学生在这里学习,文化交流很丰富。
|
||||
上海交通大学的医学院在国内外都有很高的声誉,医疗研究和临床教学都非常优秀。
|
||||
校园内的餐厅种类丰富,味道不错,价格也比较合理。
|
||||
我在上海交通大学的生活非常充实,除了学业,学校还提供了许多课外活动,丰富了我的大学生活。
|
||||
上海交通大学的校友网络非常强大,毕业后找工作很有优势。
|
||||
这里的图书馆资源十分丰富,不仅有大量的学术书籍,还有许多电子资源,学习非常方便。
|
||||
上海交通大学的校园设施非常现代化,教室和宿舍都很舒适,学生的生活质量很高。
|
||||
在上海交通大学读书让我受益匪浅,培养了我的独立思考能力和解决问题的能力。
|
||||
学校的师资力量十分强大,很多教授都是在各自领域内的权威。
|
||||
上海交通大学的工科在全国具有非常强的竞争力,尤其是在机械工程和计算机科学领域。
|
||||
我认为上海交通大学在创新创业方面做得非常好,学校提供了很多支持和资源,鼓励学生创业。
|
||||
这里的学生社团活动非常丰富,我参加的机器人社团为我提供了很多实践机会。
|
||||
上海交通大学的科研环境也很好,校内有很多实验室和项目,学生能够参与到前沿的研究中。
|
||||
校园交通非常便利,地铁和公交都很方便,方便学生的日常出行。
|
||||
上海交通大学的学术氛围很好,同学们都很有上进心,大家互相学习,促进了个人的成长。
|
||||
我曾在上海交通大学的夏令营参加过活动,那时就深深感受到了这所学校的学术氛围和团队精神。
|
||||
学校的住宿条件也很不错,宿舍虽然不大,但设施齐全,生活很方便。
|
||||
我觉得上海交通大学的就业服务也非常到位,学校有很多校企合作,实习机会丰富。
|
||||
校园内的体育设施很完善,我常常去健身房锻炼,保持身心健康。
|
||||
上海交通大学的文化氛围很浓厚,常常举办讲座、展览等活动,拓宽了我的视野。
|
||||
作为一名上海交通大学的研究生,我深知这里的科研氛围很强,导师们都非常支持我的研究工作。
|
||||
我在上海交通大学体验到了非常高水平的教育,尤其是外语和管理类课程,内容十分丰富且实用。
|
||||
学校的医疗服务也很好,校医院非常方便,医生态度也非常亲切。
|
||||
我喜欢上海交通大学的国际合作项目,能够与世界各地的学生一起学习和交流。
|
||||
交大的电子信息专业很强,学校有很多实用的设备和技术支持学生的实践和研究。
|
||||
作为一名在职研究生,我很欣赏上海交通大学为我们提供的灵活的学习模式,既能够工作又不耽误学业。
|
||||
我觉得交大的同学们普遍很有责任心,学校培养了我严谨的工作态度。
|
||||
上海交通大学的创新实验中心为学生提供了很多动手操作的机会,非常适合有兴趣做科研的同学。
|
||||
上海交通大学注重国际化,很多专业都有海外交换生项目,极大地拓展了我的全球视野。
|
||||
学校的开放性也很强,经常邀请外部专家来校讲座,给学生带来了很多新的想法和灵感。
|
||||
交大的电子工程专业让我掌握了很多先进的技术,帮助我在科技领域有了更深的理解。
|
||||
校园内有许多休闲区域,课余时间可以和朋友一起聊天放松,很适合缓解学习压力。
|
||||
上海交通大学的管理类课程内容很实用,特别是跨文化管理课程让我受益匪浅。
|
||||
交大的图书馆很现代化,里面的学习区域很安静,适合集中精力学习。
|
||||
我喜欢学校开设的社会实践课程,这让我能够将理论知识与实际工作结合起来。
|
||||
上海交通大学有很好的职业规划课程和资源,帮助学生为未来的职业生涯做好准备。
|
||||
学校的国际会议非常多,能够有机会参加全球顶级学者的讲座和论坛,开阔眼界。
|
||||
校内的艺术气息也浓厚,经常有音乐会、话剧等文艺活动。
|
||||
上海交通大学的教师不仅学术水平高,而且也非常关心学生的成长,导师对我的帮助很大。
|
||||
校园内的自行车道很便利,学生可以方便地骑车出行,节约时间。
|
||||
上海交通大学的设计类专业很强,尤其是工业设计方向,培养了很多行业领军人物。
|
||||
我对上海交通大学的国际化教学非常赞赏,特别是在跨学科领域的合作项目,给学生带来了很多实用的经验。
|
||||
上海交通大学的本科生课程安排非常合理,基础知识与专业技能的结合非常紧密。
|
||||
学校对学生的创新能力和创业精神有很高的要求,鼓励学生积极参与各种创业活动。
|
||||
作为一名国际学生,我很享受上海交通大学提供的国际学生服务,学校为我们提供了很多支持。
|
||||
上海交通大学的学生组织也非常活跃,加入其中让我结识了很多志同道合的朋友。
|
||||
校园内有不少咖啡厅和小吃店,非常适合学生们在忙碌中找个地方放松一下。
|
||||
上海交通大学的课程设计非常贴近市场需求,毕业生的就业率很高。
|
||||
学校重视学生的综合素质培养,不仅注重专业知识,也鼓励学生多方面发展。
|
||||
上海交通大学的科研平台非常好,学校有很多国家级和省级的重点实验室。
|
||||
学校提供的职业发展服务非常到位,不仅帮助我们规划职业方向,还定期举办招聘会。
|
||||
在交大读书让我体会到什么是责任和自律,这里的学习环境非常适合追求卓越的同学。
|
||||
交大的校园非常大,虽然有点偏远,但设施齐全,生活也很便利。
|
||||
学校的学术资源非常丰富,特别是在工程类学科,学术氛围非常浓厚。
|
||||
作为上海交通大学的一名校友,我认为这所学校给了我非常宝贵的教育资源,对我的职业生涯帮助很大。
|
||||
上海交通大学的技术创新和学术研究走在了国内前沿,尤其是在人工智能和大数据方面。
|
||||
我喜欢学校的多样化课程,可以根据自己的兴趣选择一些跨学科的课程,丰富自己的学术背景。
|
||||
上海交通大学不仅是学术研究的重镇,也是一个创新创业的摇篮,很多创业公司就诞生在这里。
|
||||
交大给了我很多实践的机会,无论是实验室研究还是实习项目,都是宝贵的经验。
|
||||
学校的学科设置非常全面,无论你是偏向理论研究还是实践操作,都能找到合适的方向。
|
||||
我觉得交大的英语教学水平也很高,外语课程设计非常科学,能够提高我们的英语能力。
|
||||
上海交通大学的学术会议氛围很浓,能够接触到行业内的顶尖人物,了解最新的技术发展。
|
||||
学校的暑期实习机会非常丰富,很多知名企业提供给交大的学生专属岗位。
|
||||
我很感激在上海交通大学的成长,这里培养了我严谨的科学精神和创新思维。
|
||||
交大有很多资源支持学生的创业,学校内有创新创业中心,能够帮助学生实现自己的梦想。
|
||||
学校的法律课程也非常好,老师讲解很生动,帮助我更好地理解法律原理和实践。
|
||||
上海交通大学的校园安全保障做得非常好,学校内的安全措施非常到位,让我们在这里学习和生活都很放心。
|
||||
校园内有很多公益活动,学校鼓励我们参与社会服务,贡献社会。
|
||||
交大的国际交流机会很多,学校的国际学生和教师比例很高,促进了多元文化的交流。
|
||||
老师们讲课非常生动,课堂内容深入浅出,容易理解。
|
||||
上海交通大学的学生在科研方面非常有潜力,很多同学都能进行高水平的研究。
|
||||
交大的创业生态也很活跃,有很多创新的项目在这里诞生。
|
||||
学校的就业资源非常丰富,校企合作为学生提供了很多实习和就业机会。
|
||||
交大的校园生活丰富多彩,各种活动和社团给学生带来了很多选择。
|
||||
这里的学生在学术和创新方面都很出色,毕业后都能在职场上做得很不错。
|
||||
交大的学术氛围充满活力,教授们也愿意帮助学生解决问题,学术交流非常顺畅。
|
||||
学校非常注重学生的全面发展,鼓励学生参与社会实践和志愿服务。
|
||||
上海交通大学的工程类学科非常有竞争力,培养了大量优秀的工程师。
|
||||
交大的创新氛围非常浓厚,学生们的创意常常能得到老师和学校的支持。
|
||||
校园里有很多现代化设施,特别是科研实验室,设备非常先进。
|
@ -0,0 +1,275 @@
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, ttk
|
||||
import pymysql
|
||||
|
||||
|
||||
class MasterChargeSystem(tk.Tk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.login_frame = None
|
||||
self.register_frame = None
|
||||
self.comment_frame = None
|
||||
self.create_login_window()
|
||||
|
||||
def register_database(self, username, password):
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql = "INSERT INTO user1(username, password) VALUES (%s, %s)"
|
||||
cursor.execute(sql, (username, password))
|
||||
connection.commit()
|
||||
|
||||
def login(self):
|
||||
username = self.username_entry.get().strip()
|
||||
password = self.password_entry.get().strip()
|
||||
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql = "SELECT password FROM user1 WHERE username = %s"
|
||||
cursor.execute(sql, (username,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if result:
|
||||
stored_password = result[0]
|
||||
if stored_password == password:
|
||||
messagebox.showinfo("登录", "登陆成功")
|
||||
self.show_main_window()
|
||||
else:
|
||||
messagebox.showerror("登录", "用户名或密码错误")
|
||||
else:
|
||||
messagebox.showerror("登录", "用户名不存在")
|
||||
|
||||
def register(self):
|
||||
username = self.username_entry.get().strip()
|
||||
password = self.password_entry.get().strip()
|
||||
confirm_password = self.confirm_password_entry.get().strip()
|
||||
|
||||
if username and password:
|
||||
if password == confirm_password:
|
||||
self.register_database(username, password)
|
||||
messagebox.showinfo("注册", "注册成功")
|
||||
self.create_login_window()
|
||||
else:
|
||||
messagebox.showerror("注册", "两次输入的密码不匹配")
|
||||
else:
|
||||
messagebox.showerror("注册", "用户名或密码为空")
|
||||
|
||||
def show_main_window(self):
|
||||
if self.login_frame:
|
||||
self.login_frame.pack_forget()
|
||||
if self.comment_frame:
|
||||
self.comment_frame.pack_forget()
|
||||
|
||||
self.title("考研信息系统")
|
||||
self.attributes('-fullscreen', True)
|
||||
|
||||
self.main_frame = tk.Frame(self)
|
||||
self.main_frame.pack(fill=tk.BOTH, expand=True, padx=50, pady=50)
|
||||
|
||||
main_label = tk.Label(self.main_frame, text="欢迎来到考研信息系统!")
|
||||
main_label.pack(pady=10)
|
||||
|
||||
# 添加搜索框
|
||||
search_frame = tk.Frame(self.main_frame)
|
||||
search_frame.pack(pady=10)
|
||||
|
||||
search_label = tk.Label(search_frame, text="搜索:")
|
||||
search_label.pack(side=tk.LEFT)
|
||||
|
||||
self.search1_entry = tk.Entry(search_frame)
|
||||
self.search1_entry.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
self.search2_entry = ttk.Combobox(search_frame, values=['1', '2'])
|
||||
self.search2_entry.pack(side=tk.LEFT, padx=5)
|
||||
affirm_button = tk.Button(search_frame, text="确认", command=self.search_data)
|
||||
affirm_button.pack(side=tk.RIGHT)
|
||||
|
||||
try:
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT * FROM universities_beijing")
|
||||
|
||||
# 创建一个用于 Treeview 和滚动条的框架
|
||||
tree_frame = tk.Frame(self.main_frame)
|
||||
tree_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
self.tree = ttk.Treeview(tree_frame)
|
||||
self.vertical_scrollbar = ttk.Scrollbar(tree_frame, orient=tk.VERTICAL, command=self.tree.yview)
|
||||
self.tree.configure(yscrollcommand=self.vertical_scrollbar.set)
|
||||
|
||||
# 获取列名
|
||||
cursor.execute("SELECT * FROM universities_beijing LIMIT 0")
|
||||
self.columns = [description[0] for description in cursor.description]
|
||||
|
||||
# 获取数据
|
||||
cursor.execute("SELECT * FROM universities_beijing")
|
||||
self.data = cursor.fetchall()
|
||||
|
||||
# 设置列
|
||||
self.tree['columns'] = self.columns
|
||||
self.tree.column("#0", width=0, stretch=tk.NO) # 隐藏第一个空列
|
||||
|
||||
# 动态设置列和列名
|
||||
for column in self.columns:
|
||||
self.tree.column(column, anchor=tk.W, width=100, stretch=tk.YES)
|
||||
self.tree.heading(column, text=column, anchor=tk.W)
|
||||
|
||||
self.tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
|
||||
self.vertical_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
||||
|
||||
# 插入数据
|
||||
for row in self.data:
|
||||
self.tree.insert("", tk.END, values=row)
|
||||
|
||||
# 绑定点击事件
|
||||
self.tree.bind("<Double-1>", self.show_university_details)
|
||||
|
||||
except pymysql.Error as err:
|
||||
messagebox.showerror("数据库错误", str(err))
|
||||
|
||||
exit_button = tk.Button(self.main_frame, text="退出", command=self.quit)
|
||||
exit_button.pack(pady=10)
|
||||
|
||||
comment_button = tk.Button(self.main_frame, text="评论", command=self.comment)
|
||||
comment_button.pack(pady=10)
|
||||
|
||||
def show_university_details(self, event):
|
||||
selected_item = self.tree.selection()[0] # 获取选中的行
|
||||
university_data = self.tree.item(selected_item, 'values') # 获取行数据
|
||||
|
||||
if university_data:
|
||||
self.detail_window = tk.Toplevel(self) # 创建新窗口
|
||||
self.detail_window.title("大学详细信息")
|
||||
self.detail_window.geometry("400x300")
|
||||
|
||||
# 显示大学的其他信息
|
||||
detail_label = tk.Label(self.detail_window, text=f"大学名称: {university_data[0]}") # Assuming first column is name
|
||||
detail_label.pack(pady=10)
|
||||
|
||||
additional_info = f"其他信息:\n" # Here you can add more info as needed.
|
||||
additional_info_label = tk.Label(self.detail_window, text=additional_info)
|
||||
additional_info_label.pack(pady=10)
|
||||
|
||||
# 添加评论框
|
||||
comment_label = tk.Label(self.detail_window, text="添加评论:")
|
||||
comment_label.pack(pady=10)
|
||||
|
||||
self.comment_entry = tk.Entry(self.detail_window)
|
||||
self.comment_entry.pack(pady=5)
|
||||
|
||||
submit_comment_button = tk.Button(self.detail_window, text="提交评论", command=lambda: self.submit_comment(university_data[0]))
|
||||
submit_comment_button.pack(pady=10)
|
||||
|
||||
self.detail_window.protocol("WM_DELETE_WINDOW", self.detail_window.destroy)
|
||||
|
||||
def submit_comment(self, university_name):
|
||||
comment = self.comment_entry.get()
|
||||
if comment:
|
||||
# Store comment in the database (add your SQL query here)
|
||||
with pymysql.connect(host='localhost', user='root', password='123456', database='mynewdb') as connection:
|
||||
cursor = connection.cursor()
|
||||
sql = "INSERT INTO comments (university_name, comment) VALUES (%s, %s)"
|
||||
cursor.execute(sql, (university_name, comment))
|
||||
connection.commit()
|
||||
|
||||
messagebox.showinfo("评论", "评论提交成功")
|
||||
self.comment_entry.delete(0, tk.END) # 清空输入框
|
||||
else:
|
||||
messagebox.showerror("评论", "评论不能为空")
|
||||
|
||||
def comment(self):
|
||||
if self.main_frame:
|
||||
self.main_frame.pack_forget()
|
||||
|
||||
self.title("评论界面")
|
||||
self.attributes('-fullscreen', True)
|
||||
|
||||
self.comment_frame = tk.Frame(self)
|
||||
self.comment_frame.pack(fill=tk.BOTH, expand=True, padx=50, pady=50)
|
||||
|
||||
self.back_button = tk.Button(self.comment_frame, text="返回", command=self.show_main_window)
|
||||
self.back_button.pack(pady=10)
|
||||
|
||||
def search_data(self):
|
||||
search_term = self.search1_entry.get() # Fixed to use the correct entry
|
||||
|
||||
# 清空当前Treeview
|
||||
self.tree.delete(*self.tree.get_children())
|
||||
|
||||
# 重新插入符合搜索条件的数据
|
||||
for row in self.data:
|
||||
if any(search_term in str(value).lower() for value in row):
|
||||
self.tree.insert("", tk.END, values=row)
|
||||
|
||||
def show_register_window(self):
|
||||
if self.login_frame:
|
||||
self.login_frame.pack_forget()
|
||||
self.title("用户注册界面")
|
||||
sw = self.winfo_screenwidth()
|
||||
sh = self.winfo_screenheight()
|
||||
Width = 400
|
||||
Height = 300
|
||||
cen_x = (sw - Width) / 2
|
||||
cen_y = (sh - Height) / 2
|
||||
self.geometry('%dx%d+%d+%d' % (Width, Height, cen_x, cen_y))
|
||||
|
||||
self.register_frame = tk.Frame(self)
|
||||
self.register_frame.pack(padx=20, pady=20)
|
||||
|
||||
self.username_label = tk.Label(self.register_frame, text="用户名:")
|
||||
self.username_label.grid(row=0, column=0)
|
||||
self.username_entry = tk.Entry(self.register_frame)
|
||||
self.username_entry.grid(row=0, column=1)
|
||||
|
||||
self.password_label = tk.Label(self.register_frame, text="密码:")
|
||||
self.password_label.grid(row=1, column=0)
|
||||
self.password_entry = tk.Entry(self.register_frame, show="*")
|
||||
self.password_entry.grid(row=1, column=1)
|
||||
|
||||
self.confirm_password_label = tk.Label(self.register_frame, text="确认密码:")
|
||||
self.confirm_password_label.grid(row=2, column=0)
|
||||
self.confirm_password_entry = tk.Entry(self.register_frame, show="*")
|
||||
self.confirm_password_entry.grid(row=2, column=1)
|
||||
|
||||
self.register_button = tk.Button(self.register_frame, text="注册", command=self.register)
|
||||
self.register_button.grid(row=3, columnspan=2, pady=10)
|
||||
|
||||
self.back_to_login_button = tk.Button(self.register_frame, text="返回登录", command=self.create_login_window)
|
||||
self.back_to_login_button.grid(row=4, columnspan=2)
|
||||
|
||||
def create_login_window(self):
|
||||
if self.register_frame:
|
||||
self.register_frame.pack_forget()
|
||||
if self.comment_frame:
|
||||
self.comment_frame.pack_forget()
|
||||
|
||||
self.title("用户登录界面")
|
||||
sw = self.winfo_screenwidth()
|
||||
sh = self.winfo_screenheight()
|
||||
Width = 400
|
||||
Height = 300
|
||||
cen_x = (sw - Width) / 2
|
||||
cen_y = (sh - Height) / 2
|
||||
self.geometry('%dx%d+%d+%d' % (Width, Height, cen_x, cen_y))
|
||||
|
||||
self.login_frame = tk.Frame(self)
|
||||
self.login_frame.pack(padx=20, pady=20)
|
||||
|
||||
self.username_label = tk.Label(self.login_frame, text="用户名:")
|
||||
self.username_label.grid(row=0, column=0)
|
||||
self.username_entry = tk.Entry(self.login_frame)
|
||||
self.username_entry.grid(row=0, column=1)
|
||||
|
||||
self.password_label = tk.Label(self.login_frame, text="密码:")
|
||||
self.password_label.grid(row=1, column=0)
|
||||
self.password_entry = tk.Entry(self.login_frame, show="*")
|
||||
self.password_entry.grid(row=1, column=1)
|
||||
|
||||
self.login_button = tk.Button(self.login_frame, text="登录", command=self.login)
|
||||
self.login_button.grid(row=2, columnspan=2, pady=10)
|
||||
|
||||
self.register_button = tk.Button(self.login_frame, text="注册", command=self.show_register_window)
|
||||
self.register_button.grid(row=3, columnspan=2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = MasterChargeSystem()
|
||||
app.mainloop()
|
@ -0,0 +1,130 @@
|
||||
import os
|
||||
import re
|
||||
import pandas as pd
|
||||
from collections import Counter
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
from sklearn.metrics.pairwise import cosine_similarity
|
||||
import spacy
|
||||
from spacy.lang.zh import Chinese
|
||||
|
||||
# 设置文件路径
|
||||
sample_file = '样本.txt'
|
||||
standard_file = '标准.txt'
|
||||
output_file = '评论提取结果.txt'
|
||||
excel_file = '评论提取结果.xlsx'
|
||||
|
||||
# 加载中文模型
|
||||
nlp = Chinese()
|
||||
|
||||
|
||||
def read_file(file_path):
|
||||
"""读取文件内容"""
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def clean_text(text):
|
||||
"""清洗文本"""
|
||||
# 去除特殊字符和多余空格
|
||||
text = re.sub(r'\W+', ' ', text) # 去除特殊字符
|
||||
text = re.sub(r'\s+', ' ', text) # 合并多余空格
|
||||
return text.strip() # 去掉首尾空格
|
||||
|
||||
|
||||
def extract_keywords_using_tfidf(text, top_n=10):
|
||||
"""使用TF-IDF提取关键词"""
|
||||
vectorizer = TfidfVectorizer()
|
||||
tfidf_matrix = vectorizer.fit_transform([text])
|
||||
feature_names = vectorizer.get_feature_names_out()
|
||||
dense = tfidf_matrix.todense()
|
||||
|
||||
# 获取关键词和对应的TF-IDF值
|
||||
tfidf_scores = dense.tolist()[0]
|
||||
keywords = sorted(zip(feature_names, tfidf_scores), key=lambda x: x[1], reverse=True)
|
||||
|
||||
return keywords[:top_n]
|
||||
|
||||
|
||||
def get_high_frequency_words(text, num=20):
|
||||
"""获取高频词汇"""
|
||||
words = text.split()
|
||||
word_counts = Counter(words)
|
||||
return word_counts.most_common(num)
|
||||
|
||||
|
||||
def get_related_keywords(high_freq_words, standard_keywords):
|
||||
"""从高频词汇中提取与标准关键词相关的词"""
|
||||
return [word for word in high_freq_words if word in standard_keywords]
|
||||
|
||||
|
||||
def get_similar_sentences(text, keywords):
|
||||
"""获取所有匹配关键词的句子"""
|
||||
sentences = re.split(r'[.!?,。]+', text)
|
||||
sentences = [s.strip() for s in sentences if s.strip()]
|
||||
|
||||
# 筛选包含主题关键词的句子
|
||||
relevant_sentences = []
|
||||
for s in sentences:
|
||||
if any(keyword in s for keyword in keywords):
|
||||
relevant_sentences.append(s)
|
||||
|
||||
return Counter(relevant_sentences).most_common()
|
||||
|
||||
|
||||
def main():
|
||||
sample_text = read_file(sample_file)
|
||||
standard_text = read_file(standard_file)
|
||||
|
||||
cleaned_sample_text = clean_text(sample_text)
|
||||
cleaned_standard_text = clean_text(standard_text)
|
||||
|
||||
# 从标准文本提取关键词
|
||||
standard_keywords_data = extract_keywords_using_tfidf(cleaned_standard_text, top_n=10)
|
||||
standard_keywords = [word for word, score in standard_keywords_data]
|
||||
print(f"标准文本中提取到的关键词: {standard_keywords}")
|
||||
|
||||
# 从样本文本提取关键词
|
||||
high_freq_words_data = extract_keywords_using_tfidf(cleaned_sample_text, top_n=20)
|
||||
high_freq_words = [word for word, score in high_freq_words_data]
|
||||
print(f"样本文本中提取到的高频词汇: {high_freq_words}")
|
||||
|
||||
# 从高频词汇中提取与标准关键词相关的词
|
||||
related_keywords = get_related_keywords(high_freq_words, standard_keywords)
|
||||
print(f"与标准关键字相关的高频词汇:{related_keywords}")
|
||||
|
||||
high_freq_sentences = get_similar_sentences(cleaned_sample_text, related_keywords)
|
||||
|
||||
# 保存结果到文本文件
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
f.write("标准关键词:\n")
|
||||
for word, score in standard_keywords_data:
|
||||
f.write(f"{word}: {score}\n")
|
||||
|
||||
f.write("\n样本高频词汇:\n")
|
||||
for word, score in high_freq_words_data:
|
||||
f.write(f"{word}: {score}\n")
|
||||
|
||||
f.write("\n相关高频句子:\n")
|
||||
for sentence, freq in high_freq_sentences:
|
||||
f.write(f"{sentence.strip()}: {freq}\n")
|
||||
|
||||
# 生成 Excel 文件
|
||||
high_freq_df = pd.DataFrame(high_freq_words_data, columns=['词汇', 'TF-IDF值'])
|
||||
related_keywords_df = pd.DataFrame(related_keywords, columns=['与标准关键词相关的词汇'])
|
||||
|
||||
if os.path.exists(excel_file):
|
||||
os.remove(excel_file)
|
||||
|
||||
try:
|
||||
with pd.ExcelWriter(excel_file) as writer:
|
||||
high_freq_df.to_excel(writer, sheet_name='样本高频词汇', index=False)
|
||||
pd.Series(related_keywords, name='相关高频词汇').to_frame().to_excel(writer, sheet_name='相关高频词汇',
|
||||
index=False)
|
||||
except PermissionError:
|
||||
print(f"无法写入文件 '{excel_file}',请确保该文件未在其他程序中打开。")
|
||||
except Exception as e:
|
||||
print(f"文件写入过程中发生错误: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in new issue