@Test public void testParser() throws IOException { assertEquals("(TOP " + "(NP,nomn,plur " + "(ADJF,nomn,plur женские) " + "(NOUN,inan,masc,nomn,plur сапоги)))", parser.parse("женские сапоги".split(" ")).toString()); assertEquals("(TOP " + "(NP,nomn,plur " + "(ADJF,nomn,plur женские) " + "(NOUN,inan,masc,nomn,plur сапоги) " + "(ADJF,Qual,nomn,plur коричневые)))", parser.parse("женские сапоги коричневые".split(" ")).toString()); assertEquals("(TOP " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NOUN,inan,neut,nomn,sing проектирование)) " + "(NP,gent,plur " + "(NOUN,femn,gent,inan,plur систем))) " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing полива))))", parser.parse("проектирование систем полива".split(" ")).toString()); assertEquals("(TOP " + "(NP " + "(NP,nomn,sing (NOUN,inan,masc,nomn,sing чехол)) " + "(PP " + "(PREP для) " + "(NP,gent,sing (NOUN,gent,inan,masc,sing телефона)))))", parser.parse(new String[]{"чехол", "для", "телефона"}).toString()); assertEquals("(TOP " + "(NP " + "(NP,nomn,sing " + "(NOUN,inan,masc,nomn,sing чехол)) " + "(PP " + "(PREP для) " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing телефона) " + "(LATN iphone)))))", parser.parse(new String[]{"чехол", "для", "телефона", "iphone"}).toString()); assertEquals("(TOP " + "(NP " + "(NP,nomn,sing (NOUN,inan,masc,nomn,sing чехол)) " + "(PP " + "(PREP для) " + "(NP,nomn,sing " + "(LATN iphone) " + "(NUMB,intg 5)))))", parser.parse(new String[]{"чехол", "для", "iphone", "5"}).toString()); assertEquals("(TOP " + "(NP,nomn,sing " + "(LATN iphone) " + "(NUMB,intg 5)))", parser.parse(new String[]{"iphone", "5"}).toString()); assertEquals("(TOP " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NOUN,femn,inan,nomn,sing уборка)) " + "(CONJ и) " + "(NP,nomn,sing " + "(NOUN,inan,masc,nomn,sing вывоз))) " + "(NP,gent,sing " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing снега)) " + "(CONJ и) " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing льда)))))", parser.parse(new String[]{"уборка", "и", "вывоз", "снега", "и", "льда"}).toString()); assertEquals("(TOP " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NOUN,femn,inan,nomn,sing уборка)) " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing снега))) " + "(CONJ и) " + "(NP,nomn,sing " + "(NP,nomn,sing " + "(NOUN,inan,masc,nomn,sing вывоз)) " + "(NP,gent,sing " + "(NOUN,gent,inan,masc,sing льда)))))", parser.parse(new String[]{"уборка", "снега", "и", "вывоз", "льда"}).toString()); }
public Node.Top parse(List<Node.Top> sentences) { List<Node.Top> tops = parseAll(sentences); if (tops.isEmpty()) { return new Node.Top(ImmutableList.of(), 0.0f); } return tops.get(0); }
SimpleParser extends Parser { public Node.Top parse(List<Node.Top> sentences) { List<Node.Top> tops = parseAll(sentences); if (tops.isEmpty()) { return new Node.Top(ImmutableList.of(), 0.0f); } return tops.get(0); } }
SimpleParser extends Parser { public Node.Top parse(List<Node.Top> sentences) { List<Node.Top> tops = parseAll(sentences); if (tops.isEmpty()) { return new Node.Top(ImmutableList.of(), 0.0f); } return tops.get(0); } SimpleParser(MorphAnalyzer morph, Tagger tagger);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules);  SimpleParser(MorphAnalyzer morph, Tagger tagger, int threshold);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules, int threshold); }
SimpleParser extends Parser { public Node.Top parse(List<Node.Top> sentences) { List<Node.Top> tops = parseAll(sentences); if (tops.isEmpty()) { return new Node.Top(ImmutableList.of(), 0.0f); } return tops.get(0); } SimpleParser(MorphAnalyzer morph, Tagger tagger);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules);  SimpleParser(MorphAnalyzer morph, Tagger tagger, int threshold);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules, int threshold); Node.Top parse(List<Node.Top> sentences); List<Node.Top> parseAll(List<Node.Top> sentences); }
SimpleParser extends Parser { public Node.Top parse(List<Node.Top> sentences) { List<Node.Top> tops = parseAll(sentences); if (tops.isEmpty()) { return new Node.Top(ImmutableList.of(), 0.0f); } return tops.get(0); } SimpleParser(MorphAnalyzer morph, Tagger tagger);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules);  SimpleParser(MorphAnalyzer morph, Tagger tagger, int threshold);  SimpleParser(MorphAnalyzer morph, Tagger tagger, Ruleset rules, int threshold); Node.Top parse(List<Node.Top> sentences); List<Node.Top> parseAll(List<Node.Top> sentences); static final int DEFAULT_THRESHOLD; }