public ChunkedText Process(String sentence) { ChunkedText result = null; if (tokenizer == null) { InitializeTokenizer(); } if (tagger == null) { InitializePOSTagger(); } if (chunker == null) { InitializeChunker(); } if (tokenizer != null && tagger != null & chunker != null) { result = new ChunkedText(); result.Text = sentence; //.Replace("'s", ""); //To prevent the chunker categorizing 's as a term result.TokenArray = tokenizer.tokenize(result.Text); result.POSTagArray = tagger.tag(result.TokenArray); result.ChunkTagArray = chunker.chunk(result.TokenArray, result.POSTagArray); } return(result); }
public virtual string[] GetPOSTags(string[] words) { lock (this) { return(tagger.tag(words)); } }
public virtual string[] GetPOSTags(string[] words) { UninterruptableMonitor.Enter(this); try { return(tagger.tag(words)); } finally { UninterruptableMonitor.Exit(this); } }
public override RawCorefSample read() { RawCorefSample sample = samples.read(); if (sample != null) { IList <Parse> enhancedParses = new List <Parse>(); IList <string[]> sentences = sample.Texts; foreach (var sentence in sentences) { Parse p = FullParseCorefEnhancerStream.createIncompleteParse(sentence); p.Type = AbstractBottomUpParser.TOP_NODE; Parse[] parseTokens = p.Children; // construct incomplete parse here .. string[] tags = posTagger.tag(sentence); for (int i = 0; i < parseTokens.Length; i++) { p.insert(new Parse(p.Text, parseTokens[i].Span, tags[i], 1d, parseTokens[i].HeadIndex)); } // insert tags into incomplete parse Span[] chunks = chunker.chunkAsSpans(sentence, tags); foreach (Span chunk in chunks) { if ("NP".Equals(chunk.Type)) { p.insert(new Parse(p.Text, new Span(0, 0), chunk.Type, 1d, p.HeadIndex)); } } enhancedParses.Add(p); } sample.Parses = enhancedParses; return(sample); } else { return(null); } }