Skip to content
Snippets Groups Projects
Commit fbadc044 authored by Manuel Scheibl's avatar Manuel Scheibl
Browse files

Transformed ishikawa program (with mxGraph) into JSX compatible format....

Transformed ishikawa program (with mxGraph) into JSX compatible format. Integrated Ishikawa into the main program.
parent 0e67a41d
No related branches found
No related tags found
No related merge requests found
......@@ -8261,6 +8261,11 @@
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA=="
},
"mxgraph-js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mxgraph-js/-/mxgraph-js-1.0.1.tgz",
"integrity": "sha1-IXectONRZu0rJAdeqi2UR5kGdaM="
},
"nan": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
......
......@@ -6,13 +6,14 @@
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"bootstrap": "^4.4.1",
"mxgraph-js": "^1.0.1",
"react": "^16.12.0",
"react-bootstrap": "^1.0.0-beta.16",
"react-burger-menu": "^2.6.13",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0",
"bootstrap": "^4.4.1",
"react-bootstrap": "^1.0.0-beta.16",
"react-burger-menu": "^2.6.13",
"react-sortable-hoc": "^1.10.1"
},
"scripts": {
......
This diff is collapsed.
let hypothesis = "";
/*
Simple Hypothesis generator without the approach to generate a diverse sentence as a hypothesis.
*/
//###################################
export function create_hypothesis_simple(json_node_structure) {
hypothesis = "";
const node_structure = JSON.parse(json_node_structure);
const listOfCategories = node_structure["listOfCategories"];
listOfCategories.forEach(serialize_cause);
return hypothesis;
}
function serialize_cause(cause, index) {
for (let idx in cause.causeList) {
let subcause = cause.causeList[idx];
let entry = "";
if (cause.categoryName) {
entry += `A cause for the category \"${cause.categoryName}\" is `;
}
else if (cause.causeName) {
entry += `A subcause for the cause \"${cause.causeName}\" is `;
}
entry += '\"' + subcause.causeName + '\".\n';
hypothesis += entry;
}
cause["causeList"].forEach(serialize_cause);
}
//###################################
/*
This approach uses a template to generate a hypothesis
*/
//###################################
const INIT_TO_CATEGORY = [
["For the category \"", "\" there are numerous causes. \n"],
["In terms of \"", "\", following causes drive it: \n"],
["\"", "\" is impacted by following causes: \n"],
["Causes that effect \"", "\" are manifold. \n"]
];
const FIRST_CAUSE =
[["The first cause is ", ". "],
["Firstly, ", " is a reason. "],
["A cause is ", ". "]];
const MIDDLE_CAUSE = [
["Another cause is ", ". "],
["Moreover ", " needs to be mentioned. "],
["Also a cause is ", ". "],
["Besides ", " is a mentionable cause. "],
["", " is also important. "],
["", " does als impact the results. "],
["", " is noteworthy, likewise. "],
["", " needs to be considered, too. "]];
const LAST_CAUSE =
[["Lastly, ", " is a cause. "],
["", " finishes of the list of causes. "],
["The final cause is ", ". "]];
const SUBCAUSE_TRANSITION = [
["There are some sub-causes to ", ". "],
["", " is due to following causes: "]];
const SUBCAUSE_END = [
["This finishes the sub-causes for ", ". "],
["These were all of ", "'s sub-causes. "]];
export function create_hypothesis(json_node_structure) {
hypothesis = "";
const node_structure = JSON.parse(json_node_structure);
const listOfCategories = node_structure["listOfCategories"];
listOfCategories.forEach(generate_sentence_for_category);
return hypothesis;
}
function generate_sentence_for_category(category_map, index) {
const categoryName = category_map["categoryName"];
const causeList = category_map["causeList"];
if (causeList.length > 0) {
let rnd_init_to_category = get_random_element_from(INIT_TO_CATEGORY);
hypothesis += rnd_init_to_category[0] + categoryName + rnd_init_to_category[1];
let i = 0;
while (i < causeList.length) {
generate_sentence_for_cause(causeList[i], i == 0 ? 0 : (i == causeList.length - 1 ? 2 : 1));
i++;
}
}
}
//begin_center_or_last = 0 -> First element
//begin_center_or_last = 1 -> Some middle element
//begin_center_or_last = 2 -> Last element
function generate_sentence_for_cause(cause_map, begin_center_or_last) {
const causeName = cause_map["causeName"];
const causeList = cause_map["causeList"];
const cause_text = get_random_element_from(begin_center_or_last == 0 ? FIRST_CAUSE : (begin_center_or_last == 1 ? MIDDLE_CAUSE : LAST_CAUSE));
hypothesis += cause_text[0] + causeName + cause_text[1];
if (causeList.length > 0) {
let subcause_transition = get_random_element_from(SUBCAUSE_TRANSITION);
hypothesis += subcause_transition[0] + causeName + subcause_transition[1];
console.log(hypothesis);
let i = 0;
while (i < causeList.length) {
generate_sentence_for_cause(causeList[i], i == 0 ? 0 : (i == causeList.length - 1 ? 2 : 1));
i++;
}
let subcause_end = get_random_element_from(SUBCAUSE_END);
hypothesis += subcause_end[0] + causeName + subcause_end[1];
}
}
function get_random_element_from(array) {
return array[Math.floor(Math.random() * array.length)];
}
//###################################
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment