Skip to content

Commit

Permalink
problem with sense API
Browse files Browse the repository at this point in the history
  • Loading branch information
lavedon committed Apr 21, 2021
1 parent 7c4833c commit 8a0d6a4
Show file tree
Hide file tree
Showing 21 changed files with 2,078 additions and 2 deletions.
31 changes: 29 additions & 2 deletions API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,31 @@ public static void APICalls(CurrentQuery query)
Trace.WriteLine("Called callSensesAPI");
Uri requestURL = new Uri(baseURL + query.WordID + "/senses/");
Trace.WriteLine("Making the request");
Trace.WriteLine(client.GetStringAsync(requestURL).Result);
try {
client.Timeout = TimeSpan.FromMinutes(10);

// HttpResponseMessage response = new HttpResponseMessage();
var response = client.GetStreamAsync(requestURL).Result;
Console.WriteLine(response);
}
catch (AggregateException ae)
{
Console.WriteLine("Caught aggregate exception-Task.Wait behavior");
var flatExs = ae.Flatten().InnerExceptions;
foreach (var ex in flatExs)
{
Console.WriteLine($"{ex}");
}
ae.Handle( (x) =>
{
if (x is UnauthorizedAccessException) // This we know how to handle.
{
Console.WriteLine("You do not have access.");
return true;
}
return false; // Let anything else stop the application.
});
}

