Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1008491 // stanfordParseEnglish

JavaX fragment (include)

lib 1008485 // stanford parser
lib 1008486 // english model

import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.process.TokenizerFactory;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.process.CoreLabelTokenFactory;
import edu.stanford.nlp.process.PTBTokenizer;
import edu.stanford.nlp.process.Tokenizer;
import edu.stanford.nlp.trees.Tree;

static TokenizerFactory<CoreLabel> stanfordParseEnglish_tokenizerFactory;
static LexicalizedParser stanfordParseEnglish_parser;
sS stanfordParseEnglish_PCG_MODEL = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz";

static Tree stanfordParseEnglish(S s) {
  synchronized(stanfordParseEnglish_PCG_MODEL) {
    if (stanfordParseEnglish_tokenizerFactory == null) {
      stanfordParseEnglish_tokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "invertible=true");
      stanfordParseEnglish_parser = LexicalizedParser.loadModel(stanfordParseEnglish_PCG_MODEL);
    }
  }
  ret stanfordParseEnglish_parser.apply(
    stanfordParseEnglish_tokenizerFactory.getTokenizer(new StringReader(s)).tokenize());
}

Author comment

Began life as a copy of #1008487

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008491
Snippet name: stanfordParseEnglish
Eternal ID of this version: #1008491/5
Text MD5: 4c0292202db5f7681767bb8509a21671
Author: stefan
Category: javax / a.i. parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-19 14:10:29
Source code size: 1137 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 443 / 491
Version history: 4 change(s)
Referenced in: [show references]