<commit_before>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.parser;

import junit.framework.TestCase;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * Test case for DOM parser.
 * 
 */
public class TextParserTest extends TestCase
{

	public void testParseHTMLstream( )
	{

		Document doc = new TextParser( ).parse( getClass( )
				.getResourceAsStream( "htmlparser_html.txt" ), "Auto" );
		Element root = (Element) doc.getFirstChild( );
		Node child = root.getFirstChild( );
		String res = "";
		for ( ; child.getNodeType( ) == Node.TEXT_NODE; child = child
				.getNextSibling( ) )
		{
			res += child.getNodeValue( );
		}

		assertEquals( "&first", res );
		assertEquals( "h6", child.getNodeName( ) );
		assertEquals( "h6-1", child.getFirstChild( ).getNodeValue( ) );
		child = child.getNextSibling( );
		assertEquals( "b", child.getNodeName( ) );
		assertEquals( "bold text", child.getFirstChild( ).getNodeValue( ) );

		res = "";<commit_msg>fix testcase failure<commit_after>/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.engine.parser;

import junit.framework.TestCase;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * Test case for DOM parser.
 * 
 * @version $Revision: 1.2 $ $Date: 2007/01/07 15:15:33 $
 */
public class TextParserTest extends TestCase
{

	public void testParseHTMLstream( )
	{

		Document doc = new TextParser( ).parse( getClass( )
				.getResourceAsStream( "htmlparser_html.txt" ), "Auto" );
		Element root = (Element) doc.getFirstChild( );
		Node child = root.getFirstChild( );
		assertTrue(child.getNodeName( ).equals( "script" ));
		child = child.getNextSibling( );
		String res = "";
		for ( ; child.getNodeType( ) == Node.TEXT_NODE; child = child
				.getNextSibling( ) )
		{
			res += child.getNodeValue( );
		}

		assertEquals( "&first", res );
		assertEquals( "h6", child.getNodeName( ) );
		assertEquals( "h6-1", child.getFirstChild( ).getNodeValue( ) );
		child = child.getNextSibling( );
		assertEquals( "b", child.getNodeName( ) );
		assertEquals( "bold text", child.getFirstChild( ).getNodeValue( ) );

		res = "";
{'fraction_non_alphanumeric': 0.22050959421201635, 'fraction_numerical': 0.01384083044982699, 'mean_word_length': 4.435897435897436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6083178', 'n_tokens_mistral': 996, 'n_tokens_neox': 918, 'n_words': 239}