try {
var response = client.GetStreamAsync(requestURL).Result;
Expand Down Expand Up @@ -268,8 +292,11 @@ public static void APICalls(CurrentQuery query)
{
resetHeaders(client);
Task getSenses = new Task(callSensesAPI, "CallSenses");
getSenses.ConfigureAwait(false);
getSenses.RunSynchronously();
Trace.WriteLine("Ran senses synchronously.");


Trace.WriteLine("Ran senses using start.");

JsonElement senseData = JSONResponse.RootElement.GetProperty("data");

Expand Down
Binary file modified bin/Debug/net5.0/OxfordV2.dll
Binary file not shown.
Binary file modified bin/Debug/net5.0/OxfordV2.pdb
Binary file not shown.
Binary file modified bin/Debug/net5.0/ref/OxfordV2.dll
Binary file not shown.
Empty file.
Empty file.
51 changes: 51 additions & 0 deletions logs/Log_OxfordApplication_20210420-2323.txt

Large diffs are not rendered by default.

Empty file.
99 changes: 99 additions & 0 deletions logs/Log_OxfordApplication_20210420-2341.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
computer
Found that QueryMode is set to words.
Looking up the word:
computer
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "computer_nn01", "band": 9, "meta": {"created": 1891, "revised": true, "updated": 2008}, "lemma": "computer", "oed_url": "https://www.oed.com/view/Entry/37975#eid8618136", "daterange": {"end": null, "start": 1613, "obsolete": false, "rangestring": "1613\u2014"}, "etymology": {"etymons": [{"word": "compute", "language": "English", "target_id": "compute_vb01", "part_of_speech": "VB"}, {"word": "-er", "language": "English", "target_id": "er_su01", "part_of_speech": "SUFFIX"}], "etymology_type": "derivative", "etymon_language": [["English"]], "source_language": [["European languages", "Italic", "Latin"]], "etymology_summary": "Formed within English, by derivation."}, "first_use": "\u2018R. B.\u2019", "frequency": [[1750, 0.21], [1760, 0.18], [1770, 0.17], [1780, 0.16], [1790, 0.15], [1800, 0.14], [1810, 0.083], [1820, 0.077], [1830, 0.086], [1840, 0.086], [1850, 0.093], [1860, 0.11], [1870, 0.13], [1880, 0.16], [1890, 0.18], [1900, 0.21], [1910, 0.24], [1920, 0.45], [1930, 2.1], [1940, 10], [1950, 17], [1960, 40], [1970, 77], [1980, 110], [1990, 120], [2000, 120], [2010, 120]], "sense_ids": ["computer_nn01-8618138", "computer_nn01-8618177", "computer_nn01-130514973", "computer_nn01-130514976"], "definition": "An electronic device (or system of devices) which is used to store, manipulate, and communicate information, perform complex calculations, or control or regulate other devices or machines, and is capable of receiving information (data) and of processing it in accordance with variable procedural instructions (programs or software); esp. a small, self-contained one for individual use in the home or workplace, used esp. for handling text, images, music, and video, accessing and using the internet\u2026", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}], "frequency_id": "computer_nn01-fq", "oed_reference": "computer, n.", "pronunciations": [{"ipa": ["k\u0259m\u02c8pju\u02d0t\u0259"], "region": "British"}, {"ipa": ["k\u0259m\u02c8pjud\u0259r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "computer_nn01-130514973"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
computer_nn01The user's input was read as:
s
Get senses selected.
API.cs is starting senses mode.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Called callSensesAPI
Making the request
Ran senses synchronously.
System.NullReferenceException: Object reference not set to an instance of an object.
at OxfordV2.API.APICalls(CurrentQuery query) in C:\my-coding-projects\Oxford-App\OxfordV2\API.cs:line 348
In MainMenu()
The user's input was read as:
s
Get senses selected.
API.cs is starting senses mode.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Called callSensesAPI
Making the request
Ran senses synchronously.
System.NullReferenceException: Object reference not set to an instance of an object.
at OxfordV2.API.APICalls(CurrentQuery query) in C:\my-coding-projects\Oxford-App\OxfordV2\API.cs:line 348
In MainMenu()
The user's input was read as:
s
Get senses selected.
API.cs is starting senses mode.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Called callSensesAPI
Making the request
Ran senses synchronously.
System.NullReferenceException: Object reference not set to an instance of an object.
at OxfordV2.API.APICalls(CurrentQuery query) in C:\my-coding-projects\Oxford-App\OxfordV2\API.cs:line 348
In MainMenu()
The user's input was read as:
x
Exit selected.
Empty file.
57 changes: 57 additions & 0 deletions logs/Log_OxfordApplication_20210420-2350.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
computer
Found that QueryMode is set to words.
Looking up the word:
computer
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "computer_nn01", "band": 9, "meta": {"created": 1891, "revised": true, "updated": 2008}, "lemma": "computer", "oed_url": "https://www.oed.com/view/Entry/37975#eid8618136", "daterange": {"end": null, "start": 1613, "obsolete": false, "rangestring": "1613\u2014"}, "etymology": {"etymons": [{"word": "compute", "language": "English", "target_id": "compute_vb01", "part_of_speech": "VB"}, {"word": "-er", "language": "English", "target_id": "er_su01", "part_of_speech": "SUFFIX"}], "etymology_type": "derivative", "etymon_language": [["English"]], "source_language": [["European languages", "Italic", "Latin"]], "etymology_summary": "Formed within English, by derivation."}, "first_use": "\u2018R. B.\u2019", "frequency": [[1750, 0.21], [1760, 0.18], [1770, 0.17], [1780, 0.16], [1790, 0.15], [1800, 0.14], [1810, 0.083], [1820, 0.077], [1830, 0.086], [1840, 0.086], [1850, 0.093], [1860, 0.11], [1870, 0.13], [1880, 0.16], [1890, 0.18], [1900, 0.21], [1910, 0.24], [1920, 0.45], [1930, 2.1], [1940, 10], [1950, 17], [1960, 40], [1970, 77], [1980, 110], [1990, 120], [2000, 120], [2010, 120]], "sense_ids": ["computer_nn01-8618138", "computer_nn01-8618177", "computer_nn01-130514973", "computer_nn01-130514976"], "definition": "An electronic device (or system of devices) which is used to store, manipulate, and communicate information, perform complex calculations, or control or regulate other devices or machines, and is capable of receiving information (data) and of processing it in accordance with variable procedural instructions (programs or software); esp. a small, self-contained one for individual use in the home or workplace, used esp. for handling text, images, music, and video, accessing and using the internet\u2026", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}], "frequency_id": "computer_nn01-fq", "oed_reference": "computer, n.", "pronunciations": [{"ipa": ["k\u0259m\u02c8pju\u02d0t\u0259"], "region": "British"}, {"ipa": ["k\u0259m\u02c8pjud\u0259r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "computer_nn01-130514973"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
computer_nn01The user's input was read as:
s
Get senses selected.
API.cs is starting senses mode.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Called callSensesAPI
Making the request
Ran senses using start.
System.NullReferenceException: Object reference not set to an instance of an object.
at OxfordV2.API.APICalls(CurrentQuery query) in C:\my-coding-projects\Oxford-App\OxfordV2\API.cs:line 351
In MainMenu()
The user's input was read as:
x
Exit selected.
1,785 changes: 1,785 additions & 0 deletions logs/Log_OxfordApplication_20210421-0003.txt

Large diffs are not rendered by default.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
57 changes: 57 additions & 0 deletions logs/Log_OxfordApplication_20210421-1845.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Leaving Main method.
Starting Main Menu
In MainMenu()
Automatically looking up user entered word:
computer
Found that QueryMode is set to words.
Looking up the word:
computer
Now to call the words endpoint.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Calling the API
Called callWordsAPI
Making the request
Got responses.
Set JSONResponse to the response.
Left getWords task with the JSONResponse.
Parsing JSON
We now have the data as a string.
[{"id": "computer_nn01", "band": 9, "meta": {"created": 1891, "revised": true, "updated": 2008}, "lemma": "computer", "oed_url": "https://www.oed.com/view/Entry/37975#eid8618136", "daterange": {"end": null, "start": 1613, "obsolete": false, "rangestring": "1613\u2014"}, "etymology": {"etymons": [{"word": "compute", "language": "English", "target_id": "compute_vb01", "part_of_speech": "VB"}, {"word": "-er", "language": "English", "target_id": "er_su01", "part_of_speech": "SUFFIX"}], "etymology_type": "derivative", "etymon_language": [["English"]], "source_language": [["European languages", "Italic", "Latin"]], "etymology_summary": "Formed within English, by derivation."}, "first_use": "\u2018R. B.\u2019", "frequency": [[1750, 0.21], [1760, 0.18], [1770, 0.17], [1780, 0.16], [1790, 0.15], [1800, 0.14], [1810, 0.083], [1820, 0.077], [1830, 0.086], [1840, 0.086], [1850, 0.093], [1860, 0.11], [1870, 0.13], [1880, 0.16], [1890, 0.18], [1900, 0.21], [1910, 0.24], [1920, 0.45], [1930, 2.1], [1940, 10], [1950, 17], [1960, 40], [1970, 77], [1980, 110], [1990, 120], [2000, 120], [2010, 120]], "sense_ids": ["computer_nn01-8618138", "computer_nn01-8618177", "computer_nn01-130514973", "computer_nn01-130514976"], "definition": "An electronic device (or system of devices) which is used to store, manipulate, and communicate information, perform complex calculations, or control or regulate other devices or machines, and is capable of receiving information (data) and of processing it in accordance with variable procedural instructions (programs or software); esp. a small, self-contained one for individual use in the home or workplace, used esp. for handling text, images, music, and video, accessing and using the internet\u2026", "main_entry": true, "inflections": [{"region": "British", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}, {"region": "US", "inflections": [{"form": "computer", "part_of_speech": "NN"}, {"form": "computers", "part_of_speech": "NNS"}]}], "frequency_id": "computer_nn01-fq", "oed_reference": "computer, n.", "pronunciations": [{"ipa": ["k\u0259m\u02c8pju\u02d0t\u0259"], "region": "British"}, {"ipa": ["k\u0259m\u02c8pjud\u0259r"], "region": "US"}], "parts_of_speech": ["NN"], "primary_sense_id": "computer_nn01-130514973"}]
Extracted definition.
Set definition to query object.
Now to get and set the word ID.
The wordID was grabbed as:
computer_nn01The user's input was read as:
s
Get senses selected.
API.cs is starting senses mode.
Getting request keys
resetHeaders called.
App Id is:
4ebc819b
Key is:
b6b1ca0e4e766b222d56c20f43c2396f
Here are the request Headers...
Accept: application/json
app_id: 4ebc819b
app_key: b6b1ca0e4e766b222d56c20f43c2396f

Called callSensesAPI
Making the request
Ran senses using start.
System.NullReferenceException: Object reference not set to an instance of an object.
at OxfordV2.API.APICalls(CurrentQuery query) in C:\my-coding-projects\Oxford-App\OxfordV2\API.cs:line 360
In MainMenu()
The user's input was read as:
x
Exit selected.
Binary file modified obj/Debug/net5.0/OxfordV2.dll
Binary file not shown.
Binary file modified obj/Debug/net5.0/OxfordV2.pdb
Binary file not shown.
Binary file modified obj/Debug/net5.0/ref/OxfordV2.dll
Binary file not shown.

0 comments on commit 8a0d6a4

Please sign in to comment.