public ActionResult Serializations() { Random r = new Random(DateTime.Now.Millisecond); string[] samples = new string[] { CorpusTexts.UnpaText, CorpusTexts.Gilgamesh, CorpusTexts.SampleText1, CorpusTexts.SampleText3, CorpusTexts.Lao, CorpusTexts.GeorgeSong, CorpusTexts.CrazyAnimal, CorpusTexts.CrazyAnimal2 , CorpusTexts.JanSin , CorpusTexts.RuneDanceSong , CorpusTexts.janPusaRice , CorpusTexts.janPend }; SerializationsModel sm = new SerializationsModel() { SourceText = samples[r.Next(samples.Length)] }; ProcessSerializationsModel(sm); return(View(sm)); }
private static void ProcessSerializationsModel(SerializationsModel parse) { Dialect dialect = Dialect.LooseyGoosey; ParserUtils pu = new ParserUtils(dialect); Normalizer norm = new Normalizer(dialect); SentenceSplitter ss = new SentenceSplitter(dialect); string[] sentences = ss.ParseIntoNonNormalizedSentences(parse.SourceText); StringBuilder errors = new StringBuilder(); List <Sentence> parseSentences = new List <Sentence>(); int i = 0; foreach (string sentence in sentences) { i++; if (i >= 3) { continue; } string normalized; try { normalized = norm.NormalizeText(sentence); } catch (Exception ex) { normalized = "[[CANNOT NORMALIZE: " + ex.Message + " for " + sentence + "]]"; errors.AppendLine(normalized + "<br/>"); continue; } Sentence parsedSentence; try { parsedSentence = pu.ParsedSentenceFactory(normalized, sentence); parseSentences.Add(parsedSentence); } catch (Exception ex) { string cantParse = "[[CANNOT PARSE: " + ex.Message.ToHtml() + " for " + sentence.ToHtml() + "]]"; errors.AppendLine(cantParse.ToHtml() + "<br/>"); } finally { dialect.TargetGloss = "tp"; } } parse.Json = parseSentences.ToJsonNet(); parse.Xml = FormatXml(parseSentences.ToDataContractXml()); parse.Html = "Not implemented yet"; }