Skip to content

Commit

Permalink
created class for sense type
Browse files Browse the repository at this point in the history
  • Loading branch information
lavedon committed Apr 20, 2021
1 parent bfdafa1 commit 5c0cd54
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 8 deletions.
17 changes: 16 additions & 1 deletion API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,21 @@ 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));
Trace.WriteLine(client.GetStringAsync(requestURL).Result);

try {
var response = client.GetStreamAsync(requestURL).Result;
Trace.WriteLine("Got senses responses.");
JSONResponse = JsonDocument.Parse(response);
Trace.WriteLine("Set JSONResponse to the response.");
}
catch(Exception ex)
{
Trace.WriteLine("Exception");
Trace.WriteLine(ex.GetType());
Trace.WriteLine(ex.Message);
}

};

Action<object> callQuotationsAPI = (Object obj) =>
Expand Down Expand Up @@ -302,6 +316,7 @@ public static void APICalls(CurrentQuery query)
currentQuote.Title = quoteTitle.ToString();
currentQuote.Author = quoteAuthor.ToString();

// @TODO add all quotes whether you have seen them or not?
query.Quotes.Add(currentQuote);
Console.WriteLine();
Console.WriteLine("----Enter for more - X to exit----");
Expand Down
11 changes: 11 additions & 0 deletions ConsoleUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ static void MainMenu(CurrentQuery query)
Console.WriteLine("Please Enter a word");
string word = Console.ReadLine().ToLower().Trim();
query.UserEnteredWord = word;
try {
Trace.WriteLine("Automatically looking up user entered word:");
Trace.WriteLine(query.UserEnteredWord);
query.QueryMode = Modes.Word;
API.APICalls(query);
}
catch (Exception ex)
{
Trace.WriteLine("Exception on automatic word look up");
Trace.WriteLine(ex);
}
}
Console.WriteLine();
Console.WriteLine("-------------------------");
Expand Down
5 changes: 4 additions & 1 deletion CurrentQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class CurrentQuery : IDisposable
public string Lamma { get; set; }
public int NumberOfQuotes { get; set; }
public string Quote { get; set; }


public List<Quote> Quotes { get; set; }
public List<Sense> Senses { get; set; }

public string EtymologySummary { get; set; }
public string FirstUse { get; set; }
Expand All @@ -35,7 +38,7 @@ public CurrentQuery() {
this.HasLookedUpWord = false;
this.Quotes = new List<Quote>();
}
public string? Source { get; set; }
public string Source { get; set; }

public void Dispose ()
{
Expand Down
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Program
static void Main(string[] args)
{
// Show Trace on console
// TextWriterTraceListener tr1 = new TextWriterTraceListener(System.Console.Out);
// Trace.Listeners.Add(tr1);
TextWriterTraceListener tr1 = new TextWriterTraceListener(System.Console.Out);
Trace.Listeners.Add(tr1);

// Try to create the logs directory

Expand Down
8 changes: 4 additions & 4 deletions Quote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace OxfordV2
{
public class Quote
{
public int? Year { get; set; }
public string? Text { get; set; }
public string? Title { get; set; }
public string? Author { get; set; }
public int Year { get; set; }
public string Text { get; set; }
public string Title { get; set; }
public string Author { get; set; }

}

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.
Binary file modified obj/Debug/net5.0/OxfordV2.csprojAssemblyReference.cache
Binary file not shown.
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 5c0cd54

Please sign in to comment.