コード例 #1
0
        private static HashSet <IFsSymFeatVal> GetImpliedPhonologicalFeatures(IPhNCSegments nc)
        {
            HashSet <IFsSymFeatVal> results = null;

            foreach (IPhPhoneme phoneme in nc.SegmentsRC.Where(p => p.FeaturesOA != null && !p.FeaturesOA.IsEmpty))
            {
                IEnumerable <IFsSymFeatVal> values = GetFeatures(phoneme);
                if (results == null)
                {
                    results = new HashSet <IFsSymFeatVal>(values);
                }
                else
                {
                    results.IntersectWith(values);
                }
            }
            return(results ?? new HashSet <IFsSymFeatVal>());
        }
コード例 #2
0
		private static IEnumerable<XElement> ExportNaturalClassContents(IPhNCSegments naturalClass)
		{
			return from segment in naturalClass.SegmentsRC
				   select ExportItemAsReference(segment, "Segments");
		}
コード例 #3
0
        private void ConvertNaturalClasses(string sTestName, XmlDocument doc, bool fTesting)
        {
            StringBuilder sbXPath = new StringBuilder();

            sbXPath.Append("//failure[contains(@test,'");
            sbXPath.Append(sTestName);
            sbXPath.Append("') and contains(@test,'[')]");
            XmlNodeList nl = doc.SelectNodes(sbXPath.ToString());

            if (nl != null)
            {
                m_iTestingCount = 0;

                foreach (XmlNode node in nl)
                {
                    XmlNode       test     = node.Attributes.GetNamedItem("test");
                    string        s        = test.InnerText;
                    int           i        = test.InnerText.IndexOf('/');
                    string        s0       = s.Substring(i);
                    char[]        brackets = { '[', ']' };
                    string[]      sa       = s0.Split(brackets);    // split into hunks using brackets
                    StringBuilder sb       = new StringBuilder();
                    foreach (string str in sa)                      // for each hunk
                    {
                        if (str.IndexOfAny(m_digits) >= 0)
                        {                          // assume it is an hvo
                            sb.Append("[");
                            if (fTesting)
                            {
                                if (m_iTestingCount > 5)
                                {
                                    m_iTestingCount = 0;
                                }
                                sb.Append(m_saTesting[m_iTestingCount++]);
                            }
                            else
                            {
                                string        sHvo = str;
                                int           hvo  = Convert.ToInt32(sHvo);
                                ICmObject     obj  = CmObject.CreateFromDBObject(m_cache, hvo);
                                IPhNCSegments nc   = obj as IPhNCSegments;
                                string        sName;
                                if (nc != null)
                                {
                                    sName = nc.Name.BestAnalysisAlternative.Text;
                                }
                                else
                                {
                                    sName = ParserUIStrings.ksUnknownNaturalClass;                                     // in case the user continues...
                                    throw new ApplicationException(sName);
                                }
                                sb.Append(sName);
                            }
                            sb.Append("]");
                        }
                        else
                        {
                            sb.Append(str);
                        }
                    }
                    test.InnerText = s.Substring(0, i) + sb.ToString();
                }
            }
        }
コード例 #4
0
ファイル: HCParser.cs プロジェクト: sillsdev/FieldWorks
		private static HashSet<IFsSymFeatVal> GetImpliedPhonologicalFeatures(IPhNCSegments nc)
		{
			HashSet<IFsSymFeatVal> results = null;
			foreach (IPhPhoneme phoneme in nc.SegmentsRC.Where(p => p.FeaturesOA != null && !p.FeaturesOA.IsEmpty))
			{
				IEnumerable<IFsSymFeatVal> values = GetFeatures(phoneme);
				if (results == null)
					results = new HashSet<IFsSymFeatVal>(values);
				else
					results.IntersectWith(values);
			}
			return results ?? new HashSet<IFsSymFeatVal>();
		}