Package gov.nysenate.openleg.util

Examples of gov.nysenate.openleg.util.TranscriptLine


        StringBuffer fullText = new StringBuffer();
        StringBuffer fullTextProcessed = new StringBuffer();

        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "latin1"));
        String lineText;
        TranscriptLine line;
        String date = null;
        String time = null;
        boolean firstPageParsed = false;
        boolean firstLineParsed = false;
        boolean skipFirstThreeLines = false;
        int numSkipped = 0;

        while ((lineText = reader.readLine()) != null) {
            line = new TranscriptLine(lineText);

            if (!firstPageParsed) {

                // Handle transcripts with 3 incorrect lines at start of transcript.
                if (!firstLineParsed) {
                    if (lineText.contains("SESSION")) {
                        skipFirstThreeLines = true;
                        numSkipped = 1;
                        continue;
                    }
                }
                if (skipFirstThreeLines == true && numSkipped <= 3) {
                    numSkipped++;
                    continue;
                }

                if (line.isLocation())
                    transcript.setLocation(line.removeLineNumber().trim());

                if (line.isDate())
                    date = line.getDateString();

                if (line.isTime())
                    time = line.getTimeString();

                if (line.isSession())
                    transcript.setType(line.removeLineNumber().trim());

                if (transcript.getLocation() != null && date != null && time != null && transcript.getType() != null)
                    firstPageParsed = true;
            }

            firstLineParsed = true;

            fullText.append(line.fullText()).append("\n");

            if (line.removeLineNumber().trim().length() > 0) {
                fullTextProcessed.append(line.removeLineNumber().trim()).append("\n");
            }
        }

        reader.close();
View Full Code Here


     */
    private TranscriptPage parseWithManualSpacing(List<String> pageLines) {
        TranscriptPage page = new TranscriptPage();
        int lineCount = 0;
        for (int i = 0; i < pageLines.size(); i++) {
            TranscriptLine line = new TranscriptLine(pageLines.get(i));

            if (line.isTranscriptNumber()) {
                page.setTranscriptNumber(line.removeInvalidCharacters());
                lineCount++;
            }
            else if (!line.isEmpty() && !line.isStenographer()) {
                page.addLine(line);
                lineCount++;

                if (line.fullText().trim().equals("NEW YORK STATE SENATE")) {
                    addBlankLines(page, 2);
                    lineCount += 2;
                }

                else if (line.fullText().trim().contains("STENOGRAPHIC RECORD")) {
                    addBlankLines(page, 2);
                    lineCount += 2;
                }

                else if (line.isTime()) {
                    addBlankLines(page, 2);
                    lineCount += 2;
                }

                else if (line.isSession()) {
                    addBlankLines(page, 3);
                    lineCount += 3;
                }
            }
        }
View Full Code Here

    private TranscriptPage parseWithOriginalSpacing(List<String> pageLines) {
        TranscriptPage page = new TranscriptPage();
        int lineCount = 0;

        for (String pageLine : pageLines) {
            TranscriptLine line = new TranscriptLine(pageLine);

            if (line.isTranscriptNumber()) {
                page.setTranscriptNumber(line.removeInvalidCharacters());
                lineCount++;
            }
            else if (!line.isEmpty() && !line.isStenographer()) {
                page.addLine(line);
                lineCount++;
            }
        }
View Full Code Here

    private void fixErrorsOnFirstPage(List<List<String>> pages) {
        List<String> correctedFirstPage = new ArrayList<String>();
        List<String> firstPage = pages.get(0);

        for (int i = 0; i < firstPage.size(); i++) {
            TranscriptLine line = new TranscriptLine(firstPage.get(i));

            if (!line.isEmpty()) {
                if (line.fullText().endsWith(",") || line.fullText().endsWith(", Acting")) {
                    // Combine two lines into one; corrects formatting. i.e. 123096.v1
                    TranscriptLine nextLine = getNextLine(firstPage, i);
                    if (nextLine.fullText().trim().equals("President") || nextLine.fullText().trim().equals("Acting President")) {
                        line = new TranscriptLine(line.fullText() + " " + nextLine.fullText().trim());
                        // Skip next line since we combined it with the previous line.
                        i++;
                    }
                }
View Full Code Here

        pages.set(pages.indexOf(firstPage), correctedFirstPage);
    }

    private void addBlankLines(TranscriptPage page, int numLines) {
        for (int i = 0; i < numLines; i++) {
            TranscriptLine blankLine = new TranscriptLine(" ");
            page.addLine(blankLine);
        }
    }
View Full Code Here

        }
    }

    private boolean pageHasLineNumbers(List<String> pageLines) {
        for (String pageLine : pageLines) {
            TranscriptLine line = new TranscriptLine(pageLine);
            if (!line.isEmpty() && !line.isTranscriptNumber()) {
                return line.hasLineNumber();
            }
        }
        return false;
    }
View Full Code Here

        return rawPages.indexOf(pageLines) == 0;
    }

    private TranscriptLine getNextLine(List<String> pageLines, int i) {
        if (i + 1 < pageLines.size()) {
            return new TranscriptLine(pageLines.get(i + 1));
        }
        return null;
    }
View Full Code Here

    private List<List<String>> splitPages(String transcriptText) {
        List<String> page = new ArrayList<String>();
        List<List<String>> pages = new ArrayList<List<String>>();

        String[] line = transcriptText.split("\n");
        TranscriptLine nextLine;
        for (int i = 0; i < line.length; i++) {
            page.add(line[i]);

            // Ignore the first transcript number.
            if (i > 10) {
                if (i + 1 < line.length) {
                    nextLine = new TranscriptLine(line[i + 1]);

                    if (nextLine.isTranscriptNumber()) {
                        pages.add(page);
                        page = new ArrayList<String>();
                    }
                }
            }
View Full Code Here

TOP

Related Classes of gov.nysenate.openleg.util.TranscriptLine

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.