private static void SortLift(string outputPath, LexEntryRepository lexEntryRepository, ViewTemplate template) { using (var exporter = new LiftWriter(outputPath, LiftWriter.ByteOrderStyle.NoBOM)) { IWritingSystemDefinition firstWs = template.HeadwordWritingSystems[0]; ResultSet <LexEntry> recordTokens = lexEntryRepository.GetAllEntriesSortedByHeadword(firstWs); int index = 0; foreach (RecordToken <LexEntry> token in recordTokens) { int homographNumber = 0; if ((bool)token["HasHomograph"]) { homographNumber = (int)token["HomographNumber"]; } LexEntry lexEntry = token.RealObject; EmbeddedXmlCollection sortedAnnotation = new EmbeddedXmlCollection(); sortedAnnotation.Values.Add("<annotation name='sorted-index' value='" + (++index) + "'/>"); lexEntry.Properties.Add(new KeyValuePair <string, IPalasoDataObjectProperty>("SortedIndex", sortedAnnotation)); exporter.Add(lexEntry, homographNumber); } exporter.End(); } }
public void Subsense() { LexEntry e = MakeSimpleEntry(); string xml = @" <entry id='flob'> <sense id='opon_1' order='1'> <subsense id='opon_1a' order='1'> <grammatical-info value='n'/> <gloss lang='en'> <text>grand kin</text> </gloss> <definition> <form lang='en'> <text> grandparent, grandchild; reciprocal term of plus or minus two generations </text> </form> </definition> </subsense> <subsense id='opon_1b' order='2'> <grammatical-info value='n'/> <gloss lang='en'> <text>ancestor</text> </gloss> </subsense> </sense> </entry>" ; LexSense sense = new LexSense(); e.Senses.Add(sense); _builder.GetOrMakeSubsense(sense, new Extensible(), xml); _builder.FinishEntry(e); _liftWriter.Add(e); _liftWriter.End(); AssertHasAtLeastOneMatch("//entry/sense/subsense[@id='opon_1b' and @order='2']/gloss"); AssertHasAtLeastOneMatch("//entry/sense/subsense/grammatical-info"); }