/** * Recursive method to process a node in Arvores Deitadas format. * * @param node * the node to be processed * @param sentence * the sentence tokens we got so far * @param names * the names we got so far */ private void process(Node node, List<String> sentence, List<Span> names) { if (node != null) { for (TreeElement element : node.getElements()) { if (element.isLeaf()) { processLeaf((Leaf) element, sentence, names); } else { process((Node) element, sentence, names); } } } }
public NameSample read() throws IOException { Sentence paragraph; // we should look for text here. while ((paragraph = this.adSentenceStream.read()) != null) { int currentTextID = getTextID(paragraph); boolean clearData = false; if (currentTextID != textID) { clearData = true; textID = currentTextID; } Node root = paragraph.getRoot(); List<String> sentence = new ArrayList<>(); List<Span> names = new ArrayList<>(); process(root, sentence, names); return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), clearData); } return null; }
/** * Recursive method to process a node in Arvores Deitadas format. * * @param node * the node to be processed * @param sentence * the sentence tokens we got so far * @param names * the names we got so far */ private void process(Node node, List<String> sentence, List<Span> names) { if (node != null) { for (TreeElement element : node.getElements()) { if (element.isLeaf()) { processLeaf((Leaf) element, sentence, names); } else { process((Node) element, sentence, names); } } } }
public NameSample read() throws IOException { Sentence paragraph; // we should look for text here. while ((paragraph = this.adSentenceStream.read()) != null) { int currentTextID = getTextID(paragraph); boolean clearData = false; if (currentTextID != textID) { clearData = true; textID = currentTextID; } Node root = paragraph.getRoot(); List<String> sentence = new ArrayList<>(); List<Span> names = new ArrayList<>(); process(root, sentence, names); return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), clearData); } return null; }
/** * Recursive method to process a node in Arvores Deitadas format. * * @param node * the node to be processed * @param sentence * the sentence tokens we got so far * @param names * the names we got so far */ private void process(Node node, List<String> sentence, List<Span> names) { if (node != null) { for (TreeElement element : node.getElements()) { if (element.isLeaf()) { processLeaf((Leaf) element, sentence, names); } else { process((Node) element, sentence, names); } } } }
public NameSample read() throws IOException { Sentence paragraph; // we should look for text here. while ((paragraph = this.adSentenceStream.read()) != null) { int currentTextID = getTextID(paragraph); boolean clearData = false; if (currentTextID != textID) { clearData = true; textID = currentTextID; } Node root = paragraph.getRoot(); List<String> sentence = new ArrayList<>(); List<Span> names = new ArrayList<>(); process(root, sentence, names); return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), clearData); } return null; }