public async Task <IndexedDocument> GetIndexedDocument(String fileName) { IndexedDocument result = null; if (indexedDocuments.ContainsKey(fileName)) { // If we already created it in the past, just return it. result = indexedDocuments[fileName]; } if (result == null) { string rawText = await GetFileContent(fileName); if (indexedDocuments.ContainsKey(fileName)) { result = indexedDocuments[fileName]; } if (result == null) { result = new IndexedDocument(fileName, rawText); indexedDocuments.Add(fileName, result); } } return(result); }
public async Task <int> AddLearnedAnnotations(string learnedAnnotations) { string annotationsString = learnedAnnotations; List <Annotation> dsallAnnotations = JsonConvert.DeserializeObject <List <Annotation> >(annotationsString); int i = 0; if (dsallAnnotations != null) { for (i = 0; i < dsallAnnotations.Count; i++) { // For some reason the iterator was not working well.. doing an old-fashioned for loop to debug. Annotation annotation = dsallAnnotations[i]; // get the file -- or create a new one if it already exists. IndexedDocument newDocument = await GetIndexedDocument(annotation.FileName); annotation.AnnotationName = "Learned Date"; if (!newDocument.Annotations.ContainsKey(annotation.StartOffset)) { newDocument.Annotations.Add(annotation.StartOffset, annotation); } } } return(i); }
private async void FileSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { string fileName = e.AddedItems[0].ToString(); currentDocument = await fileManager.GetIndexedDocument(fileName); UpdateDocumentView(); } }
public async void InitializeAnnotations() { string annotationsString = await GetFileContent("allAnnotations/allAnnotations.json"); List <Annotation> dsallAnnotations = JsonConvert.DeserializeObject <List <Annotation> >(annotationsString); if (dsallAnnotations != null) { foreach (Annotation annotation in dsallAnnotations) { // get the file -- or create a new one if it already exists. IndexedDocument newDocument = await GetIndexedDocument(annotation.FileName); newDocument.Annotations.Add(annotation.StartOffset, annotation); } } }