这是所有的

main
ay0w55p 5 months ago
parent 7fb777126c
commit 33497fdc40

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/民航NLP.iml" filepath="$PROJECT_DIR$/.idea/民航NLP.iml" />
</modules>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

@ -0,0 +1 @@
# some run examples

@ -0,0 +1 @@
Subproject commit cd0bdc08708d2d7cd7f278abf44801bb431d739f

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Making IE from textual data using GPT4IE." />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>基于有噪声民航数据的NLP处理系统</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

@ -0,0 +1,25 @@
{
"short_name": "GPT4IE",
"name": "GPT4IE",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

@ -0,0 +1,4 @@
已知事件类型和论元角色列表的对应关系如下:$prompt1
给定一句话:"$prompt", 请提取出这句话的事件论元,并以字典的形式回答,字典的形式为:{事件类型: {论元角色: 论元内容}}。直接给出答案即可。如果没有论元角色没有相应的论元内容,论元内容回答:无。

@ -0,0 +1,3 @@
The correspondence between known event types and argument role lists is as follows: $prompt1
Give a sentence:"$prompt", Please extract the event argument or arguments of this sentence, and answer it or them in the form of a dictionary. The dictionary is in the form of: {event type: {argument role: argument content}}. Just give the answer. If the argument role does not have the corresponding argument content, the argument content answers: None.

@ -0,0 +1,5 @@
已知实体类型列表:$prompt1。
给定一个句子:"$prompt"
在给定的句子中可能包含哪些实体,请按照形式 (实体类型, 实体内容) 回答:

@ -0,0 +1,5 @@
List of known entity types: $prompt1.
Given a sentence: "$prompt"
Which entities may be included in a given sentence, please answer in the form (entity type, entity content):

@ -0,0 +1,11 @@
假设你是一个实体关系三元组抽取模型。我会给你头实体类型列表subject_types尾实体类型列表object_types关系列表relations再给你一个句子请你根据这三个列表抽出句子中的subject和object并组成三元组且形式为(subject, relation, object)。
给定的句子为:"$prompt"
relations$prompt1
subject_types$prompt2
object_types$prompt3
在给定的句子中,可能包含了哪些三元组?请按照形式(subject, relation, object)回答:

@ -0,0 +1,11 @@
Suppose you are an entity-relationship triple extraction model. I'll give you list of head entity types: subject_types, list of tail entity types: object_types, list of relations: relations. Give you a sentence, please extract the subject and object in the sentence based on these three lists, and form a triplet in the form of (subject, relation, object).
The given sentence is "$prompt".
relations: $prompt1
subject_types: $prompt2
object_types: $prompt3
In the given sentence, what triples might be contained? Please answer in the form (subject, relation, object):

@ -0,0 +1,38 @@
The aid group Doctors Without Borders said that since Saturday , more than 275 wounded people had been admitted and treated at Donka Hospital in the capital of Guinea , Conakry .
['location-located_in', 'administrative_division-country', 'person-place_lived', 'person-company', 'person-nationality', 'company-founders', 'country-administrative_divisions', 'person-children', 'country-capital', 'deceased_person-place_of_death', 'neighborhood-neighborhood_of', 'person-place_of_birth']
['organization', 'person', 'location', 'country']
['person', 'location', 'country', 'organization', 'city']
_____________________________________________________
第五部:《如懿传》《如懿传》是一部古装宫廷情感电视剧,由汪俊执导,周迅、霍建华、张钧甯、董洁、辛芷蕾、童瑶、李纯、邬君梅等主演
['所属专辑', '成立日期', '海拔', '官方语言', '占地面积', '父亲', '歌手', '制片人', '导演', '首都', '主演', '董事长', '祖籍', '妻子', '母亲', '气候', '面积', '主角', '邮政编码', '简称', '出品公司', '注册资本', '编剧', '创始人', '毕业院校', '国籍', '专业代码', '朝代', '作者', '作词', '所在城市', '嘉宾', '总部地点', '人口数量', '代言人', '改编自', '校长', '丈夫', '主持人', '主题曲', '修业年限', '作曲', '号', '上映时间', '票房', '饰演', '配音', '获奖']
['国家', '行政区', '文学作品', '人物', '影视作品', '学校', '图书作品', '地点', '历史人物', '景点', '歌曲', '学科专业', '企业', '电视综艺', '机构', '企业/品牌', '娱乐人物']
['国家', '人物', 'Text', 'Date', '地点', '气候', '城市', '歌曲', '企业', 'Number', '音乐专辑', '学校', '作品', '语言']
_______________________________________________________
比如本轮的比赛中就有,中甲榜首之争,再次惨败的西北狼回到主场能否止住颓势,闹剧频出的川足事态如何发展,永昌客场是否能迎来首胜。
{'组织行为-罢工': ['时间', '所属组织', '罢工人数', '罢工人员'], '竞赛行为-晋级': ['时间', '晋级方', '晋级赛事'], '财经/交易-涨停':['时间', '涨停股票'] , '组织关系-解雇': ['时间', '解雇方', '被解雇人员']}
_____________________________________________________
He lost an election to a dead man.
{'Personnel:Elect': ['Person', 'Entity', 'Position', 'Time', 'Place'], 'Business:Declare-Bankruptcy': ['Org', 'Time', 'Place'], 'Justice:Arrest-Jail': ['Person', 'Agent', 'Crime', 'Time', 'Place'], 'Life:Divorce': ['Person', 'Time', 'Place'], 'Life:Injure': ['Agent', 'Victim', 'Instrument', 'Time', 'Place']}
————————————————————————————————————————————
在过去的五年中,致公党在邓小平理论指引下,遵循社会主义初级阶段的基本路线,努力实践致公党十大提出的发挥参政党职能、加强自身建设的基本任务。
['组织机构', '地点', '人物']
_____________________________________________________
Japan then laid siege to the Syrian penalty area and had a goal disallowed for offside in the 16th minute.
['LOC', 'MISC', 'ORG', 'PER']
_____________________________________________________
"homepage": "https://cocacola-lab.github.io/GPT4IE",

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

@ -0,0 +1,210 @@
@import url('https://fonts.googleapis.com/css2?family=Noticia+Text:wght@400;700&display=swap');
.headerText {
font-family: 'Noticia Text';
font-weight: 900;
font-size: 60px;
text-align: center;
padding-top: 40px;
}
.subheaderText {
font-family: 'Noticia Text';
font-weight: 400;
font-size: 20px;
text-align: center;
width: 60%;
margin: 0 auto;
}
.subsubheaderText {
font-family: 'Noticia Text';
font-weight: 400;
font-size: 18px;
text-align: center;
width: 60%;
margin: 0 auto;
}
table{
font-family: 'Oswald', sans-serif;
border-collapse:collapse;
margin-left:auto;
margin-right:auto;
margin-top: 5px;
}
td{
background-color:#ffffff;
width:50%;
height:50px;
text-align:center;
}
tr{
border-bottom: 1px solid #dddddd;
}
tr:first-of-type{
border-top: 2px solid gray;
}
tr:last-of-type{
border-bottom: 2px solid gray;
}
.opensourceText {
font-family: 'Noticia Text';
font-weight: 400;
font-size: 14px;
text-align: center;
width: 60%;
margin: 10px auto;
}
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
@media (min-width: 768px) {
.container {
width: 750px;
}
}
@media (min-width: 992px) {
.container {
width: 970px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
}
.graphContainer {
width: 80%;
height: 80%;
background-color: rgb(255, 255, 255);
border-radius: 10px;
overflow: hidden;
border: 1px solid rgb(0, 0, 0);
box-shadow: 0 0 5px rgb(0 0 0 / 10%);
margin: 0 auto;
margin-bottom: 10px;
}
.ulC {
text-align: center
}
.footer {
font-family: 'Noticia Text';
font-weight: 400;
font-size: 13px;
text-align: center;
margin: 0 auto;
margin-bottom: 100px;
}
.inputContainer {
width: 60%;
margin: 0 auto;
margin-top: 50px;
margin-bottom: 50px;
}
.searchBar {
border: 1px solid rgb(0, 0, 0);
border-radius: 5px;
box-shadow: 0 0 5px rgb(0 0 0 / 10%);
display: block;
font-size: 16px;
height: 50px;
outline: none;
padding: 0 10px;
width: 90%;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
}
.typeList {
border: 1px solid rgb(0, 0, 0);
border-radius: 5px;
box-shadow: 0 0 5px rgb(0 0 0 / 10%);
display: block;
font-size: 16px;
height: 50px;
outline: none;
padding: 0 10px;
width: 90%;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
}
.apiKeyTextField {
border: 1px solid rgb(0, 0, 0);
border-radius: 5px;
box-shadow: 0 0 5px rgb(0 0 0 / 10%);
display: block;
font-size: 16px;
height: 50px;
outline: none;
padding: 0 10px;
width: 90%;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
}
.generateButton {
background-color: rgb(0, 0, 0);
border: none;
border-radius: 5px;
color: rgb(255, 255, 255);
cursor: pointer;
font-size: 16px;
height: 50px;
outline: none;
width: 40%;
display: inline-block;
margin-right: 5px;
}
.generateButton:hover {
background-color: rgb(0, 0, 0, 0.8);
}
.generateButton:disabled {
background-color: rgb(0, 0, 0, 0.5);
cursor: wait;
}
.clearButton {
background-color: rgb(255, 255, 255);
border: 1px solid rgb(0, 0, 0);
border-radius: 5px;
color: rgb(0, 0, 0);
cursor: pointer;
font-size: 16px;
height: 50px;
outline: none;
width: 40%;
margin-left: auto;
margin-right: auto;
display: inline-block;
margin-left: 5px;
}
.clearButton:hover {
background-color: rgba(239, 239, 239, 0.8);
}

@ -0,0 +1,446 @@
import './App.css';
import React, { useState } from "react";
const DEFAULT_PARAMS = {
"model": "text-davinci-003",
"temperature": 0,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
//const SELECTED_PROMPT = "STATELESS"
function App() {
const [structureState, setStructureState] = useState(
[] //[{subject: '七里香', relation: '歌手', object: '人物'}]
);
const clearState = () => {
setStructureState([])
};
const updateStructure = (update) =>{
//setStructureState([]); //清理状态值
//console.log(JSON.parse(JSON.stringify(structureState)));
var current_structure = JSON.parse(JSON.stringify(structureState));
if (update.length === 0) {
console.log("0 output")
return;
}
update.forEach(ut => {
current_structure.push(ut);
});
setStructureState(current_structure);
}
const queryREPrompt = (prompt, prompt1, prompt2, prompt3, apiKey) => {
console.log(lanState);
var file = '';
if (lanState.lanValue === 'english') {
file ='prompts/RE-eng.prompt'
} else {
file ='prompts/RE-chi.prompt'
};
console.log(file);
fetch(file)
.then(response => response.text()) //response转文本->
.then(curprompt => {
console.log(curprompt);
curprompt = curprompt.replace("$prompt", prompt);
if(prompt1.length === 0){
console.log("default relation type list");
if (lanState.lanValue === 'english') {
curprompt = curprompt.replace("$prompt1", "['location-located_in', 'administrative_division-country', 'person-place_lived', 'person-company', 'person-nationality', 'company-founders', 'country-administrative_divisions', 'person-children', 'country-capital', 'deceased_person-place_of_death', 'neighborhood-neighborhood_of', 'person-place_of_birth']");
} else {
curprompt = curprompt.replace("$prompt1", "['所属专辑', '成立日期', '海拔', '官方语言', '占地面积', '父亲', '歌手', '制片人', '导演', '首都', '主演', '董事长', '祖籍', '妻子', '母亲', '气候', '面积', '主角', '邮政编码', '简称', '出品公司', '注册资本', '编剧', '创始人', '毕业院校', '国籍', '专业代码', '朝代', '作者', '作词', '所在城市', '嘉宾', '总部地点', '人口数量', '代言人', '改编自', '校长', '丈夫', '主持人', '主题曲', '修业年限', '作曲', '号', '上映时间', '票房', '饰演', '配音', '获奖']");
};
} else{
curprompt = curprompt.replace("$prompt1", prompt1);
}
if(prompt2.length === 0){
console.log("default subject type list");
if (lanState.lanValue === 'english') {
curprompt = curprompt.replace("$prompt2", "['organization', 'person', 'location', 'country']");
} else {
curprompt = curprompt.replace("$prompt2", "['国家', '行政区', '文学作品', '人物', '影视作品', '学校', '图书作品', '地点', '历史人物', '景点', '歌曲', '学科专业', '企业', '电视综艺', '机构', '企业/品牌', '娱乐人物']");
};
} else{
curprompt = curprompt.replace("$prompt2", prompt1);
}
if(prompt3.length === 0){
console.log("default object type list");
if (lanState.lanValue === 'english') {
curprompt = curprompt.replace("$prompt3", "['person', 'location', 'country', 'organization', 'city']");
} else {
curprompt = curprompt.replace("$prompt3", "['国家', '人物', 'Text', 'Date', '地点', '气候', '城市', '歌曲', '企业', 'Number', '音乐专辑', '学校', '作品', '语言']");
};
} else{
curprompt = curprompt.replace("$prompt3", prompt1);
}
console.log(curprompt);
const params = { ...DEFAULT_PARAMS, prompt: curprompt };
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + String(apiKey)
},
body: JSON.stringify(params)
};
fetch('https://api.openai.com/v1/completions', requestOptions)
.then(response => {
if (!response.ok) {
switch (response.status) {
case 401: // 401: Unauthorized: API key is wrong
throw new Error('Please double-check your API key.');
case 429: // 429: Too Many Requests: Need to pay
throw new Error('You exceeded your current quota, please check your plan and billing details.');
default:
throw new Error('Something went wrong with the request, please check the Network log');
}
}
//console.log(response)
return response.json();
})
.then((response) => {
const { choices } = response;
//console.log(choices)
const text = choices[0].text;
console.log(text);
//const updates = JSON.parse(text);
//console.log(updates);
//updateGraph(updates);
const reg = /\(.*?\)/g; //g表示全局搜索会进行多次match
var update = text.match(reg);
if(! update){
update = [text];
}
console.log(update);
console.log(update[0])
updateStructure(update);
//document.getElementsByClassName("searchBar")[0].value = "";
//document.getElementsByClassName("typeList")[0].value = "";
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false;
}).catch((error) => {
console.log(error);
alert(error);
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false; //出错则释放,为了能再次使用
});
})
};
const queryNERPrompt = (prompt, prompt1, prompt2, prompt3, apiKey) => {
console.log(lanState);
var file = '';
if (lanState.lanValue === 'english') {
file ='prompts/NER-eng.prompt'
} else {
file ='prompts/NER-chi.prompt'
};
console.log(file);
fetch(file)
.then(response => response.text()) //response转文本-> curprompt
.then(curprompt => {
console.log(curprompt);
if(prompt1.length === 0){
console.log("default ner type list");
if (lanState.lanValue === 'english') {
curprompt = curprompt.replace("$prompt1", "['LOC', 'MISC', 'ORG', 'PER']");
} else {
curprompt = curprompt.replace("$prompt1", "['组织机构', '地点', '人物']");
};
} else{
curprompt = curprompt.replace("$prompt1", prompt1);
}
curprompt = curprompt.replace("$prompt", prompt);
console.log(curprompt);
const params = { ...DEFAULT_PARAMS, prompt: curprompt };
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + String(apiKey)
},
body: JSON.stringify(params)
};
fetch('https://api.openai.com/v1/completions', requestOptions)
.then(response => {
if (!response.ok) {
switch (response.status) {
case 401: // 401: Unauthorized: API key is wrong
throw new Error('Please double-check your API key.');
case 429: // 429: Too Many Requests: Need to pay
throw new Error('You exceeded your current quota, please check your plan and billing details.');
default:
throw new Error('Something went wrong with the request, please check the Network log');
}
}
//console.log(response)
return response.json();
})
.then((response) => {
const { choices } = response;
//console.log(choices)
const text = choices[0].text;
console.log(text);
//const updates = JSON.parse(text);
//console.log(updates);
//updateGraph(updates);
const reg = /\(.*?\)/g; //g表示全局搜索会进行多次match
var update = text.match(reg);
if(! update){
update = [text];
}
console.log(update);
console.log(update[0])
updateStructure(update);
//document.getElementsByClassName("searchBar")[0].value = "";
//document.getElementsByClassName("typeList")[0].value = "";
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false;
}).catch((error) => {
console.log(error);
alert(error);
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false; //出错则释放,为了能再次使用
});
})
};
const queryEEPrompt = (prompt, prompt1, prompt2, prompt3, apiKey) => {
console.log(lanState);
var file = '';
if (lanState.lanValue === 'english') {
file ='prompts/EE-eng.prompt'
} else {
file ='prompts/EE-chi.prompt'
};
console.log(file);
fetch(file)
.then(response => response.text()) //response转文本-> curprompt
.then(curprompt => {
console.log(curprompt);
if(prompt1.length === 0){
console.log("default event type list");
if (lanState.lanValue === 'english') {
curprompt = curprompt.replace("$prompt1", "{'Personnel:Elect': ['Person', 'Entity', 'Position', 'Time', 'Place'], 'Business:Declare-Bankruptcy': ['Org', 'Time', 'Place'], 'Justice:Arrest-Jail': ['Person', 'Agent', 'Crime', 'Time', 'Place'], 'Life:Divorce': ['Person', 'Time', 'Place'], 'Life:Injure': ['Agent', 'Victim', 'Instrument', 'Time', 'Place']}");
} else {
curprompt = curprompt.replace("$prompt1", "{'组织行为-罢工': ['时间', '所属组织', '罢工人数', '罢工人员'], '竞赛行为-晋级': ['时间', '晋级方', '晋级赛事'], '财经/交易-涨停':['时间', '涨停股票'] , '组织关系-解雇': ['时间', '解雇方', '被解雇人员']}");
};
} else{
curprompt = curprompt.replace("$prompt1", prompt1);
}
curprompt = curprompt.replace("$prompt", prompt);
console.log(curprompt);
const params = { ...DEFAULT_PARAMS, prompt: curprompt };
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + String(apiKey)
},
body: JSON.stringify(params)
};
fetch('https://api.openai.com/v1/completions', requestOptions)
.then(response => {
if (!response.ok) {
switch (response.status) {
case 401: // 401: Unauthorized: API key is wrong
throw new Error('Please double-check your API key.');
case 429: // 429: Too Many Requests: Need to pay
throw new Error('You exceeded your current quota, please check your plan and billing details.');
default:
throw new Error('Something went wrong with the request, please check the Network log');
}
}
//console.log(response)
return response.json();
})
.then((response) => {
const { choices } = response;
//console.log(choices)
const text = choices[0].text;
console.log(text);
//const updates = JSON.parse(text);
//console.log(updates);
//updateGraph(updates);
const reg = /[^,{]+?:[\x20]*\{.*?\}/g; //g表示全局搜索会进行多次match
var update = text.match(reg);
if(! update){
update = [text];
}
console.log(update);
console.log(update[0])
updateStructure(update);
//document.getElementsByClassName("searchBar")[0].value = "";
//document.getElementsByClassName("typeList")[0].value = "";
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false;
}).catch((error) => {
console.log(error);
alert(error);
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false; //出错则释放,为了能再次使用
});
})
};
const queryPrompt = (prompt, prompt1, prompt2, prompt3, apiKey) => {
console.log(taskState.taskValue);
if (taskState.taskValue === 'RE') {
queryREPrompt(prompt, prompt1, prompt2, prompt3, apiKey);
} else if (taskState.taskValue === 'NER') {
queryNERPrompt(prompt, prompt1, prompt2, prompt3, apiKey);
} else if (taskState.taskValue === 'EE') {
queryEEPrompt(prompt, prompt1, prompt2, prompt3, apiKey);
} else {
alert("Please select a task");
document.body.style.cursor = 'default';
document.getElementsByClassName("generateButton")[0].disabled = false;
}
}
const createIE = () => {
document.body.style.cursor = 'wait';
document.getElementsByClassName("generateButton")[0].disabled = true;
const prompt = document.getElementsByClassName("searchBar")[0].value;
const prompt1 = document.getElementById("prompt1").value;
const prompt2 = document.getElementById("prompt2").value;
const prompt3 = document.getElementById("prompt3").value;
var apiKey = document.getElementsByClassName("apiKeyTextField")[0].value;
//console.log(apiKey);
if (apiKey.length === 0){
console.log("default open AI key");
const temp_k = "@WITy9ios86qOmgLcFT3BlbkFJi68ofPwe9IVifL3NYgZ5";
apiKey = "sk-nd9" + temp_k.substring(1);
//console.log(apiKey);
}
queryPrompt(prompt, prompt1, prompt2, prompt3, apiKey);
}
const lists = structureState.map((triplet) =>
<li key={triplet.toString()}> {triplet}</li>
);
// 语言选项
const [lanState, setLanState] = useState(
{lanValue: "english"}
);
const handleChange = (event) => {
console.log(event);
console.log(event.target.value);
//setLanState({lanValue: event.target.value},
// () => {console.log(lanState)});
setLanState({lanValue: event.target.value}); // 坑set状态后lanState值不会立即改变因为react是渲染周期结束后才更新值。
};
// 任务选项
const [taskState, setTaskState] = useState(
{taskValue: "NER"}
);
const handleChange2 = (event) => {
console.log(event);
console.log(event.target.value);
//setLanState({lanValue: event.target.value},
// () => {console.log(lanState)});
setTaskState({taskValue: event.target.value});
};
// <form>能控制radio为一组。
return (
<div className='container'>
<h1 className="headerText">基于民航有噪声数据的NLP处理工具 </h1>
<p className='subheaderText'>基于民航有噪声数据的NLP处理工具 </p>
<p className='subheaderText'>工具简介输入非结构化文本->消除噪声数据预处理->无噪声的标准化文本->利用手动枚举的论元关系字典样例如上和提示词工程样例如上使大模型根据知识图谱里的内容neo4j和langchain输出主体飞机和要素行为地点json格式</p>
<p className='subheaderText'>我们支持以下功能:</p>
<div>
<table>
<tbody>
<tr>
<td>RE</td>
<td>entity-relation joint extraction</td>
</tr>
<tr>
<td>NER</td>
<td>named entity recoginzation</td>
</tr>
<tr>
<td>EE</td>
<td>event extraction</td>
</tr>
</tbody>
</table>
</div>
<center>
<div>
<form>
<input type="radio" id="zh" value="chinese" checked={lanState.lanValue === 'chinese'}
onChange={handleChange} /> Chinese
<input type="radio" id="en" value="english" checked={lanState.lanValue === 'english'}
onChange={handleChange} /> English
</form>
</div>
<div>
<form>
<input type="radio" id="re" value="RE" checked={taskState.taskValue === 'RE'}
onChange={handleChange2} /> RE
<input type="radio" id="ner" value="NER" checked={taskState.taskValue === 'NER'}
onChange={handleChange2} /> NER
<input type="radio" id="ee" value="EE" checked={taskState.taskValue === 'EE'}
onChange={handleChange2} /> EE
</form>
</div>
<div className='inputContainer'>
<input className="searchBar" placeholder="Input sentence..."></input>
<input className="typeList" id="prompt1" placeholder="relation/ner/event type list;
like ['nationality']/['LOC']/{'Life:Divorce':['Person','Time','Place']}"></input>
<input className="typeList" id="prompt2" placeholder="Subject type list... like ['person','location']"></input>
<input className="typeList" id="prompt3" placeholder="Object type list... like ['country','location']"></input>
<input className="apiKeyTextField" type="password" placeholder="Enter your OpenAI API key..."></input>
<button className="generateButton" onClick={createIE}>Generate</button>
<button className="clearButton" onClick={clearState}>Clear</button>
</div>
</center>
<div className='graphContainer'>
<ul className='ulC'>{lists}</ul>
</div>
<p className='footer'>Tip: you can clear output by clicking Clear button for aesthetics
<br></br>Note: Except for the mandatory "Input sentence" and "OpenAI API key" fields, other items can be optional.
<br></br>We set the default relation/entity/event type list; subject type list; object type list. Change the default setting and extract specific information by reset the type lists.</p>
</div>
);
}
export default App;

@ -0,0 +1,9 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: black;
}

@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
const root = ReactDOM.createRoot(document.getElementById('root')); // 渲染到这个index.html中的root id处
root.render(
<App />
);

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Loading…
Cancel
Save