Package edu.washington.cs.knowitall.nlp.extraction

Examples of edu.washington.cs.knowitall.nlp.extraction.ChunkedArgumentExtraction


                int label = Integer.parseInt(lines[9]);

                // Construct the extraction
                ChunkedExtraction rel = new ChunkedExtraction(sent, relRange);
                ChunkedArgumentExtraction arg1 = new ChunkedArgumentExtraction(
                        sent, arg1Range, rel);
                ChunkedArgumentExtraction arg2 = new ChunkedArgumentExtraction(
                        sent, arg2Range, rel);
                LabeledBinaryExtraction extr = new LabeledBinaryExtraction(rel,
                        arg1, arg2, label);

                return extr;
View Full Code Here


    public static VerbTokenFeature rightBeforeArg1(Collection<String> tokens) {
        return new VerbTokenFeature(tokens) {
            @Override
            protected Range rangeToExamine(ChunkedBinaryExtraction cbe) {
                ChunkedArgumentExtraction arg1 = cbe.getArgument1();
                int index = arg1.getStart() - 1;
                if (index < 0 || index > arg1.getSentence().getLength()) {
                    return Range.EMPTY;
                } else
                    return Range.fromInterval(index, index + 1);
            }
        };
View Full Code Here

    public static VerbTokenFeature rightAfterArg2(String... tokens) {
        return new VerbTokenFeature(tokens) {
            @Override
            protected Range rangeToExamine(ChunkedBinaryExtraction cbe) {
                ChunkedArgumentExtraction arg2 = cbe.getArgument2();
                int index = arg2.getStart() + arg2.getLength();
                if (index < 0 || index >= arg2.getSentence().getLength()) {
                    return Range.EMPTY;
                } else
                    return Range.fromInterval(index, index + 1);
            }
        };
View Full Code Here

    public static VerbTokenFeature anywhereBeforeArg1(Collection<String> tokens) {
        return new VerbTokenFeature(tokens) {
            @Override
            protected Range rangeToExamine(ChunkedBinaryExtraction cbe) {
                ChunkedArgumentExtraction arg1 = cbe.getArgument1();
                int index = arg1.getStart() - 1;
                if (index < 0 || index >= arg1.getSentence().getLength()) {
                    return Range.EMPTY;
                } else
                    return Range.fromInterval(0, index + 1);
            }
        };
View Full Code Here

    public static VerbTokenFeature anywhereAfterArg2(Collection<String> tokens) {
        return new VerbTokenFeature(tokens) {
            @Override
            protected Range rangeToExamine(ChunkedBinaryExtraction cbe) {
                ChunkedArgumentExtraction arg2 = cbe.getArgument2();
                int index = arg2.getStart() + arg2.getLength();
                if (index < 0 || index >= arg2.getSentence().getLength()) {
                    return Range.EMPTY;
                } else
                    return Range.fromInterval(index, cbe.getSentence()
                            .getLength());
            }
View Full Code Here

    @Override
    protected Iterable<ChunkedArgumentExtraction> extractCandidates(
            ChunkedExtraction predicate) throws ExtractorException {
        Collection<ChunkedArgumentExtraction> args = new ArrayList<ChunkedArgumentExtraction>();
        ChunkedArgumentExtraction arg = null;
        if (mode == Mode.LEFT) {
            arg = getArg1(predicate);
        } else {
            arg = getArg2(predicate);
        }
View Full Code Here

                        .getSentence().getLength() || (!arg.getSentence()
                        .getToken(i + 1).equals("and") && !arg.getSentence()
                        .getToken(i + 1).equals("or"))))
                        || arg.getSentence().getToken(i).equals("and")
                        || arg.getSentence().getToken(i).equals("or")) {
                    args.add(new ChunkedArgumentExtraction(arg.getSentence(),
                            new Range(start, length), arg.getRelation()));
                    start = i + 1;
                    length = 0;
                } else if (!arg.getSentence().getToken(i).equals(",")) {
                    length++;
                }
            }
            args.add(new ChunkedArgumentExtraction(arg.getSentence(),
                    new Range(start, length), arg.getRelation()));

        } else if (patternextractor.matchesAppositiveStrict(arg)) {
            int start = arg.getStart();
            int length = 0;
            for (int i = arg.getStart(); i < arg.getStart() + arg.getLength(); i++) {
                if (arg.getSentence().getToken(i).equals(",")) {
                    args.add(new ChunkedArgumentExtraction(arg.getSentence(),
                            new Range(start, length), arg.getRelation()));
                    start = i + 1;
                    length = 0;
                } else {
                    length++;
                }
            }
            args.add(new ChunkedArgumentExtraction(arg.getSentence(),
                    new Range(start, length), arg.getRelation()));

        } else {
            args.add(arg);
        }
View Full Code Here

        if (rightbound > 0) {
            double[] leftbound_conf = getArg1LeftBound(predicate, rightbound);
            int leftbound = (int) leftbound_conf[0];
            if (leftbound >= 0) {
                double conf = leftbound_conf[1];
                ChunkedArgumentExtraction arg1 = new ChunkedArgumentExtraction(
                        predicate.getSentence(), new Range(leftbound, rightbound
                                - leftbound), predicate, conf);
                return arg1;
            }
        }
View Full Code Here

        // create arg2
        Range newrange = new Range(leftbound, rightbound - leftbound);
        if (rightbound == 0) {
            return null;
        }
        ChunkedArgumentExtraction argument2 = new ChunkedArgumentExtraction(
                predicate.getSentence(), newrange, predicate, conf);

        // check final condition
        if (!argument2.getChunkTagsAsString().contains("NP")) {
            return null;
        }
        return argument2;
    }
View Full Code Here

     */
    public static PosFeature rightBeforeArg1(String... posTags) {
        return new PosFeature(posTags) {
            @Override
            protected Range rangeToExamine(ChunkedBinaryExtraction cbe) {
                ChunkedArgumentExtraction arg1 = cbe.getArgument1();
                int index = arg1.getStart() - 1;
                if (index < 0 || index >= arg1.getSentence().getLength()) {
                    return Range.EMPTY;
                } else
                    return Range.fromInterval(index, index + 1);
            }
        };
View Full Code Here

TOP

Related Classes of edu.washington.cs.knowitall.nlp.extraction.ChunkedArgumentExtraction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.