/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void SetupAnalysisWss() { IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; IWritingSystemManager wsManager = Cache.ServiceLocator.WritingSystemManager; //wsContainer.AnalysisWritingSystems.Clear(); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("en")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("fr")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("es")); wsContainer.CurrentAnalysisWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); if (m_dlg == null) { m_dlg = new DummyFwProjPropertiesDlg(Cache); } }
/// <summary> /// Initializes a new instance of the <see cref="StringSearcher<T>"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="wsManager">The writing system store.</param> public StringSearcher(SearchType type, IWritingSystemManager wsManager) { if (wsManager == null) { throw new ArgumentNullException("wsManager"); } m_type = type; m_sortKeySelector = (ws, text) => wsManager.Get(ws).Collator.GetSortKey(text).KeyData; m_tokenizer = (ws, text) => Icu.Split(Icu.UBreakIteratorType.UBRK_WORD, wsManager.Get(ws).IcuLocale, text); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void SetupVernWss() { IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; IWritingSystemManager wsManager = Cache.ServiceLocator.WritingSystemManager; //wsContainer.VernacularWritingSystems.Clear(); //wsContainer.CurrentVernacularWritingSystems.Clear(); // Setup so the CurVernWssRS returns the proper sequence. wsContainer.VernacularWritingSystems.Add(wsManager.Get("en")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("fr")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("es")); wsContainer.CurrentVernacularWritingSystems.Add(wsManager.Get("en")); if (m_dlg == null) { m_dlg = new DummyFwProjPropertiesDlg(Cache); } }
private void Add(int indexId, int wsId, string text, T item) { SortKeyIndex index = GetIndex(indexId, wsId); IWritingSystem ws = m_wsManager.Get(wsId); ICollator collator = ws.Collator; switch (m_type) { case SearchType.Exact: case SearchType.Prefix: index.Add(collator.GetSortKey(text).KeyData, item); break; case SearchType.FullText: foreach (string token in Icu.Split(Icu.UBreakIteratorType.UBRK_WORD, ws.IcuLocale, text)) { index.Add(collator.GetSortKey(token).KeyData, item); } break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Resolve a magic font name to the real font name for the given writing system. /// </summary> /// <param name="fontName"></param> /// <param name="ws"></param> /// <exception cref="InvalidOperationException">Thrown if StyleInfoTable was constructed /// with a null writing system factory</exception> /// ------------------------------------------------------------------------------------ internal string ResolveMagicFontName(string fontName, int ws) { if (m_wsManager == null) { throw new InvalidOperationException("StyleInfoTable was constructed with a null writing system store. Cannot resolve magic font name."); } IWritingSystem wsObj = m_wsManager.Get(ws); switch (fontName) { case StyleServices.DefaultFont: return(wsObj.DefaultFontName); default: Debug.Fail("ResolveMagicFontName called with unexpected (non-magic?) font name."); return(fontName); // This method probably shouldn't have been called, but oh well... } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Retrieve named checking parameter value. /// Checks use this to get their setup information. /// </summary> /// <param name="key">Parameter name</param> /// <returns>Parameter value</returns> /// ------------------------------------------------------------------------------------ public string GetParameterValue(string key) { IWritingSystemManager wsManager = m_cache.ServiceLocator.WritingSystemManager; int hvoWs = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle; IWritingSystem ws = wsManager.Get(hvoWs); if (key.Contains("ValidCharacters")) { return(GetValidCharactersList(key, ws)); } switch (key) { case "PoeticStyles": return(GetPoeticStyles()); case "Versification Scheme": return(m_scr.Versification.ToString()); case "IntroductionOutlineStyles": //REVIEW: Do we need this? return "Intro_List_Item1"; return(string.Empty); case "PunctCheckLevel": return("Intermediate"); case "PunctWhitespaceChar": return(m_punctWhitespaceChar.Substring(0, 1)); case "MatchedPairs": return(ws.MatchedPairs); case "PunctuationPatterns": return(ws.PunctuationPatterns); case "SentenceFinalPunctuation": return(GetSentenceFinalPunctuation(ws, m_cache.ServiceLocator.UnicodeCharProps)); case "QuotationMarkInfo": return(ws.QuotationMarks); case "StylesInfo": return((StyleInfo != null) ? StyleInfo.XmlString : null); case "DefaultWritingSystemName": return(ws.DisplayLabel); case "Verse Bridge": return(m_scr.BridgeForWs(hvoWs)); case "Script Digit Zero": return(m_scr.UseScriptDigits ? ((char)m_scr.ScriptDigitZero).ToString() : "0"); case "Sub-verse Letter A": return("a"); // TODO (TE-8593): Support sub-verse letters for non-Roman text case "Sub-verse Letter B": return("b"); // TODO (TE-8593): Support sub-verse letters for non-Roman text default: string value; return((m_checkingParameters.TryGetValue(key, out value)) ? value : string.Empty); } }
/// <summary> /// This method (as far as I know) will be first called on the StText object, and then recursively from the /// base implementation for vector items in component objects. /// </summary> /// <param name="tag"></param> /// <param name="vc"></param> /// <param name="frag"></param> public override void AddObjVecItems(int tag, IVwViewConstructor vc, int frag) { ICmObject text = null; switch (frag) { case InterlinVc.kfragInterlinPara: m_writer.WriteStartElement("interlinear-text"); //here the m_hvoCurr object is an StText object, store the IText owner //so that we can pull data from it to close out the interlinear-text element //Naylor 11-2011 text = m_repoObj.GetObject(m_hvoCurr).Owner; m_writer.WriteAttributeString("guid", text.Guid.ToString()); foreach (var mTssPendingTitle in pendingTitles) { var hystericalRaisens = mTssPendingTitle; WritePendingItem("title", ref hystericalRaisens); } foreach (var mTssPendingAbbrev in pendingAbbreviations) { var hystericalRaisens = mTssPendingAbbrev; WritePendingItem("title-abbreviation", ref hystericalRaisens); } foreach (var source in pendingSources) { var hystericalRaisens = source; WritePendingItem("source", ref hystericalRaisens); } foreach (var desc in pendingComments) { var hystericalRaisens = desc; WritePendingItem("comment", ref hystericalRaisens); } m_writer.WriteStartElement("paragraphs"); break; case InterlinVc.kfragParaSegment: m_writer.WriteStartElement("phrases"); break; case InterlinVc.kfragBundle: m_writer.WriteStartElement("words"); break; case InterlinVc.kfragMorphBundle: m_writer.WriteStartElement("morphemes"); break; default: break; } base.AddObjVecItems(tag, vc, frag); switch (frag) { case InterlinVc.kfragInterlinPara: m_writer.WriteEndElement(); // paragraphs m_writer.WriteStartElement("languages"); foreach (int wsActual in m_usedWritingSystems) { m_writer.WriteStartElement("language"); // we don't have enough context at this point to get all the possible writing system // information we may encounter in the word bundles. string icuCode = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual); m_writer.WriteAttributeString("lang", icuCode); IWritingSystem ws = m_wsManager.Get(wsActual); string fontName = ws.DefaultFontName; m_writer.WriteAttributeString("font", fontName); if (m_cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Contains(ws)) { m_writer.WriteAttributeString("vernacular", "true"); } if (ws.RightToLeftScript) { m_writer.WriteAttributeString("RightToLeft", "true"); } m_writer.WriteEndElement(); } m_writer.WriteEndElement(); // languages //Media files section if (text != null && text is FDO.IText && ((FDO.IText)text).MediaFilesOA != null) { FDO.IText theText = (FDO.IText)text; m_writer.WriteStartElement("media-files"); m_writer.WriteAttributeString("offset-type", theText.MediaFilesOA.OffsetType); foreach (var mediaFile in theText.MediaFilesOA.MediaURIsOC) { m_writer.WriteStartElement("media"); m_writer.WriteAttributeString("guid", mediaFile.Guid.ToString()); m_writer.WriteAttributeString("location", mediaFile.MediaURI); m_writer.WriteEndElement(); //media } m_writer.WriteEndElement(); //media-files } m_writer.WriteEndElement(); // interlinear-text //wipe out the pending items to be clean for next text. pendingTitles.Clear(); pendingSources.Clear(); pendingAbbreviations.Clear(); pendingComments.Clear(); break; case InterlinVc.kfragParaSegment: case InterlinVc.kfragBundle: case InterlinVc.kfragMorphBundle: m_writer.WriteEndElement(); break; default: break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets required and optional information that describes the files being submitted in /// the RAMP package. METS = Metadata Encoding & Transmission Standard /// (see http://www.loc.gov/METS/). /// </summary> /// <param name="model">Object provided by SIL.Archiving for setting application /// specific archiving information.</param> /// <param name="fieldWorksVersion">Fieldworks version to display.</param> /// <param name="cache"></param> /// <returns>A list of JSON encoded pairs that describe the information in the RAMP /// package.</returns> /// ------------------------------------------------------------------------------------ private void AddMetsPairs(RampArchivingDlgViewModel model, string fieldWorksVersion, FdoCache cache) { IWritingSystemManager wsManager = cache.ServiceLocator.GetInstance <IWritingSystemManager>(); var wsDefaultVern = wsManager.Get(cache.DefaultVernWs); var vernIso3Code = wsDefaultVern.GetIso3Code(); model.SetScholarlyWorkType(ScholarlyWorkType.PrimaryData); // use year range for CreationDate if possible GetCreateDateRange(cache); var yearStart = m_earliest.Year; var yearEnd = m_latest.Year; if (yearEnd > yearStart) { model.SetCreationDate(yearStart, yearEnd); } else { model.SetCreationDate(m_earliest); } model.SetModifiedDate(cache.LangProject.DateModified); if (!string.IsNullOrEmpty(vernIso3Code)) { model.SetSubjectLanguage(vernIso3Code, wsDefaultVern.LanguageName); } var contentLanguages = new List <ArchivingLanguage>(); var softwareRequirements = new HashSet <string>(); bool fWsUsesKeyman = false; softwareRequirements.Add(string.Format("FieldWorks Language Explorer, Version {0} or later", fieldWorksVersion)); foreach (var ws in cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Union( cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems).Union( cache.ServiceLocator.WritingSystems.CurrentPronunciationWritingSystems)) { var iso3Code = ws.GetIso3Code(); if (!string.IsNullOrEmpty(iso3Code)) { contentLanguages.Add(new ArchivingLanguage(iso3Code, ws.LanguageSubtag.Name)); } if (!string.IsNullOrEmpty(ws.DefaultFontName)) { softwareRequirements.Add(ws.DefaultFontName); } fWsUsesKeyman |= DoesWritingSystemUseKeyman(ws); } if (fWsUsesKeyman) { softwareRequirements.Add("Keyman"); } model.SetContentLanguages(contentLanguages); model.SetSoftwareRequirements(softwareRequirements); SilDomain domains = SilDomain.Linguistics; var cNotebookRecords = cache.LangProject.ResearchNotebookOA.AllRecords.Count(); if (cNotebookRecords > 0) { domains |= SilDomain.Anthropology; domains |= SilDomain.Anth_Ethnography; // Data notebook data is considered a (partial) ethnography. } var cLexicalEntries = cache.LangProject.LexDbOA.Entries.Count(); if (cLexicalEntries > 0) { domains |= SilDomain.Ling_Lexicon; } // Determine if there are any interlinearized texts if (cache.ServiceLocator.GetInstance <IWfiAnalysisRepository>().AllInstances().Any(a => a.OccurrencesInTexts.Any() && a.GetAgentOpinion(cache.LangProject.DefaultUserAgent) == Opinions.approves)) { domains |= SilDomain.Ling_InterlinearizedText; } var cTexts = cache.LangProject.Texts.Count(); if (cTexts > 0) { domains |= SilDomain.Ling_Text; } /* TODO: If files to include in archive includes a Lift file, set the correct schema */ //if (filesToArchive.Contains( FwFileExtensions.ksLexiconInterchangeFormat ) // model.SetSchemaConformance("LIFT"); /* TODO: If files to include in archive includes a grammar sketch, set the correct subdomain */ //if (filesToArchive.Contains(...) // domains |= SilDomain.Ling_GrammaticalDescription; model.SetDomains(domains); // get the information for DatasetExtent var datasetExtent = new StringBuilder(); const string delimiter = "; "; if (cNotebookRecords > 0) { datasetExtent.AppendLineFormat("{0} Notebook record{1}", new object[] { cNotebookRecords, (cNotebookRecords == 1) ? "" : "s" }, delimiter); } if (cLexicalEntries > 0) { datasetExtent.AppendLineFormat("{0} Lexical entr{1}", new object[] { cLexicalEntries, (cLexicalEntries == 1) ? "y" : "ies" }, delimiter); } if (cTexts > 0) { datasetExtent.AppendLineFormat("{0} Text{1}", new object[] { cTexts, (cTexts == 1) ? "" : "s" }, delimiter); } if (datasetExtent.Length > 0) { model.SetDatasetExtent(datasetExtent + "."); } }