-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate diproche via swipl-wasm #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
TimothyGillespie
wants to merge
28
commits into
master
Choose a base branch
from
TimothyGillespie/diprocheIntegration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
eceb57c
Add wasm code to proj
Khazuar 78bddad
Get wasm to work
Khazuar 8f38e2d
Attempt to clean up.
Khazuar 2d655b2
Add separate setup with longer timeout
Khazuar d0cc34e
Fix linter issues
Khazuar f0fd2d7
Merge pull request #112 from diproche/swipl-wasm-async
TimothyGillespie 7fba34d
Change string[] to string in the return of the query function
TimothyGillespie 2680563
Rename fubar to swiplwasmHandler
TimothyGillespie 91f2e4b
Add shx and diproche dependency and scripts
TimothyGillespie 76ed5dd
Include the copied diproche file in .gitignore
TimothyGillespie 2f2eb04
Add a diproche handler
TimothyGillespie a221d04
Parse diproche errors via the diproche handler
TimothyGillespie faa2383
Merge branch 'master' into TimothyGillespie/diprocheIntegration
TimothyGillespie 022a695
Change from https to ssl for the diproche dependency
TimothyGillespie 5f127d2
Move swipl-wasm into the src folder to properly import
TimothyGillespie 06c4354
Fix linter issues
TimothyGillespie 00c8c54
Add comment to bagof
TimothyGillespie 80656c5
Change path to swipl-wasm for the diprocheHandler
TimothyGillespie ce8c4e0
Add comment to explain odd import
TimothyGillespie 7c326ca
Ensure right import order
TimothyGillespie 542eb10
Remove console logs
TimothyGillespie 3ee6dd7
Utilize the more efficient suggestion
TimothyGillespie e540768
Reinsert and explain the export
TimothyGillespie 0deff0f
Update src/util/parseStringToIntegerArray.ts
TimothyGillespie 359c412
Update src/util/parseStringToIntegerArray.ts
TimothyGillespie 2a10970
Update src/util/prolog/swiplwasmHandler.test.ts
TimothyGillespie b751932
Resolve merge conflict
TimothyGillespie f69ae55
Rename test
TimothyGillespie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| /node_modules | ||
| /.pnp | ||
| .pnp.js | ||
| /src/util/diproche/diprocheProgram | ||
| /diproche.pl | ||
|
|
||
| # testing | ||
| /coverage | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,50 @@ | ||
| { | ||
| "name": "diproche-webinterface", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@types/lodash": "^4.14.136", | ||
| "@types/react-router-dom": "^4.3.4", | ||
| "@types/shortid": "0.0.29", | ||
| "bootstrap": "^4.3.1", | ||
| "jquery": "^3.4.1", | ||
| "lodash": "^4.17.15", | ||
| "node-sass": "^4.12.0", | ||
| "react": "^16.8.6", | ||
| "react-bootstrap": "^1.0.0-beta.10", | ||
| "react-dom": "^16.8.6", | ||
| "react-router-dom": "^5.0.1", | ||
| "react-scripts": "^3.0.1", | ||
| "shortid": "^2.2.14", | ||
| "tau-prolog": "^0.2.66", | ||
| "typescript": "3.4.2" | ||
| }, | ||
| "scripts": { | ||
| "start": "react-scripts start", | ||
| "lint": "tslint --project .", | ||
| "build": "react-scripts build", | ||
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": "react-app" | ||
| }, | ||
| "browserslist": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not ie <= 11", | ||
| "not op_mini all" | ||
| ], | ||
| "devDependencies": { | ||
| "@types/jest": "24.0.11", | ||
| "@types/node": "11.13.2", | ||
| "@types/node-sass": "^4.11.0", | ||
| "@types/react": "16.8.13", | ||
| "@types/react-dom": "16.8.3", | ||
| "shx": "^0.3.2", | ||
| "tslint": "^5.18.0" | ||
| }, | ||
| "proxy": "http://localhost:5000" | ||
| "name": "diproche-webinterface", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@types/lodash": "^4.14.136", | ||
| "@types/react-router-dom": "^4.3.4", | ||
| "@types/shortid": "0.0.29", | ||
| "bootstrap": "^4.3.1", | ||
| "jquery": "^3.4.1", | ||
| "lodash": "^4.17.15", | ||
| "node-sass": "^4.12.0", | ||
| "one_file_diproche": "git+ssh://git@github.com/TimothyGillespie/one_file_diproche.git", | ||
| "react": "^16.8.6", | ||
| "react-bootstrap": "^1.0.0-beta.10", | ||
| "react-dom": "^16.8.6", | ||
| "react-router-dom": "^5.0.1", | ||
| "react-scripts": "^3.0.1", | ||
| "shortid": "^2.2.14", | ||
| "tau-prolog": "^0.2.66", | ||
| "typescript": "3.4.2" | ||
| }, | ||
| "scripts": { | ||
| "start": "npm run mv-diproche && react-scripts start", | ||
| "lint": "tslint --project .", | ||
| "build": "npm run mv-diproche && react-scripts build", | ||
| "test": "npm run mv-diproche && react-scripts test", | ||
| "eject": "react-scripts eject", | ||
| "mv-diproche": "shx cp ./node_modules/one_file_diproche/diproche_onefile.pl ./diproche.pl" | ||
| }, | ||
| "eslintConfig": { | ||
| "extends": "react-app" | ||
| }, | ||
| "browserslist": [ | ||
| ">0.2%", | ||
| "not dead", | ||
| "not ie <= 11", | ||
| "not op_mini all" | ||
| ], | ||
| "devDependencies": { | ||
| "@types/jest": "24.0.11", | ||
| "@types/node": "11.13.2", | ||
| "@types/node-sass": "^4.11.0", | ||
| "@types/react": "16.8.13", | ||
| "@types/react-dom": "16.8.3", | ||
| "shx": "^0.3.2", | ||
| "tslint": "^5.18.0" | ||
| }, | ||
| "proxy": "http://localhost:5000" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { addIssue } from "../issueHandling/issueMapping"; | ||
|
|
||
| function addDiprocheIssues(unverifiedLines: number[]): void { | ||
| unverifiedLines.forEach((singleLine: number) => { | ||
| addIssue("UNVERIFIED_LINE", { fromIndex: singleLine, toIndex: singleLine}); | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| export default addDiprocheIssues; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import DiprocheHandler from "./diprocheHandler"; | ||
| import tests from "./diprocheTestAssets.json"; | ||
|
|
||
| describe("Diproche Handler", () => { | ||
|
|
||
| const diproche = new DiprocheHandler(); | ||
|
|
||
| beforeAll(async () => { | ||
| await diproche.loadDiproche(); | ||
| }, 15000); | ||
|
|
||
| test("Will return 16 for test1", async () => { | ||
| const result = await diproche.query(tests.test1); | ||
| expect(result).toEqual([16]); | ||
| }, 50000); | ||
|
|
||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
|
|
||
| // The order of these two imports makes a functional difference | ||
| // tslint:disable: ordered-imports | ||
| import "../swipl-wasm/swipl-web"; | ||
| import { consult, loadingComplete as swiLoadingComplete, query } from "../prolog/swiplwasmHandler"; | ||
| // tslint:enable: ordered-imports | ||
|
|
||
| const diprocheProgramCode: string = fs.readFileSync( | ||
| path.resolve(__dirname, "../../../diproche.pl"), | ||
| {encoding: "utf-8"}, | ||
| ); | ||
|
|
||
| class DiprocheHandler { | ||
| public async loadDiproche(): Promise<void> { | ||
| await swiLoadingComplete; | ||
| await consult(diprocheProgramCode); | ||
| console.log("Diproche was loaded"); | ||
| } | ||
|
|
||
| public async query(queryString: string): Promise<string> { | ||
| let copyQueryString: string = queryString; | ||
| copyQueryString = copyQueryString.substr(0, copyQueryString.length - 1); | ||
|
|
||
| const result: string = await query("diproche_fo(" + copyQueryString + ", X)."); | ||
| return result; | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| export default DiprocheHandler; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "test1": "[[wir,zeigen,[a,and,b],<->,[b,and,a]],[=>],[angenommen,a,and,b],[dann,a],[ferner,gilt,b],[damit,folgt,b,and,a],[qed],[abs],[<=],[nehmen,wir,jetzt,an,dass,b,and,a],[dann,folgt,a],[ausserdem,folgt,b],[also,gilt,nun,a,and,b],[qed],[damit,gilt,[a,and,b],<->,[c,and,a]]]." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * Converts a string to an array of numbers | ||
| * @param integerArrayAsString - A string representing a array of integers (i.e. [16, 87, 27]) | ||
| * @return An array of integers represented by the string | ||
| */ | ||
| export default function parseStringToIntegerArray(integerArrayAsString: string) { | ||
|
|
||
| if (integerArrayAsString === "[]") { | ||
| return []; | ||
| } | ||
|
|
||
| if ( | ||
| integerArrayAsString.substr(0, 1) !== "[" || | ||
| integerArrayAsString.substr(integerArrayAsString.length - 1, 1) !== "]" | ||
| ) { | ||
| throw new Error("The given string is not contained in brackets '[]'"); | ||
| } | ||
|
|
||
| // Removing the outter brackets | ||
| integerArrayAsString = integerArrayAsString.substr(1, integerArrayAsString.length - 2); | ||
|
|
||
| const arrayOfInteger = integerArrayAsString.split(",").map(s => Number.parseInt(s, 10)); | ||
|
|
||
| return arrayOfInteger; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // The order of these two imports makes a functional difference | ||
| // tslint:disable: ordered-imports | ||
| import "../swipl-wasm/swipl-web"; | ||
| import { consult, loadingComplete as swiLoadingComplete, query } from "./swiplwasmHandler"; | ||
| // tslint:enable: ordered-imports | ||
|
|
||
| describe("swiplWasmHandler", () => { | ||
| beforeAll(async () => { | ||
| await swiLoadingComplete; | ||
| }, 15000); | ||
|
|
||
| test("Test whether bob and frank are men", async () => { | ||
| await consult("man(bob)."); | ||
| expect(await query("man(bob).")).toEqual("true."); | ||
| expect(await query("man(frank).")).toEqual("false."); | ||
| }); | ||
|
|
||
| test("Waiting on previous results and maintaining order is not necessary", async () => { | ||
| consult("man(bob)."); | ||
| const bobResult = query("man(bob)."); | ||
| const frankResult = query("man(frank)."); | ||
|
|
||
| expect(await frankResult).toEqual("false."); | ||
| expect(await bobResult).toEqual("true."); | ||
| }); | ||
|
|
||
| test("Can reconsult", async () => { | ||
| consult("man(bob)."); | ||
| const bobResult = query("man(bob)."); | ||
|
|
||
| consult("man(frank)."); | ||
| const frankResult = query("man(frank)."); | ||
|
|
||
| expect(await bobResult).toEqual("true."); | ||
| expect(await frankResult).toEqual("true."); | ||
| }); | ||
|
|
||
| test("Can return concrete answer", async () => { | ||
| await consult("man(bob)."); | ||
| expect(await query("man(N).")).toEqual("N = bob."); | ||
| }); | ||
|
|
||
| /* doesn't work yet. | ||
|
|
||
| test("Can return multiple answers", async () => { | ||
| await consult("man(bob). man(frank)."); | ||
| expect(await query("man(N).")).toEqual("N = bob;", "N = frank."); | ||
| }); | ||
|
|
||
| test("Handles consulting errors", async () => { | ||
| try { | ||
| await consult("man(bob."); | ||
| fail("Should have thrown."); | ||
| } catch (e) { | ||
| expect(e.message).toBe( | ||
| "ERROR: /file.pl:1:7: Syntax error: Operator expected", | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| test("Handles querying errors", async () => { | ||
| await consult("man(bob)."); | ||
| await query("man(bob)."); | ||
| }); | ||
| */ | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines are not indices