diff --git a/build.sh b/build.sh index 301135706f3a6999cd5cbbd955521735a76bb20a..fe85c1ddfc7b986f4c3361ca3d0e5475a3585d58 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,6 @@ TOMCAT_WEBAPPS="vm/webapps" # enable/disable (1/0) project building BUILD_DTM=1 -BUILD_JGIBBLDA=1 BUILD_VIPRA_UTIL=1 BUILD_VIPRA_CMD=1 BUILD_VIPRA_UI=1 @@ -27,7 +26,7 @@ if [ $BUILD_DTM -eq 1 ]; then echo using $MAKE | tee $LOG fi -if [ $BUILD_JGIBBLDA -eq 1 ] || [ $BUILD_VIPRA_UTIL -eq 1 ] || [ $BUILD_VIPRA_CMD -eq 1 ] || [ $BUILD_VIPRA_BACKEND -eq 1 ]; then +if [ $BUILD_VIPRA_UTIL -eq 1 ] || [ $BUILD_VIPRA_CMD -eq 1 ] || [ $BUILD_VIPRA_BACKEND -eq 1 ]; then JAVA=$(command -v java 2>/dev/null) || { echo >&2 "java not found"; exit 1; } echo using $JAVA | tee $LOG @@ -67,22 +66,6 @@ else cd ../.. fi -# build jgibblda - -echo "" >> $LOG -echo "-------------------------------" >> $LOG -if [ $BUILD_JGIBBLDA -ne 1 ]; then - echo "compiling jgibblda > skipped" | tee -a $LOG -else - echo "compiling jgibblda" | tee -a $LOG - echo "-------------------------------" >> $LOG - $MVN -f ./jgibblda/pom.xml install >> $LOG 2>&1 - if [ $? -ne 0 ]; then - echo "error" - exit 1 - fi -fi - # build vipra-util echo "" >> $LOG diff --git a/jgibblda/.classpath b/jgibblda/.classpath deleted file mode 100644 index cf6dc8577b7a1ef815c8060b30722361a43c9e05..0000000000000000000000000000000000000000 --- a/jgibblda/.classpath +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="org.eclipse.jst.component.nondependency" value=""/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> - <attributes> - <attribute name="owner.project.facets" value="java"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/jgibblda/.gitignore b/jgibblda/.gitignore deleted file mode 100644 index 09e3bc9b241c477ea341af9ee029becad0c2148c..0000000000000000000000000000000000000000 --- a/jgibblda/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin/ -/target/ diff --git a/jgibblda/.project b/jgibblda/.project deleted file mode 100644 index 2f6739e94a4f8a44417d3b5e9e2bf9db4a44913f..0000000000000000000000000000000000000000 --- a/jgibblda/.project +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>JGibbLDA</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.wst.common.project.facet.core.builder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.wst.validation.validationbuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.m2e.core.maven2Builder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>net.sourceforge.metrics.builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> - <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> - <nature>org.eclipse.m2e.core.maven2Nature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>org.eclipse.wst.common.project.facet.core.nature</nature> - <nature>net.sourceforge.metrics.nature</nature> - </natures> -</projectDescription> diff --git a/jgibblda/.settings/org.eclipse.core.resources.prefs b/jgibblda/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index e9441bb123ec3e1ab029c7eac896bc45681d9a71..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding/<project>=UTF-8 diff --git a/jgibblda/.settings/org.eclipse.jdt.core.prefs b/jgibblda/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index bf52a73f0cb4d7fde47825bf5e19ce3b293969af..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,298 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=48 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=48 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=120 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/jgibblda/.settings/org.eclipse.jdt.ui.prefs b/jgibblda/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index bab1260352fa628f34603b44ab35e272a059e4b0..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=false -cleanup.convert_to_enhanced_for_loop=true -cleanup.correct_indentation=true -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=true -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=true -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=true -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=true -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=false -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup.use_type_arguments=false -cleanup_profile=_vipra -cleanup_settings_version=2 -eclipse.preferences.version=1 -formatter_profile=_vipra -formatter_settings_version=12 diff --git a/jgibblda/.settings/org.eclipse.m2e.core.prefs b/jgibblda/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb2389f85fe6381425d29f0a9866fb65..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/jgibblda/.settings/org.eclipse.wst.common.component b/jgibblda/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 245b97a8e36eb01568610dd2812fad4883b3bfaa..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> - <wb-module deploy-name="JGibbLDA"> - <wb-resource deploy-path="/" source-path="/src/main/java"/> - </wb-module> -</project-modules> diff --git a/jgibblda/.settings/org.eclipse.wst.common.project.facet.core.xml b/jgibblda/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index fd0227a68279180b3dd187cfc58335b8a0914833..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<faceted-project> - <fixed facet="java"/> - <fixed facet="jst.utility"/> - <installed facet="jst.utility" version="1.0"/> - <installed facet="java" version="1.8"/> -</faceted-project> diff --git a/jgibblda/.settings/org.eclipse.wst.validation.prefs b/jgibblda/.settings/org.eclipse.wst.validation.prefs deleted file mode 100644 index 04cad8cb752a9761c4e5167d0301d3a27674430f..0000000000000000000000000000000000000000 --- a/jgibblda/.settings/org.eclipse.wst.validation.prefs +++ /dev/null @@ -1,2 +0,0 @@ -disabled=06target -eclipse.preferences.version=1 diff --git a/jgibblda/pom.xml b/jgibblda/pom.xml deleted file mode 100644 index 6abee2d33e9a846fb25a36a86f97ca64fd63c9d8..0000000000000000000000000000000000000000 --- a/jgibblda/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>jgibblda</groupId> - <artifactId>jgibblda</artifactId> - <version>0.0.1-SNAPSHOT</version> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - <log4jVersion>2.4.1</log4jVersion> - </properties> - - <dependencies> - <dependency> - <groupId>args4j</groupId> - <artifactId>args4j</artifactId> - <version>2.32</version> - </dependency> - - <!-- Logging --> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <version>${log4jVersion}</version> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>${log4jVersion}</version> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <version>${log4jVersion}</version> - </dependency> - </dependencies> -</project> \ No newline at end of file diff --git a/jgibblda/src/main/java/META-INF/MANIFEST.MF b/jgibblda/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 5e9495128c0376427420c4189993b3851770b702..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/jgibblda/src/main/java/jgibblda/Constants.java b/jgibblda/src/main/java/jgibblda/Constants.java deleted file mode 100644 index 65fff358f800501ba6760de427e491b0c24f97cc..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Constants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -public class Constants { - public static final long BUFFER_SIZE_LONG = 1000000; - public static final short BUFFER_SIZE_SHORT = 512; - - public static final int MODEL_STATUS_UNKNOWN = 0; - public static final int MODEL_STATUS_EST = 1; - public static final int MODEL_STATUS_ESTC = 2; - public static final int MODEL_STATUS_INF = 3; -} diff --git a/jgibblda/src/main/java/jgibblda/Conversion.java b/jgibblda/src/main/java/jgibblda/Conversion.java deleted file mode 100644 index ed310f99ed9592acbe8ce8c948d7b2f8a1ace974..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Conversion.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -public class Conversion { - public static String ZeroPad(final int number, final int width) { - final StringBuffer result = new StringBuffer(""); - for (int i = 0; i < width - Integer.toString(number).length(); i++) - result.append("0"); - result.append(Integer.toString(number)); - - return result.toString(); - } -} diff --git a/jgibblda/src/main/java/jgibblda/Dictionary.java b/jgibblda/src/main/java/jgibblda/Dictionary.java deleted file mode 100644 index 335565dd190be4e05eefa2fac10a2df77ab03c54..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Dictionary.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ -package jgibblda; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.StringTokenizer; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Dictionary { - - public static final Logger log = LoggerFactory.getLogger(Dictionary.class); - - public Map<String, Integer> word2id; - public Map<Integer, String> id2word; - - // -------------------------------------------------- - // constructors - // -------------------------------------------------- - - public Dictionary() { - word2id = new HashMap<String, Integer>(); - id2word = new HashMap<Integer, String>(); - } - - // --------------------------------------------------- - // get/set methods - // --------------------------------------------------- - - public String getWord(final int id) { - return id2word.get(id); - } - - public Integer getID(final String word) { - return word2id.get(word); - } - - // ---------------------------------------------------- - // checking methods - // ---------------------------------------------------- - /** - * check if this dictionary contains a specified word - */ - public boolean contains(final String word) { - return word2id.containsKey(word); - } - - public boolean contains(final int id) { - return id2word.containsKey(id); - } - - // --------------------------------------------------- - // manupulating methods - // --------------------------------------------------- - /** - * add a word into this dictionary return the corresponding id - */ - public int addWord(final String word) { - if (!contains(word)) { - final int id = word2id.size(); - - word2id.put(word, id); - id2word.put(id, word); - - return id; - } else - return getID(word); - } - - // --------------------------------------------------- - // I/O methods - // --------------------------------------------------- - /** - * read dictionary from file - */ - public boolean readWordMap(final String wordMapFile) { - try { - final BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(wordMapFile), "UTF-8")); - String line; - - // read the number of words - line = reader.readLine(); - final int nwords = Integer.parseInt(line); - - // read map - for (int i = 0; i < nwords; ++i) { - line = reader.readLine(); - final StringTokenizer tknr = new StringTokenizer(line, " \t\n\r"); - - if (tknr.countTokens() != 2) - continue; - - final String word = tknr.nextToken(); - final String id = tknr.nextToken(); - final int intID = Integer.parseInt(id); - - id2word.put(intID, word); - word2id.put(word, intID); - } - - reader.close(); - return true; - } catch (final Exception e) { - log.error("Error while reading dictionary:" + e.getMessage()); - e.printStackTrace(); - return false; - } - } - - public boolean writeWordMap(final String wordMapFile) { - try { - final BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(wordMapFile), "UTF-8")); - - // write number of words - writer.write(word2id.size() + "\n"); - - // write word to id - final Iterator<String> it = word2id.keySet().iterator(); - while (it.hasNext()) { - final String key = it.next(); - final Integer value = word2id.get(key); - - writer.write(key + " " + value + "\n"); - } - - writer.close(); - return true; - } catch (final Exception e) { - log.error("Error while writing word map " + e.getMessage()); - e.printStackTrace(); - return false; - } - - } -} diff --git a/jgibblda/src/main/java/jgibblda/Document.java b/jgibblda/src/main/java/jgibblda/Document.java deleted file mode 100644 index cb87aed08e12bddd5ea1223c378b55bd44bc96da..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Document.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import java.util.Vector; - -public class Document { - - // ---------------------------------------------------- - // Instance Variables - // ---------------------------------------------------- - public int[] words; - public String rawStr; - public int length; - - // ---------------------------------------------------- - // Constructors - // ---------------------------------------------------- - public Document() { - words = null; - rawStr = ""; - length = 0; - } - - public Document(final int length) { - this.length = length; - rawStr = ""; - words = new int[length]; - } - - public Document(final int length, final int[] words) { - this.length = length; - rawStr = ""; - - this.words = new int[length]; - for (int i = 0; i < length; ++i) { - this.words[i] = words[i]; - } - } - - public Document(final int length, final int[] words, final String rawStr) { - this.length = length; - this.rawStr = rawStr; - - this.words = new int[length]; - for (int i = 0; i < length; ++i) { - this.words[i] = words[i]; - } - } - - public Document(final Vector<Integer> doc) { - this.length = doc.size(); - rawStr = ""; - this.words = new int[length]; - for (int i = 0; i < length; i++) { - this.words[i] = doc.get(i); - } - } - - public Document(final Vector<Integer> doc, final String rawStr) { - this.length = doc.size(); - this.rawStr = rawStr; - this.words = new int[length]; - for (int i = 0; i < length; ++i) { - this.words[i] = doc.get(i); - } - } -} diff --git a/jgibblda/src/main/java/jgibblda/Estimator.java b/jgibblda/src/main/java/jgibblda/Estimator.java deleted file mode 100644 index 8968c09784eae25d47f73b7f34973c7e4274fda1..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Estimator.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import java.io.File; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Estimator { - - public static final Logger log = LoggerFactory.getLogger(Estimator.class); - - // output model - protected Model trnModel; - LDACmdOption option; - - public boolean init(final LDACmdOption option) { - this.option = option; - trnModel = new Model(); - - if (option.est) { - if (!trnModel.initNewModel(option)) - return false; - trnModel.data.localDict.writeWordMap(option.dir + File.separator + option.wordMapFileName); - } else if (option.estc) { - if (!trnModel.initEstimatedModel(option)) - return false; - } - - return true; - } - - public void estimate() { - log.info("sampling " + trnModel.niters + " iterations"); - - final int lastIter = trnModel.liter; - for (trnModel.liter = lastIter + 1; trnModel.liter < trnModel.niters + lastIter; trnModel.liter++) { - log.info("iteration " + trnModel.liter); - - // for all z_i - for (int m = 0; m < trnModel.M; m++) { - for (int n = 0; n < trnModel.data.docs[m].length; n++) { - // z_i = z[m][n] - // sample from p(z_i|z_-i, w) - final int topic = sampling(m, n); - trnModel.z[m].set(n, topic); - } // end for each word - } // end for each document - - if (option.savestep > 0) { - if (trnModel.liter % option.savestep == 0) { - log.info("iteration checkpoint: " + trnModel.liter); - computeTheta(); - computePhi(); - trnModel.saveModel(option.modelName + "-" + Conversion.ZeroPad(trnModel.liter, 5)); - } - } - } // end iterations - - log.info("sampling completed, saving final model"); - computeTheta(); - computePhi(); - trnModel.liter--; - trnModel.saveModel(option.modelName); - } - - /** - * Do sampling - * - * @param m - * document number - * @param n - * word number - * @return topic id - */ - public int sampling(final int m, final int n) { - // remove z_i from the count variable - int topic = trnModel.z[m].get(n); - final int w = trnModel.data.docs[m].words[n]; - - trnModel.nw[w][topic] -= 1; - trnModel.nd[m][topic] -= 1; - trnModel.nwsum[topic] -= 1; - trnModel.ndsum[m] -= 1; - - final double Vbeta = trnModel.V * trnModel.beta; - final double Kalpha = trnModel.K * trnModel.alpha; - - // do multinominal sampling via cumulative method - for (int k = 0; k < trnModel.K; k++) { - trnModel.p[k] = (trnModel.nw[w][k] + trnModel.beta) / (trnModel.nwsum[k] + Vbeta) - * (trnModel.nd[m][k] + trnModel.alpha) / (trnModel.ndsum[m] + Kalpha); - } - - // cumulate multinomial parameters - for (int k = 1; k < trnModel.K; k++) { - trnModel.p[k] += trnModel.p[k - 1]; - } - - // scaled sample because of unnormalized p[] - final double u = Math.random() * trnModel.p[trnModel.K - 1]; - - for (topic = 0; topic < trnModel.K; topic++) { - if (trnModel.p[topic] > u) // sample topic w.r.t distribution p - break; - } - - // add newly estimated z_i to count variables - trnModel.nw[w][topic] += 1; - trnModel.nd[m][topic] += 1; - trnModel.nwsum[topic] += 1; - trnModel.ndsum[m] += 1; - - return topic; - } - - public void computeTheta() { - for (int m = 0; m < trnModel.M; m++) { - for (int k = 0; k < trnModel.K; k++) { - trnModel.theta[m][k] = (trnModel.nd[m][k] + trnModel.alpha) - / (trnModel.ndsum[m] + trnModel.K * trnModel.alpha); - } - } - } - - public void computePhi() { - for (int k = 0; k < trnModel.K; k++) { - for (int w = 0; w < trnModel.V; w++) { - trnModel.phi[k][w] = (trnModel.nw[w][k] + trnModel.beta) - / (trnModel.nwsum[k] + trnModel.V * trnModel.beta); - } - } - } -} diff --git a/jgibblda/src/main/java/jgibblda/Inferencer.java b/jgibblda/src/main/java/jgibblda/Inferencer.java deleted file mode 100644 index 5108749dbb20812e8b3137285033ac0de1e16468..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Inferencer.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Inferencer { - - public static final Logger log = LoggerFactory.getLogger(Inferencer.class); - - // Train model - public Model trnModel; - public Dictionary globalDict; - private LDACmdOption option; - - private Model newModel; - public int niters = 100; - - // ----------------------------------------------------- - // Init method - // ----------------------------------------------------- - public boolean init(final LDACmdOption option) { - this.option = option; - trnModel = new Model(); - - if (!trnModel.initEstimatedModel(option)) - return false; - - globalDict = trnModel.data.localDict; - computeTrnTheta(); - computeTrnPhi(); - - return true; - } - - // inference new model ~ getting data from a specified dataset - public Model inference(final LDADataset newData) { - final Model newModel = new Model(); - - newModel.initNewModel(option, newData, trnModel); - this.newModel = newModel; - - log.info("sampling " + niters + " iterations"); - for (newModel.liter = 1; newModel.liter <= niters; newModel.liter++) { - - // for all newz_i - for (int m = 0; m < newModel.M; ++m) { - for (int n = 0; n < newModel.data.docs[m].length; n++) { - // (newz_i = newz[m][n] - // sample from p(z_i|z_-1,w) - final int topic = infSampling(m, n); - newModel.z[m].set(n, topic); - } - } // end foreach new doc - - } // end iterations - - log.info("sampling completed"); - - computeNewTheta(); - computeNewPhi(); - newModel.liter--; - return this.newModel; - } - - public Model inference(final String[] strs) { - final LDADataset dataset = LDADataset.readDataSet(strs, globalDict); - return inference(dataset); - } - - // inference new model ~ getting dataset from file specified in option - public Model inference() { - - newModel = new Model(); - if (!newModel.initNewModel(option, trnModel)) - return null; - - log.info("sampling " + niters + " iterations"); - - for (newModel.liter = 1; newModel.liter <= niters; newModel.liter++) { - - // for all newz_i - for (int m = 0; m < newModel.M; ++m) { - for (int n = 0; n < newModel.data.docs[m].length; n++) { - // (newz_i = newz[m][n] - // sample from p(z_i|z_-1,w) - final int topic = infSampling(m, n); - newModel.z[m].set(n, topic); - } - } // end foreach new doc - - } // end iterations - - log.info("sampling completed, saving final model"); - - computeNewTheta(); - computeNewPhi(); - newModel.liter--; - newModel.saveModel(newModel.dfile + "." + newModel.modelName); - - return newModel; - } - - /** - * do sampling for inference m: document number n: word number? - */ - protected int infSampling(final int m, final int n) { - // remove z_i from the count variables - int topic = newModel.z[m].get(n); - final int _w = newModel.data.docs[m].words[n]; - final int w = newModel.data.lid2gid.get(_w); - newModel.nw[_w][topic] -= 1; - newModel.nd[m][topic] -= 1; - newModel.nwsum[topic] -= 1; - newModel.ndsum[m] -= 1; - - final double Vbeta = trnModel.V * newModel.beta; - final double Kalpha = trnModel.K * newModel.alpha; - - // do multinomial sampling via cummulative method - for (int k = 0; k < newModel.K; k++) { - newModel.p[k] = (trnModel.nw[w][k] + newModel.nw[_w][k] + newModel.beta) - / (trnModel.nwsum[k] + newModel.nwsum[k] + Vbeta) * (newModel.nd[m][k] + newModel.alpha) - / (newModel.ndsum[m] + Kalpha); - } - - // cummulate multinomial parameters - for (int k = 1; k < newModel.K; k++) { - newModel.p[k] += newModel.p[k - 1]; - } - - // scaled sample because of unnormalized p[] - final double u = Math.random() * newModel.p[newModel.K - 1]; - - for (topic = 0; topic < newModel.K; topic++) { - if (newModel.p[topic] > u) - break; - } - - // add newly estimated z_i to count variables - newModel.nw[_w][topic] += 1; - newModel.nd[m][topic] += 1; - newModel.nwsum[topic] += 1; - newModel.ndsum[m] += 1; - - return topic; - } - - protected void computeNewTheta() { - for (int m = 0; m < newModel.M; m++) { - for (int k = 0; k < newModel.K; k++) { - newModel.theta[m][k] = (newModel.nd[m][k] + newModel.alpha) - / (newModel.ndsum[m] + newModel.K * newModel.alpha); - } // end foreach topic - } // end foreach new document - } - - protected void computeNewPhi() { - for (int k = 0; k < newModel.K; k++) { - for (int _w = 0; _w < newModel.V; _w++) { - final Integer id = newModel.data.lid2gid.get(_w); - - if (id != null) { - newModel.phi[k][_w] = (trnModel.nw[id][k] + newModel.nw[_w][k] + newModel.beta) - / (newModel.nwsum[k] + newModel.nwsum[k] + trnModel.V * newModel.beta); - } - } // end foreach word - } // end foreach topic - } - - protected void computeTrnTheta() { - for (int m = 0; m < trnModel.M; m++) { - for (int k = 0; k < trnModel.K; k++) { - trnModel.theta[m][k] = (trnModel.nd[m][k] + trnModel.alpha) - / (trnModel.ndsum[m] + trnModel.K * trnModel.alpha); - } - } - } - - protected void computeTrnPhi() { - for (int k = 0; k < trnModel.K; k++) { - for (int w = 0; w < trnModel.V; w++) { - trnModel.phi[k][w] = (trnModel.nw[w][k] + trnModel.beta) - / (trnModel.nwsum[k] + trnModel.V * trnModel.beta); - } - } - } -} diff --git a/jgibblda/src/main/java/jgibblda/LDA.java b/jgibblda/src/main/java/jgibblda/LDA.java deleted file mode 100644 index 111ab000a34e447b0fbf981259125fb532024d2e..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/LDA.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -import org.kohsuke.args4j.CmdLineException; -import org.kohsuke.args4j.CmdLineParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LDA { - - public static final Logger log = LoggerFactory.getLogger(LDA.class); - - public static void main(final String args[]) { - final LDACmdOption option = new LDACmdOption(); - final CmdLineParser parser = new CmdLineParser(option); - - try { - if (args.length == 0) { - showHelp(parser); - return; - } - - parser.parseArgument(args); - - if (option.est || option.estc) { - final Estimator estimator = new Estimator(); - estimator.init(option); - estimator.estimate(); - } else if (option.inf) { - final Inferencer inferencer = new Inferencer(); - inferencer.init(option); - - final Model newModel = inferencer.inference(); - - for (int i = 0; i < newModel.phi.length; ++i) { - // phi: K * V - log.info("-----------------------\ntopic" + i + " : "); - for (int j = 0; j < 10; ++j) { - log.info(inferencer.globalDict.id2word.get(j) + "\t" + newModel.phi[i][j]); - } - } - } - } catch (final CmdLineException cle) { - log.info("Command line error: " + cle.getMessage()); - showHelp(parser); - return; - } catch (final Exception e) { - log.info("Error in main: " + e.getMessage()); - e.printStackTrace(); - return; - } - } - - public static void showHelp(final CmdLineParser parser) { - log.info("LDA [options ...] [arguments...]"); - parser.printUsage(System.out); - } - -} diff --git a/jgibblda/src/main/java/jgibblda/LDACmdOption.java b/jgibblda/src/main/java/jgibblda/LDACmdOption.java deleted file mode 100644 index 79c548a7fbf4648938ba936522be774dbf6aad28..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/LDACmdOption.java +++ /dev/null @@ -1,48 +0,0 @@ -package jgibblda; - -import org.kohsuke.args4j.Option; - -public class LDACmdOption { - - @Option(name = "-est", usage = "Specify whether we want to estimate model from scratch") - public boolean est = false; - - @Option(name = "-estc", usage = "Specify whether we want to continue the last estimation") - public boolean estc = false; - - @Option(name = "-inf", usage = "Specify whether we want to do inference") - public boolean inf = true; - - @Option(name = "-dir", usage = "Specify directory") - public String dir = ""; - - @Option(name = "-dfile", usage = "Specify data file") - public String dfile = ""; - - @Option(name = "-model", usage = "Specify the model name") - public String modelName = ""; - - @Option(name = "-alpha", usage = "Specify alpha") - public double alpha = -1.0; - - @Option(name = "-beta", usage = "Specify beta") - public double beta = -1.0; - - @Option(name = "-ntopics", usage = "Specify the number of topics") - public int K = 100; - - @Option(name = "-niters", usage = "Specify the number of iterations") - public int niters = 1000; - - @Option(name = "-savestep", usage = "Specify the number of steps to save the model since the last save") - public int savestep = 100; - - @Option(name = "-twords", usage = "Specify the number of most likely words to be printed for each topic") - public int twords = 100; - - @Option(name = "-withrawdata", usage = "Specify whether we include raw data in the input") - public boolean withrawdata = false; - - @Option(name = "-wordmap", usage = "Specify the wordmap file") - public String wordMapFileName = "wordmap.txt"; -} diff --git a/jgibblda/src/main/java/jgibblda/LDADataset.java b/jgibblda/src/main/java/jgibblda/LDADataset.java deleted file mode 100644 index f03d417a101e56ac0c14f8adf2419b62eb59b9f3..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/LDADataset.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ -package jgibblda; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LDADataset { - - public static final Logger log = LoggerFactory.getLogger(LDADataset.class); - - // --------------------------------------------------------------- - // Instance Variables - // --------------------------------------------------------------- - - public Dictionary localDict; // local dictionary - public Document[] docs; // a list of documents - public int M; // number of documents - public int V; // number of words - - // map from local coordinates (id) to global ones - // null if the global dictionary is not set - public Map<Integer, Integer> lid2gid; - - // link to a global dictionary (optional), null for train data, not null for - // test data - public Dictionary globalDict; - - // -------------------------------------------------------------- - // Constructor - // -------------------------------------------------------------- - public LDADataset() { - localDict = new Dictionary(); - M = 0; - V = 0; - docs = null; - - globalDict = null; - lid2gid = null; - } - - public LDADataset(final int M) { - localDict = new Dictionary(); - this.M = M; - this.V = 0; - docs = new Document[M]; - - globalDict = null; - lid2gid = null; - } - - public LDADataset(final int M, final Dictionary globalDict) { - localDict = new Dictionary(); - this.M = M; - this.V = 0; - docs = new Document[M]; - - this.globalDict = globalDict; - lid2gid = new HashMap<Integer, Integer>(); - } - - // ------------------------------------------------------------- - // Public Instance Methods - // ------------------------------------------------------------- - /** - * set the document at the index idx if idx is greater than 0 and less than - * M - * - * @param doc - * document to be set - * @param idx - * index in the document array - */ - public void setDoc(final Document doc, final int idx) { - if (0 <= idx && idx < M) { - docs[idx] = doc; - } - } - - /** - * set the document at the index idx if idx is greater than 0 and less than - * M - * - * @param str - * string contains doc - * @param idx - * index in the document array - */ - public void setDoc(final String str, final int idx) { - if (0 <= idx && idx < M) { - final String[] words = str.split("[ \\t\\n]"); - - final Vector<Integer> ids = new Vector<Integer>(); - - for (final String word : words) { - int _id = localDict.word2id.size(); - - if (localDict.contains(word)) - _id = localDict.getID(word); - - if (globalDict != null) { - // get the global id - final Integer id = globalDict.getID(word); - - if (id != null) { - localDict.addWord(word); - - lid2gid.put(_id, id); - ids.add(_id); - } else { // not in global dictionary - // do nothing currently - } - } else { - localDict.addWord(word); - ids.add(_id); - } - } - - final Document doc = new Document(ids, str); - docs[idx] = doc; - V = localDict.word2id.size(); - } - } - // --------------------------------------------------------------- - // I/O methods - // --------------------------------------------------------------- - - /** - * read a dataset from a stream, create new dictionary - * - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final String filename) { - try { - final BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(filename), "UTF-8")); - - final LDADataset data = readDataSet(reader); - - reader.close(); - return data; - } catch (final Exception e) { - log.error("Read Dataset Error: " + e.getMessage()); - e.printStackTrace(); - return null; - } - } - - /** - * read a dataset from a file with a preknown vocabulary - * - * @param filename - * file from which we read dataset - * @param dict - * the dictionary - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final String filename, final Dictionary dict) { - try { - final BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(filename), "UTF-8")); - final LDADataset data = readDataSet(reader, dict); - - reader.close(); - return data; - } catch (final Exception e) { - log.error("Read Dataset Error: " + e.getMessage()); - e.printStackTrace(); - return null; - } - } - - /** - * read a dataset from a stream, create new dictionary - * - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final BufferedReader reader) { - return readDataSet(reader, null); - } - - /** - * read a dataset from a stream with respect to a specified dictionary - * - * @param reader - * stream from which we read dataset - * @param dict - * the dictionary - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final BufferedReader reader, final Dictionary dict) { - try { - final List<String> lines = new ArrayList<>(); - - String line; - while ((line = reader.readLine()) != null) { - lines.add(line); - } - - final LDADataset data = new LDADataset(lines.size(), dict); - - for (int i = 0; i < lines.size(); i++) { - data.setDoc(lines.get(i), i); - } - - return data; - } catch (final Exception e) { - log.error("Read Dataset Error: " + e.getMessage()); - e.printStackTrace(); - return null; - } - } - - /** - * read a dataset from a string, create new dictionary - * - * @param str - * String from which we get the dataset, documents are seperated - * by newline character - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final String[] strs) { - final LDADataset data = new LDADataset(strs.length); - - for (int i = 0; i < strs.length; ++i) { - data.setDoc(strs[i], i); - } - return data; - } - - /** - * read a dataset from a string with respect to a specified dictionary - * - * @param str - * String from which we get the dataset, documents are seperated - * by newline character - * @param dict - * the dictionary - * @return dataset if success and null otherwise - */ - public static LDADataset readDataSet(final String[] strs, final Dictionary dict) { - final LDADataset data = new LDADataset(strs.length, dict); - - for (int i = 0; i < strs.length; ++i) { - data.setDoc(strs[i], i); - } - return data; - } -} diff --git a/jgibblda/src/main/java/jgibblda/Model.java b/jgibblda/src/main/java/jgibblda/Model.java deleted file mode 100644 index fbdb5b9bfde95d94b0903b8b9e0b99bd7fe6e3a3..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Model.java +++ /dev/null @@ -1,719 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ -package jgibblda; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Model { - - public static final Logger log = LoggerFactory.getLogger(Model.class); - - // --------------------------------------------------------------- - // Class Variables - // --------------------------------------------------------------- - - public static String tassignSuffix; // suffix for topic assignment file - public static String thetaSuffix; // suffix for theta (topic - document - // distribution) file - public static String phiSuffix; // suffix for phi file (topic - word - // distribution) file - public static String othersSuffix; // suffix for containing other parameters - public static String twordsSuffix; // suffix for file containing - // words-per-topics - - // --------------------------------------------------------------- - // Model Parameters and Variables - // --------------------------------------------------------------- - - public String wordMapFile; // file that contain word to id map - public String trainlogFile; // training log file - - public String dir; - public String dfile; - public String modelName; - public int modelStatus; // see Constants class for status of model - public LDADataset data; // link to a dataset - - public int M; // dataset size (i.e., number of docs) - public int V; // vocabulary size - public int K; // number of topics - public double alpha, beta; // LDA hyperparameters - public int niters; // number of Gibbs sampling iteration - public int liter; // the iteration at which the model was saved - public int savestep; // saving period - public int twords; // print out top words per each topic - public int withrawdata; - - // Estimated/Inferenced parameters - public double[][] theta; // theta: document - topic distributions, size M x - // K - public double[][] phi; // phi: topic-word distributions, size K x V - - // Temp variables while sampling - public Vector<Integer>[] z; // topic assignments for words, size M x - // doc.size() - protected int[][] nw; // nw[i][j]: number of instances of word/term i - // assigned to topic j, size V x K - protected int[][] nd; // nd[i][j]: number of words in document i assigned to - // topic j, size M x K - protected int[] nwsum; // nwsum[j]: total number of words assigned to topic - // j, size K - protected int[] ndsum; // ndsum[i]: total number of words in document i, - // size M - - // temp variables for sampling - protected double[] p; - - // --------------------------------------------------------------- - // Constructors - // --------------------------------------------------------------- - - public Model() { - setDefaultValues(); - } - - /** - * Set default values for variables - */ - public void setDefaultValues() { - wordMapFile = "wordmap.txt"; - trainlogFile = "trainlog.txt"; - tassignSuffix = ".tassign"; - thetaSuffix = ".theta"; - phiSuffix = ".phi"; - othersSuffix = ".others"; - twordsSuffix = ".twords"; - - dir = "./"; - dfile = "trndocs.dat"; - modelName = "model-final"; - modelStatus = Constants.MODEL_STATUS_UNKNOWN; - - M = 0; - V = 0; - K = 100; - alpha = 50.0 / K; - beta = 0.1; - niters = 2000; - liter = 0; - - z = null; - nw = null; - nd = null; - nwsum = null; - ndsum = null; - theta = null; - phi = null; - } - - // --------------------------------------------------------------- - // I/O Methods - // --------------------------------------------------------------- - /** - * read other file to get parameters - */ - protected boolean readOthersFile(final String otherFile) { - // open file <model>.others to read: - - try { - final BufferedReader reader = new BufferedReader(new FileReader(otherFile)); - String line; - while ((line = reader.readLine()) != null) { - final StringTokenizer tknr = new StringTokenizer(line, "= \t\r\n"); - - final int count = tknr.countTokens(); - if (count != 2) - continue; - - final String optstr = tknr.nextToken(); - final String optval = tknr.nextToken(); - - if (optstr.equalsIgnoreCase("alpha")) { - alpha = Double.parseDouble(optval); - } else if (optstr.equalsIgnoreCase("beta")) { - beta = Double.parseDouble(optval); - } else if (optstr.equalsIgnoreCase("ntopics")) { - K = Integer.parseInt(optval); - } else if (optstr.equalsIgnoreCase("liter")) { - liter = Integer.parseInt(optval); - } else if (optstr.equalsIgnoreCase("nwords")) { - V = Integer.parseInt(optval); - } else if (optstr.equalsIgnoreCase("ndocs")) { - M = Integer.parseInt(optval); - } else { - // any more? - } - } - - reader.close(); - } catch (final Exception e) { - log.error("Error while reading other file:" + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - @SuppressWarnings("unchecked") - protected boolean readTAssignFile(final String tassignFile) { - BufferedReader reader = null; - try { - int i, j; - reader = new BufferedReader(new InputStreamReader(new FileInputStream(tassignFile), "UTF-8")); - - String line; - z = new Vector[M]; - data = new LDADataset(M); - data.V = V; - for (i = 0; i < M; i++) { - line = reader.readLine(); - final StringTokenizer tknr = new StringTokenizer(line, " \t\r\n"); - - final int length = tknr.countTokens(); - - final Vector<Integer> words = new Vector<Integer>(); - final Vector<Integer> topics = new Vector<Integer>(); - - for (j = 0; j < length; j++) { - final String token = tknr.nextToken(); - - final StringTokenizer tknr2 = new StringTokenizer(token, ":"); - if (tknr2.countTokens() != 2) { - log.warn("Invalid word-topic assignment line\n"); - return false; - } - - words.add(Integer.parseInt(tknr2.nextToken())); - topics.add(Integer.parseInt(tknr2.nextToken())); - } // end for each topic assignment - - // allocate and add new document to the corpus - final Document doc = new Document(words); - data.setDoc(doc, i); - - // assign values for z - z[i] = new Vector<Integer>(); - for (j = 0; j < topics.size(); j++) { - z[i].add(topics.get(j)); - } - - } // end for each doc - } catch (final Exception e) { - log.error("Error while loading model: " + e.getMessage()); - e.printStackTrace(); - return false; - } finally { - if (reader != null) - try { - reader.close(); - } catch (final IOException e) {} - } - return true; - } - - /** - * load saved model - */ - public boolean loadModel() { - if (!readOthersFile(dir + File.separator + modelName + othersSuffix)) - return false; - - if (!readTAssignFile(dir + File.separator + modelName + tassignSuffix)) - return false; - - // read dictionary - final Dictionary dict = new Dictionary(); - if (!dict.readWordMap(dir + File.separator + wordMapFile)) - return false; - - data.localDict = dict; - - return true; - } - - /** - * Save word-topic assignments for this model - */ - public boolean saveModelTAssign(final String filename) { - int i, j; - - try { - final BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); - - // write docs with topic assignments for words - for (i = 0; i < data.M; i++) { - for (j = 0; j < data.docs[i].length; ++j) { - writer.write(data.docs[i].words[j] + ":" + z[i].get(j) + " "); - } - writer.write("\n"); - } - - writer.close(); - } catch (final Exception e) { - log.error("Error while saving model tassign: " + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Save theta (topic distribution) for this model - */ - public boolean saveModelTheta(final String filename) { - try { - final BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); - for (int i = 0; i < M; i++) { - for (int j = 0; j < K; j++) { - writer.write(theta[i][j] + " "); - } - writer.write("\n"); - } - writer.close(); - } catch (final Exception e) { - log.error("Error while saving topic distribution file for this model: " + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Save word-topic distribution - */ - - public boolean saveModelPhi(final String filename) { - try { - final BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); - - for (int i = 0; i < K; i++) { - for (int j = 0; j < V; j++) { - writer.write(phi[i][j] + " "); - } - writer.write("\n"); - } - writer.close(); - } catch (final Exception e) { - log.error("Error while saving word-topic distribution:" + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Save other information of this model - */ - public boolean saveModelOthers(final String filename) { - try { - final BufferedWriter writer = new BufferedWriter(new FileWriter(filename)); - - writer.write("alpha=" + alpha + "\n"); - writer.write("beta=" + beta + "\n"); - writer.write("ntopics=" + K + "\n"); - writer.write("ndocs=" + M + "\n"); - writer.write("nwords=" + V + "\n"); - writer.write("liters=" + liter + "\n"); - - writer.close(); - } catch (final Exception e) { - log.error("Error while saving model others:" + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Save model the most likely words for each topic - */ - public boolean saveModelTwords(final String filename) { - try { - final BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(filename), "UTF-8")); - - if (twords > V) { - twords = V; - } - - for (int k = 0; k < K; k++) { - final List<Pair> wordsProbsList = new ArrayList<Pair>(); - for (int w = 0; w < V; w++) { - final Pair p = new Pair(w, phi[k][w], false); - - wordsProbsList.add(p); - } // end foreach word - - // print topic - writer.write("Topic " + k + "th:\n"); - Collections.sort(wordsProbsList); - - for (int i = 0; i < twords; i++) { - if (data.localDict.contains((Integer) wordsProbsList.get(i).first)) { - final String word = data.localDict.getWord((Integer) wordsProbsList.get(i).first); - - writer.write("\t" + word + " " + wordsProbsList.get(i).second + "\n"); - } - } - } // end foreach topic - - writer.close(); - } catch (final Exception e) { - log.error("Error while saving model twords: " + e.getMessage()); - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Save model - */ - public boolean saveModel(final String modelName) { - if (!saveModelTAssign(dir + File.separator + modelName + tassignSuffix)) { - return false; - } - - if (!saveModelOthers(dir + File.separator + modelName + othersSuffix)) { - return false; - } - - if (!saveModelTheta(dir + File.separator + modelName + thetaSuffix)) { - return false; - } - - if (!saveModelPhi(dir + File.separator + modelName + phiSuffix)) { - return false; - } - - if (twords > 0) { - if (!saveModelTwords(dir + File.separator + modelName + twordsSuffix)) - return false; - } - return true; - } - - // --------------------------------------------------------------- - // Init Methods - // --------------------------------------------------------------- - /** - * initialize the model - */ - protected boolean init(final LDACmdOption option) { - if (option == null) - return false; - - modelName = option.modelName; - K = option.K; - - alpha = option.alpha; - if (alpha < 0.0) - alpha = 50.0 / K; - - if (option.beta >= 0) - beta = option.beta; - - niters = option.niters; - - dir = option.dir; - if (dir.endsWith(File.separator)) - dir = dir.substring(0, dir.length() - 1); - - dfile = option.dfile; - twords = option.twords; - wordMapFile = option.wordMapFileName; - - return true; - } - - /** - * Init parameters for estimation - */ - @SuppressWarnings("unchecked") - public boolean initNewModel(final LDACmdOption option) { - if (!init(option)) - return false; - - int m, n, w, k; - p = new double[K]; - - data = LDADataset.readDataSet(dir + File.separator + dfile); - if (data == null) { - log.error("Fail to read training data!\n"); - return false; - } - - // + allocate memory and assign values for variables - M = data.M; - V = data.V; - dir = option.dir; - savestep = option.savestep; - - // K: from command line or default value - // alpha, beta: from command line or default values - // niters, savestep: from command line or default values - - nw = new int[V][K]; - for (w = 0; w < V; w++) { - for (k = 0; k < K; k++) { - nw[w][k] = 0; - } - } - - nd = new int[M][K]; - for (m = 0; m < M; m++) { - for (k = 0; k < K; k++) { - nd[m][k] = 0; - } - } - - nwsum = new int[K]; - for (k = 0; k < K; k++) { - nwsum[k] = 0; - } - - ndsum = new int[M]; - for (m = 0; m < M; m++) { - ndsum[m] = 0; - } - - z = new Vector[M]; - for (m = 0; m < data.M; m++) { - final int N = data.docs[m].length; - z[m] = new Vector<Integer>(); - - // initilize for z - for (n = 0; n < N; n++) { - final int topic = (int) Math.floor(Math.random() * K); - z[m].add(topic); - - // number of instances of word assigned to topic j - nw[data.docs[m].words[n]][topic] += 1; - // number of words in document i assigned to topic j - nd[m][topic] += 1; - // total number of words assigned to topic j - nwsum[topic] += 1; - } - // total number of words in document i - ndsum[m] = N; - } - - theta = new double[M][K]; - phi = new double[K][V]; - - return true; - } - - /** - * Init parameters for inference - * - * @param newData - * DataSet for which we do inference - */ - @SuppressWarnings("unchecked") - public boolean initNewModel(final LDACmdOption option, final LDADataset newData, final Model trnModel) { - if (!init(option)) - return false; - - int m, n, w, k; - - K = trnModel.K; - alpha = trnModel.alpha; - beta = trnModel.beta; - - p = new double[K]; - log.info("K:" + K); - - data = newData; - - // + allocate memory and assign values for variables - M = data.M; - V = data.V; - dir = option.dir; - savestep = option.savestep; - log.info("M:" + M); - log.info("V:" + V); - - // K: from command line or default value - // alpha, beta: from command line or default values - // niters, savestep: from command line or default values - - nw = new int[V][K]; - for (w = 0; w < V; w++) { - for (k = 0; k < K; k++) { - nw[w][k] = 0; - } - } - - nd = new int[M][K]; - for (m = 0; m < M; m++) { - for (k = 0; k < K; k++) { - nd[m][k] = 0; - } - } - - nwsum = new int[K]; - for (k = 0; k < K; k++) { - nwsum[k] = 0; - } - - ndsum = new int[M]; - for (m = 0; m < M; m++) { - ndsum[m] = 0; - } - - z = new Vector[M]; - for (m = 0; m < data.M; m++) { - final int N = data.docs[m].length; - z[m] = new Vector<Integer>(); - - // initilize for z - for (n = 0; n < N; n++) { - final int topic = (int) Math.floor(Math.random() * K); - z[m].add(topic); - - // number of instances of word assigned to topic j - nw[data.docs[m].words[n]][topic] += 1; - // number of words in document i assigned to topic j - nd[m][topic] += 1; - // total number of words assigned to topic j - nwsum[topic] += 1; - } - // total number of words in document i - ndsum[m] = N; - } - - theta = new double[M][K]; - phi = new double[K][V]; - - return true; - } - - /** - * Init parameters for inference reading new dataset from file - */ - public boolean initNewModel(final LDACmdOption option, final Model trnModel) { - if (!init(option)) - return false; - - final LDADataset dataset = LDADataset.readDataSet(dir + File.separator + dfile, trnModel.data.localDict); - if (dataset == null) { - log.error("Fail to read dataset!\n"); - return false; - } - - return initNewModel(option, dataset, trnModel); - } - - /** - * init parameter for continue estimating or for later inference - */ - public boolean initEstimatedModel(final LDACmdOption option) { - if (!init(option)) - return false; - - int m, n, w, k; - - p = new double[K]; - - // load model, i.e., read z and trndata - if (!loadModel()) { - log.error("Fail to load word-topic assignment file of the model!\n"); - return false; - } - - log.info("Model loaded:"); - log.info("\talpha:" + alpha); - log.info("\tbeta:" + beta); - log.info("\tM:" + M); - log.info("\tV:" + V); - - nw = new int[V][K]; - for (w = 0; w < V; w++) { - for (k = 0; k < K; k++) { - nw[w][k] = 0; - } - } - - nd = new int[M][K]; - for (m = 0; m < M; m++) { - for (k = 0; k < K; k++) { - nd[m][k] = 0; - } - } - - nwsum = new int[K]; - for (k = 0; k < K; k++) { - nwsum[k] = 0; - } - - ndsum = new int[M]; - for (m = 0; m < M; m++) { - ndsum[m] = 0; - } - - for (m = 0; m < data.M; m++) { - final int N = data.docs[m].length; - - // assign values for nw, nd, nwsum, and ndsum - for (n = 0; n < N; n++) { - w = data.docs[m].words[n]; - final int topic = z[m].get(n); - - // number of instances of word i assigned to topic j - nw[w][topic] += 1; - // number of words in document i assigned to topic j - nd[m][topic] += 1; - // total number of words assigned to topic j - nwsum[topic] += 1; - } - // total number of words in document i - ndsum[m] = N; - } - - theta = new double[M][K]; - phi = new double[K][V]; - dir = option.dir; - savestep = option.savestep; - - return true; - } - -} diff --git a/jgibblda/src/main/java/jgibblda/Pair.java b/jgibblda/src/main/java/jgibblda/Pair.java deleted file mode 100644 index 887b90694bf140315407c44e1416beb5798d6b2c..0000000000000000000000000000000000000000 --- a/jgibblda/src/main/java/jgibblda/Pair.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2007 by - * - * Xuan-Hieu Phan hieuxuan@ecei.tohoku.ac.jp or pxhieu@gmail.com Graduate School - * of Information Sciences Tohoku University - * - * Cam-Tu Nguyen ncamtu@gmail.com College of Technology Vietnam National - * University, Hanoi - * - * JGibbsLDA is a free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * JGibbsLDA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * JGibbsLDA; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package jgibblda; - -@SuppressWarnings("rawtypes") -public class Pair implements Comparable<Pair> { - public Object first; - public Comparable second; - public static boolean naturalOrder = false; - - public Pair(final Object k, final Comparable v) { - first = k; - second = v; - } - - public Pair(final Object k, final Comparable v, final boolean naturalOrder) { - first = k; - second = v; - Pair.naturalOrder = naturalOrder; - } - - @Override - @SuppressWarnings("unchecked") - public int compareTo(final Pair p) { - if (naturalOrder) - return this.second.compareTo(p.second); - else - return -this.second.compareTo(p.second); - } -} diff --git a/vipra-backend/src/main/java/de/vipra/rest/resource/SequenceResource.java b/vipra-backend/src/main/java/de/vipra/rest/resource/SequenceResource.java index 170570f728616d07ba4b4f3e91d71271ae228355..4960daef6c84e8b73cbbdb14a3bc8bfab9202ad9 100644 --- a/vipra-backend/src/main/java/de/vipra/rest/resource/SequenceResource.java +++ b/vipra-backend/src/main/java/de/vipra/rest/resource/SequenceResource.java @@ -39,8 +39,7 @@ public class SequenceResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getSequences(@QueryParam("skip") final Integer skip, @QueryParam("limit") final Integer limit, - @QueryParam("sort") @DefaultValue("startDate") final String sortBy, - @QueryParam("fields") final String fields) { + @QueryParam("sort") @DefaultValue("id") final String sortBy, @QueryParam("fields") final String fields) { final ResponseWrapper<List<SequenceFull>> res = new ResponseWrapper<>(); if (res.hasErrors()) diff --git a/vipra-cmd/pom.xml b/vipra-cmd/pom.xml index ccacb04b64992fe250634dcba7b7686d246cfedc..5c87afc82927589f029ac08340756eddef4b1e08 100644 --- a/vipra-cmd/pom.xml +++ b/vipra-cmd/pom.xml @@ -87,11 +87,6 @@ <artifactId>util</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> - <dependency> - <groupId>jgibblda</groupId> - <artifactId>jgibblda</artifactId> - <version>0.0.1-SNAPSHOT</version> - </dependency> </dependencies> <build> diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java b/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java index dc5e26555ecaccd1de04888d0caf2f6173e679af..9a8db6e34714d258e09e64f75ba63d3857778800 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/file/Filebase.java @@ -86,8 +86,6 @@ public abstract class Filebase implements Closeable { switch (Constants.ANALYZER) { case DTM: return new DTMFilebase(dataDir); - case JGIBB: - return new JGibbFilebase(dataDir); default: return null; } diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java b/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java deleted file mode 100644 index 0e42682aee43f9ccdbb953e8459296e0176801cb..0000000000000000000000000000000000000000 --- a/vipra-cmd/src/main/java/de/vipra/cmd/file/JGibbFilebase.java +++ /dev/null @@ -1,33 +0,0 @@ -package de.vipra.cmd.file; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.List; - -import de.vipra.cmd.ex.FilebaseException; -import de.vipra.util.model.ArticleFull; -import edu.stanford.nlp.util.StringUtils; - -public class JGibbFilebase extends Filebase { - - private final File modelFile; - - public JGibbFilebase(final File dataDir) throws FilebaseException { - super(dataDir, "jgibb"); - modelFile = getModelFile(null); - } - - @Override - public synchronized void write(final List<ArticleFull> articles) throws IOException { - if (!articles.isEmpty()) { - final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(modelFile))); - for (final ArticleFull article : articles) - writer.write(StringUtils.join(article.getProcessedText()) + "\n"); - writer.close(); - } - } - -} diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/lda/Analyzer.java b/vipra-cmd/src/main/java/de/vipra/cmd/lda/Analyzer.java index 88a31bcfe7827cb6be81cf04491abe79bda6c2d8..b62453ce717e9c4751305301abd7027f89b975cc 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/lda/Analyzer.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/lda/Analyzer.java @@ -26,9 +26,6 @@ public abstract class Analyzer { case DTM: analyzer = new DTMAnalyzer(); break; - case JGIBB: - analyzer = new JGibbAnalyzer(); - break; default: return null; } diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/lda/DTMAnalyzer.java b/vipra-cmd/src/main/java/de/vipra/cmd/lda/DTMAnalyzer.java index 5ac5d47406ce5e251cbcb08196665ca885aca35d..9287f12beb9aeeaa452fced3ecc8723d82eb0dce 100644 --- a/vipra-cmd/src/main/java/de/vipra/cmd/lda/DTMAnalyzer.java +++ b/vipra-cmd/src/main/java/de/vipra/cmd/lda/DTMAnalyzer.java @@ -201,7 +201,6 @@ public class DTMAnalyzer extends Analyzer { final TopicFull newTopic = new TopicFull(); final List<Sequence> newTopicSequences = new ArrayList<>(sequencesCount); newTopic.setSequences(newTopicSequences); - newTopic.setDynamic(true); newTopics.add(newTopic); in = new BufferedReader(new InputStreamReader(new FileInputStream(seqFile))); @@ -332,7 +331,7 @@ public class DTMAnalyzer extends Analyzer { // update article if (!newTopicRefs.isEmpty()) { // renormalize share - for (TopicRef newTopicRef : newTopicRefs) + for (final TopicRef newTopicRef : newTopicRefs) newTopicRef.setShare(newTopicRef.getShare() / reducedShare); Collections.sort(newTopicRefs, Comparator.reverseOrder()); diff --git a/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbAnalyzer.java b/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbAnalyzer.java deleted file mode 100644 index 7f94afc67fafb02e4a145d00811826816fe196cd..0000000000000000000000000000000000000000 --- a/vipra-cmd/src/main/java/de/vipra/cmd/lda/JGibbAnalyzer.java +++ /dev/null @@ -1,252 +0,0 @@ -package de.vipra.cmd.lda; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.bson.types.ObjectId; - -import de.vipra.cmd.ex.AnalyzerException; -import de.vipra.cmd.file.FilebaseIndex; -import de.vipra.util.Config; -import de.vipra.util.Constants; -import de.vipra.util.CountMap; -import de.vipra.util.FileUtils; -import de.vipra.util.ex.ConfigException; -import de.vipra.util.ex.DatabaseException; -import de.vipra.util.model.ArticleFull; -import de.vipra.util.model.Topic; -import de.vipra.util.model.TopicFull; -import de.vipra.util.model.TopicRef; -import de.vipra.util.model.TopicWord; -import de.vipra.util.model.Word; -import de.vipra.util.service.MongoService; -import jgibblda.Estimator; -import jgibblda.LDACmdOption; - -public class JGibbAnalyzer extends Analyzer { - - public static final Logger log = LogManager.getLogger(JGibbAnalyzer.class); - public static final String NAME = "jgibb"; - - private File dataDir; - private File modelDir; - private File modelFile; - private LDACmdOption options; - private MongoService<ArticleFull, ObjectId> dbArticles; - private MongoService<TopicFull, ObjectId> dbTopics; - private MongoService<Word, String> dbWords; - private FilebaseIndex index; - - protected JGibbAnalyzer() { - super("JGibb Analyzer"); - } - - @Override - public void init(Config config) throws AnalyzerException { - options = new LDACmdOption(); - - try { - dataDir = config.getDataDirectory(); - } catch (final ConfigException e) { - throw new AnalyzerException(e); - } - - modelDir = new File(dataDir, NAME); - options.dir = modelDir.getAbsolutePath(); - options.estc = new File(modelDir, NAME + ".tassign").exists(); - options.est = !options.estc; - options.K = Constants.K_TOPICS; - options.twords = Constants.K_TOPIC_WORDS; - options.niters = Constants.STATIC_ITER; - - modelFile = new File(modelDir, NAME); - options.dfile = modelFile.getName(); - - options.modelName = NAME; - - try { - config = Config.getConfig(); - dbArticles = MongoService.getDatabaseService(config, ArticleFull.class); - dbTopics = MongoService.getDatabaseService(config, TopicFull.class); - dbWords = MongoService.getDatabaseService(config, Word.class); - index = new FilebaseIndex(modelDir); - } catch (final Exception e) { - throw new AnalyzerException(e); - } - } - - @Override - public void analyze(final boolean reread) throws AnalyzerException { - if (!modelFile.exists()) { - throw new AnalyzerException("model file does not exist: " + modelFile.getAbsolutePath()); - } - - if (!reread) { - final Estimator estimator = new Estimator(); - estimator.init(options); - estimator.estimate(); - } - - final boolean seqRelativeCutoff = Constants.MINIMUM_RELATIVE_PROB > 0; - - // read topic definitions and save - - final File twords = new File(modelDir, NAME + ".twords"); - List<String> lines; - try { - lines = FileUtils.readFile(twords); - } catch (final IOException e) { - throw new AnalyzerException(e); - } - - // the list of new topics - final List<TopicFull> newTopics = new ArrayList<>(options.K); - // set of new words - final Set<Word> newWords = new HashSet<>(); - - List<TopicWord> topicWords = null; - int topicIndex = -1; - final double[] maxLikelinesses = new double[Constants.K_TOPICS]; - - // create topics and determine maximum likeliness for each topic - for (final String line : lines) { - if (!line.startsWith("\t")) { - topicIndex++; - topicWords = new ArrayList<>(Constants.K_TOPIC_WORDS); - final TopicFull newTopic = new TopicFull(); - newTopic.setWords(topicWords); - newTopics.add(newTopic); - continue; - } - - final String[] parts = line.trim().split("\\s+"); - final double likeliness = Double.parseDouble(parts[1]); - - // determine maximum likeliness of this topic - if (likeliness > maxLikelinesses[topicIndex]) - maxLikelinesses[topicIndex] = likeliness; - - // check word likeliness - topicWords.add(new TopicWord(new Word(parts[0]), likeliness)); - } - - // filter out words below minimum relative likeliness, add accepted - // words to list of new words - for (topicIndex = 0; topicIndex < newTopics.size(); topicIndex++) { - final TopicFull topic = newTopics.get(topicIndex); - final double maxLikeliness = maxLikelinesses[topicIndex]; - final ArrayList<TopicWord> filteredTopicWords = new ArrayList<>(topic.getWords().size()); - for (final TopicWord word : topic.getWords()) { - if (!seqRelativeCutoff || word.getLikeliness() >= Constants.MINIMUM_RELATIVE_PROB * maxLikeliness) { - filteredTopicWords.add(word); - newWords.add(word.getWord()); - } - } - topic.setWords(filteredTopicWords); - - if (!filteredTopicWords.isEmpty()) { - Collections.sort(filteredTopicWords, Collections.reverseOrder()); - - topic.setName(TopicFull.getNameFromWords(filteredTopicWords)); - } - } - - // recreate topics and words - dbTopics.drop(); - dbWords.drop(); - try { - dbTopics.createMultiple(newTopics); - dbWords.createMultiple(newWords); - } catch (final DatabaseException e) { - throw new AnalyzerException(e); - } - - // read documents and reference topics - - final File tassign = new File(modelDir, NAME + ".tassign"); - final Pattern topicIndexPattern = Pattern.compile(":(\\d+)"); - BufferedReader in = null; - - try { - in = new BufferedReader(new InputStreamReader(new FileInputStream(tassign))); - String line; - int articleIndex = 0; - - // each line in the tassign file is a document, formatted with - // <word-id>:<topic-id> - while ((line = in.readLine()) != null) { - // extract topic ids and count them - final CountMap<String> countMap = new CountMap<>(); - final Matcher matcher = topicIndexPattern.matcher(line); - while (matcher.find()) - countMap.count(matcher.group(1)); - - int maxCount = 0; - for (final Entry<String, Integer> entry : countMap.entrySet()) - if (entry.getValue() > maxCount) - maxCount = entry.getValue(); - final double minShare = maxCount * Constants.MINIMUM_RELATIVE_PROB; - - // create list of topics refs referencing topics with counted - // occurrences, sum accepted topic word count - long reducedCount = 0; - final List<TopicRef> newTopicRefs = new ArrayList<>(countMap.size()); - for (final Entry<String, Integer> entry : countMap.entrySet()) { - // check if topic above threshold - if (entry.getValue() >= minShare) { - reducedCount += entry.getValue(); - final TopicFull topic = newTopics.get(Integer.parseInt(entry.getKey())); - // TODO words with low relative likeliness are ignored. - // topic references from this file are possibly wrong. - // fix this by checking if the word is actually accepted - // by the referenced topic. - final TopicRef ref = new TopicRef(); - ref.setCount(entry.getValue()); - ref.setTopic(new Topic(topic.getId())); - newTopicRefs.add(ref); - } - } - - // calculate each accepted topic share - for (final TopicRef ref : newTopicRefs) - ref.setShare((double) ref.getCount() / reducedCount); - - if (!newTopicRefs.isEmpty()) { - Collections.sort(newTopicRefs, Comparator.reverseOrder()); - - // update article with topic references (partial update) - final ArticleFull article = new ArticleFull(); - article.setId(index.get(articleIndex++)); - article.setTopics(newTopicRefs); - - try { - // TODO: using field name here. Hard to refactor - dbArticles.updateSingle(article, "topics"); - } catch (final DatabaseException e) { - log.error(e); - } - } - } - - in.close(); - - } catch (final Exception e) { - throw new AnalyzerException(e); - } - } - -} diff --git a/vipra-ui/app/html/directives/alert.html b/vipra-ui/app/html/directives/alert.html deleted file mode 100644 index 97d850995dbbfd2b1c6e65dd2eb0da4c49a62cb0..0000000000000000000000000000000000000000 --- a/vipra-ui/app/html/directives/alert.html +++ /dev/null @@ -1,6 +0,0 @@ -<div ng-attr-class="{{classes}}" role="alert"> - <button type="button" class="close" data-dismiss="alert" aria-label="Close" ng-show="dismissible"> - <span aria-hidden="true">×</span> - </button> - <ng-transclude/> -</div> diff --git a/vipra-ui/app/html/directives/dropdown.html b/vipra-ui/app/html/directives/dropdown.html deleted file mode 100644 index 70c61a654a796ba0d342a3c2e70ca164a472525b..0000000000000000000000000000000000000000 --- a/vipra-ui/app/html/directives/dropdown.html +++ /dev/null @@ -1,7 +0,0 @@ -<div class="dropdown"> - <button class="btn btn-default dropdown-toggle" type="button" ng-attr-id="{{dropdownId}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> - <span ng-bind="label"></span> - <span class="caret"></span> - </button> - <ul ng-attr-class="{{'dropdown-menu ' + align}}" ng-attr-aria-labelledby="{{dropdownId}}" ng-transclude></ul> -</div> diff --git a/vipra-ui/app/html/explorer.html b/vipra-ui/app/html/explorer.html index 961e0f9d437afb9f7d99e5d334a393da120e53c3..ad539a64615ae34b6a4815a5710b97789e7624a0 100644 --- a/vipra-ui/app/html/explorer.html +++ b/vipra-ui/app/html/explorer.html @@ -1,10 +1,24 @@ <div class="fullsize navpadding explorer" ng-cloak ng-hide="$state.current.name !== 'explorer'"> <div class="sidebar"> - <button class="btn btn-sm btn-default" ng-click="checkTopics(true)">All</button> - <button class="btn btn-sm btn-default" ng-click="checkTopics(false)">None</button> - <button class="btn btn-sm btn-default" ng-click="checkTopics()">Toggle</button> + <div class="btn-group btn-group-justified" role="group" aria-label="..."> + <a class="btn btn-sm btn-default" ng-click="checkTopics(true)" title="Select all topics">All</a> + <a class="btn btn-sm btn-default" ng-click="checkTopics(false)" title="Deselect all topics">None</a> + <a class="btn btn-sm btn-default" ng-click="checkTopics()" title="Toggle all topics">Toggle</a> + </div> + <div class="btn-group btn-group-justified"> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'name'" title="Sort by name">α</a> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'avgRelevance'" title="Sort by relevance average">μ</a> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'varRelevance'" title="Sort by relevance variance">σ</a> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'frel'" title="Sort by falling relevance">↘</a> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'rrel'" title="Sort by rising relevance">↗</a> + <a class="btn btn-sm btn-default" ng-model="opts.sorttopics" ng-model-store bs-radio="'rreld'" title="Sort by rising relevance with decay">↝</a> + </div> + <div class="btn-group btn-group-justified"> + <input type="text" class="form-control" ng-model="search.$" ng-model-store placeholder="Filter"> + <span class="glyphicon glyphicon-remove-circle searchclear" ng-click="search=''"></span> + </div> <ul class="list-unstyled topic-choice"> - <li ng-repeat="topic in topics"> + <li ng-repeat="topic in topics | orderBy:opts.sorttopics | filter:search"> <div class="checkbox checkbox-condensed" ng-attr-title="{{::topic.name}}" ng-class="{selected:opts.selectedTopics[topic.id]}"> <input type="checkbox" ng-model="opts.selectedTopics[topic.id]" ng-attr-id="{{::topic.id}}" ng-model-store="selectedTopics-{{::topic.id}}"> <label class="check" ng-attr-for="{{::topic.id}}"> @@ -15,7 +29,19 @@ </li> </ul> </div> - <div class="chart"> - + <div class="chart message-container"> + <div class="topbar"> + Display relevances: + <div class="radio radio-inline"> + <input type="radio" id="seqAbsolute" ng-model="opts.seqstyle" value="absolute" ng-model-store ng-model-default="'absolute'"> + <label for="seqAbsolute">Absolute</label> + </div> + <div class="radio radio-inline"> + <input type="radio" id="seqRelative" ng-model="opts.seqstyle" value="relative" ng-model-store> + <label for="seqRelative">Relative</label> + </div> + </div> + <div class="area-chart" id="topic-seq" highcharts="topicSeq"></div> + <div class="message" ng-show="!topicsSelected">No topic selected</div> </div> </div> \ No newline at end of file diff --git a/vipra-ui/app/html/index.html b/vipra-ui/app/html/index.html index 260825fac09599e9678a420d1a014b80e9eea49d..5798ff160834e05c92b0b70edcaeac3984d94aee 100644 --- a/vipra-ui/app/html/index.html +++ b/vipra-ui/app/html/index.html @@ -54,4 +54,4 @@ </div> </div> </div> -<div ng-cloak ui-view></div> +<div ng-cloak ui-view></div> \ No newline at end of file diff --git a/vipra-ui/app/html/network.html b/vipra-ui/app/html/network.html index 6d933364f6742036cddb10b081943f04c15dd159..1fbf495530f2289088d6bb1fced3aec6698f3b0c 100644 --- a/vipra-ui/app/html/network.html +++ b/vipra-ui/app/html/network.html @@ -1,15 +1,18 @@ <div ng-cloak ng-hide="$state.current.name !== 'network'"> <div class="fullsize navpadding"> <div class="graph-legend overlay"> - <label style="color:{{colors.articles}}"> - <input type="checkbox" ng-model="shown.articles" ng-model-store="showArticles" ng-model-default="type == 'articles'" ng-disabled="type == 'articles'"> Articles - </label> - <label style="color:{{colors.topics}}"> - <input type="checkbox" ng-model="shown.topics" ng-model-store="showTopics" ng-model-default="true" ng-disabled="type == 'topics'"> Topics - </label> - <label style="color:{{colors.words}}"> - <input type="checkbox" ng-model="shown.words" ng-model-store="showWords" ng-model-default="true" ng-disabled="type == 'words'"> Words - </label> + <div class="checkbox"> + <input type="checkbox" id="showArticles" ng-model="shown.articles" ng-model-store="showArticles" ng-model-default="type == 'articles'" ng-disabled="type == 'articles'"> + <label for="showArticles" style="color:{{colors.articles}}">Articles</label> + </div> + <div class="checkbox"> + <input type="checkbox" id="showTopics" ng-model="shown.topics" ng-model-store="showTopics" ng-model-default="true" ng-disabled="type == 'topics'"> + <label for="showTopics" style="color:{{colors.topics}}">Topics</label> + </div> + <div class="checkbox"> + <input type="checkbox" id="showWords" ng-model="shown.words" ng-model-store="showWords" ng-model-default="true" ng-disabled="type == 'words'"> + <label for="showWords" style="color:{{colors.words}}">Words</label> + </div> </div> <div class="fullsize navpadding" id="visgraph"></div> </div> diff --git a/vipra-ui/app/html/topics/show.html b/vipra-ui/app/html/topics/show.html index 6dd31fad7b18a8ce006f64d88a0e3fa1ed7c7ced..599aa2085117dc5536e04a8faf8d42a1cf6df177 100644 --- a/vipra-ui/app/html/topics/show.html +++ b/vipra-ui/app/html/topics/show.html @@ -14,15 +14,18 @@ </div> </div> </h1> - <bs-alert type="danger" ng-if="renameErrors"> - <span ng-bind-html="renameErrors"></span> - </bs-alert> <table class="item-actions"> <tr> <td> - <bs-dropdown label="Actions"> - <li><a ng-click="startRename()">Rename</a></li> - </bs-dropdown> + <div class="dropdown"> + <button class="btn btn-default dropdown-toggle" type="button" id="actionsDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> + Actions + <span class="caret"></span> + </button> + <ul class="dropdown-menu" aria-labelledby="actionsDropdown"> + <li><a ng-click="startRename()">Rename</a></li> + </ul> + </div> </td> <td> <a class="btn btn-default" ui-sref="network({type:'topics', id:topic.id})">Network graph</a> @@ -54,53 +57,26 @@ </table> </div> </div> - <div ng-if="!topic.dynamic"> - <h3>Words</h3> - <div class="row"> - <div class="col-md-12"> - <table class="table table-bordered table-condensed table-fixed"> - <thead> - <tr> - <th sort-by="id" ng-model="opts.wordSort" sort-reverse="opts.wordSortRev"> - Word - </th> - <th sort-by="likeliness" ng-model="opts.wordSort" sort-reverse="opts.wordSortRev"> - Likeliness - </th> - </tr> - </thead> - <tbody> - <tr ng-repeat="word in topic.words | orderBy:opts.wordSort:opts.wordSortRev"> - <td> - <a ui-sref="words.show({id:word.id})" ng-bind="word.id"></a> - </td> - <td ng-bind-template="{{word.likeliness.toFixed(6)}}"></td> - </tr> - </tbody> - </table> - </div> - </div> - </div> - <div ng-if="topic.dynamic"> - <h3>Relevance over time</h3> - <div class="row"> - <div class="col-md-12"> - <div class="well well-sm"> - <label class="radio-inline"> - <input type="radio" ng-model="opts.seqstyle" value="absolute" ng-model-store="seqStyle" ng-model-default="'absolute'" ng-change="changeSeqStyle()">Absolute - </label> - <label class="radio-inline"> - <input type="radio" ng-model="opts.seqstyle" value="relative" ng-model-store="seqStyle" ng-change="changeSeqStyle()">Relative - </label> + <h3>Relevance over time</h3> + <div class="row"> + <div class="col-md-12"> + <div class="well well-sm"> + <div class="radio radio-inline"> + <input type="radio" id="seqAbsolute" ng-model="opts.seqstyle" value="absolute" ng-model-store="seqStyle" ng-model-default="'absolute'"> + <label for="seqAbsolute">Absolute</label> + </div> + <div class="radio radio-inline"> + <input type="radio" id="seqRelative" ng-model="opts.seqstyle" value="relative" ng-model-store="seqStyle"> + <label for="seqRelative">Relative</label> </div> </div> </div> - <br> - <div class="row"> - <div class="col-md-12"> - <div class="area-chart" id="topic-seq" highcharts="topicSeq"></div> - </div> + </div> + <br> + <div class="row"> + <div class="col-md-12"> + <div class="area-chart" id="topic-seq" highcharts="topicSeq"></div> </div> - </div> + </div> </div> <div ng-cloak ui-view></div> diff --git a/vipra-ui/app/js/app.js b/vipra-ui/app/js/app.js index 515882f4e578d6bc16fc36a1554b5a5da97d825b..cfa37ff395f75cd560a4a2ac1842f6e1b02f8312 100644 --- a/vipra-ui/app/js/app.js +++ b/vipra-ui/app/js/app.js @@ -10,6 +10,7 @@ var app = angular.module('vipra.app', [ 'ngResource', 'ngSanitize', + 'ngAnimate', 'ui.router', 'nya.bootstrap.select', 'vipra.controllers', diff --git a/vipra-ui/app/js/controllers.js b/vipra-ui/app/js/controllers.js index bf42c96a245e1d81dd22bd94502f1282ccba027d..6bfbe8838dc0f79391847a9ded297a5cd7186435 100644 --- a/vipra-ui/app/js/controllers.js +++ b/vipra-ui/app/js/controllers.js @@ -293,9 +293,13 @@ app.controller('ExplorerController', ['$scope', 'TopicFactory', function($scope, TopicFactory) { - $scope.opts = {}; + $scope.opts = { + sorttopics: 'name' + }; - TopicFactory.query({}, function(data) { + TopicFactory.query({ + fields: 'name,sequences,avgRelevance,varRelevance' + }, function(data) { $scope.topics = data; var colors = Vipra.generateColors($scope.topics.length); for (var i = 0; i < $scope.topics.length; i++) @@ -306,17 +310,70 @@ $scope.checkTopics = function(to) { var toggle = typeof to === 'undefined'; - if(!$scope.opts.selectedTopics) + if (!$scope.opts.selectedTopics) $scope.opts.selectedTopics = {}; - for(var i = 0, t; i < $scope.topics.length; i++) { + for (var i = 0, t; i < $scope.topics.length; i++) { t = $scope.topics[i]; - if(toggle) + if (toggle) $scope.opts.selectedTopics[t.id] = !$scope.opts.selectedTopics[t.id]; else $scope.opts.selectedTopics[t.id] = to; } }; + $scope.redrawGraph = function() { + if (!$scope.topics || !$scope.opts.selectedTopics) return; + var series = []; + + // create series of selected topics + for (var i = 0; i < $scope.topics.length; i++) { + if ($scope.opts.selectedTopics[$scope.topics[i].id]) { + var topic = $scope.topics[i], + min = 0, + max = 0, + relevances = []; + + // data array with relevances and min/max + for (var j = 0, sequence, relevance; j < topic.sequences.length; j++) { + sequence = topic.sequences[j]; + relevance = $scope.opts.seqstyle === 'relative' ? sequence.relevanceChange : sequence.relevance; + relevances.push({ + x: new Date(sequence.window.startDate).getTime(), + y: relevance, + id: topic.id, + seq: sequence + }); + if (relevances[j].y > relevances[max].y) + max = j; + else if (relevances[j].y < relevances[min].y) + min = j; + } + + // mark maximum and minimum value + relevances[max].marker = { symbol: 'triangle', fillColor: '#f00' }; + relevances[min].marker = { symbol: 'triangle-down', fillColor: '#f00' }; + + series.push({ + name: topic.name, + data: relevances, + color: 'rgb(' + topic.color.join() + ')' + }); + } + } + + // highcharts configuration + $scope.topicSeq = areaRelevanceChart(series, $scope.selectSequence); + $scope.topicsSelected = series.length; + }; + + $scope.selectSequence = function(node) { + $scope.$apply(function() { + + }); + }; + + $scope.$watchCollection('opts.selectedTopics', $scope.redrawGraph); + $scope.$watch('opts.seqstyle', $scope.redrawGraph); } ]); @@ -377,22 +434,11 @@ } // highcharts data - var topicShare = { - chart: { type: 'pie' }, - credits: { enabled: false }, - plotOptions: { - pie: { allowPointSelect: true } - }, - title: { text: '' }, - tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, - series: [{ - name: 'Topic Share', - colorByPoint: true, - data: topicShareSeries - }] - }; - - $scope.topicShare = topicShare; + $scope.topicShare = topicShareChart([{ + name: 'Topic Share', + colorByPoint: true, + data: topicShareSeries + }]); } }, function(err) { $scope.errors = err; @@ -467,6 +513,40 @@ $scope.topic = data; $scope.topicCreated = Vipra.formatDateTime($scope.topic.created); $scope.topicModified = Vipra.formatDateTime($scope.topic.modified); + + $scope.$watch('opts.seqstyle', function(style) { + if (!style || !$scope.topic || !$scope.topic.sequences) return; + console.log('redraw relevance chart'); + var min = 0, + max = 0, + relevances = []; + + // create series + for (var i = 0, sequence, relevance; i < $scope.topic.sequences.length; i++) { + sequence = $scope.topic.sequences[i]; + relevance = $scope.opts.seqstyle === 'relative' ? sequence.relevanceChange : sequence.relevance; + relevances.push([new Date(sequence.window.startDate).getTime(), relevance]); + if (relevances[i][1] > relevances[max][1]) + max = i; + else if (relevances[i][1] < relevances[min][1]) + min = i; + } + + // mark maximum and minimum value + relevances[max] = { + x: relevances[max][0], + y: relevances[max][1], + marker: { symbol: 'triangle', fillColor: '#f00' } + }; + relevances[min] = { + x: relevances[min][0], + y: relevances[min][1], + marker: { symbol: 'triangle-down', fillColor: '#f00' } + }; + + // highcharts configuration + $scope.topicSeq = areaRelevanceChart([{ name: $scope.topic.name, data: relevances }]); + }); }, function(err) { $scope.errors = err; }); @@ -500,60 +580,6 @@ $event.preventDefault(); } }; - - $scope.$watch('opts.seqstyle', function(style) { - if (!style) return; - console.log('redraw relevance chart'); - var min = 0, - max = 0, - relevances = []; - // create series - for (var i = 0, sequence, relevance; i < $scope.topic.sequences.length; i++) { - sequence = $scope.topic.sequences[i]; - relevance = $scope.opts.seqstyle === 'relative' ? sequence.relevanceChange : sequence.relevance; - relevances.push([new Date(sequence.window.startDate).getTime(), relevance]); - if (relevances[i][1] > relevances[max][1]) - max = i; - else if (relevances[i][1] < relevances[min][1]) - min = i; - } - - // mark maximum and minimum value - relevances[max] = { - x: relevances[max][0], - y: relevances[max][1], - marker: { symbol: 'triangle', fillColor: '#f00' } - }; - relevances[min] = { - x: relevances[min][0], - y: relevances[min][1], - marker: { symbol: 'triangle-down', fillColor: '#f00' } - }; - - // highcharts configuration - $scope.topicSeq = { - chart: { - type: 'areaspline', - zoomType: 'x', - spacingLeft: 0, - spacingRight: 0 - }, - title: { text: '' }, - xAxis: { - type: 'datetime', - title: { text: '' } - }, - yAxis: { title: { text: 'Relevance' } }, - tooltip: { - headerFormat: '', - pointFormat: '{point.x:%Y}: {point.y:.4f}' - }, - legend: { enabled: false }, - credits: { enabled: false }, - plotOptions: { areaspline: { fillOpacity: 0.5 } }, - series: [{ name: $scope.topic.name, data: relevances }] - }; - }); } ]); @@ -633,4 +659,59 @@ } ]); + /**************************************************************************** + * Shared Highcharts configurations + ****************************************************************************/ + + function areaRelevanceChart(series, clickCallback) { + return { + chart: { + type: 'areaspline', + zoomType: 'x', + spacingLeft: 0, + spacingRight: 0 + }, + title: { text: '' }, + xAxis: { + type: 'datetime', + title: { text: '' } + }, + yAxis: { title: { text: 'Relevance' } }, + tooltip: { + headerFormat: '', + pointFormat: '{point.x:%Y}: {point.y:.4f}' + }, + legend: { enabled: false }, + credits: { enabled: false }, + plotOptions: { + areaspline: { fillOpacity: 0.5 }, + series: { + cursor: 'pointer', + allowPointSelect: true, + point: { + events: { + click: function(e) { + clickCallback(e.point); + } + } + } + } + }, + series: series + }; + } + + function topicShareChart(series) { + return { + chart: { type: 'pie' }, + credits: { enabled: false }, + plotOptions: { + pie: { allowPointSelect: true } + }, + title: { text: '' }, + tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, + series: series + }; + } + })(); diff --git a/vipra-ui/app/js/directives.js b/vipra-ui/app/js/directives.js index d790879ba8a00a2fbd85f584fb80f8ac96b4fbf4..754ef28f055d8ba21d4e7289a2b111cebced0eb8 100644 --- a/vipra-ui/app/js/directives.js +++ b/vipra-ui/app/js/directives.js @@ -2,7 +2,7 @@ * Vipra Application * Directives ******************************************************************************/ -/* globals angular, $, console, Vipra */ +/* globals angular, console */ (function() { "use strict"; @@ -65,16 +65,6 @@ }; }); - app.directive('toggleLink', function() { - return { - link: function($scope, $elem, $attrs) { - $elem.click(function() { - $($attrs.target).slideToggle(); - }); - } - }; - }); - app.directive('ngModelStore', ['Store', function(Store) { return { restrict: 'A', @@ -88,7 +78,7 @@ console.log('no store key given'); return; } - var key = $attrs.ngModelStore; + var key = $attrs.ngModelStore || $attrs.ngModel; var value = Store(key); if (value !== null) { $ctrl.$setViewValue(value); @@ -104,49 +94,6 @@ }; }]); - app.directive('bsDropdown', function() { - return { - scope: { - label: '@', - align: '@' - }, - templateUrl: 'html/directives/dropdown.html', - transclude: true, - replace: true, - link: function($scope) { - $scope.dropdownId = Vipra.randomId(); - $scope.align = 'dropdown-menu-left'; - if ($scope.align === 'right') - $scope.align = 'dropdown-menu-right'; - } - }; - }); - - app.directive('bsAlert', function() { - return { - scope: { - type: '@', - dismissible: '@' - }, - transclude: true, - replace: true, - templateUrl: 'html/directives/alert.html', - link: function($scope) { - if (!$scope.type) { - console.log('no alert type given'); - return; - } - - $scope.dismissible = $scope.dismissible !== 'false'; - - var classes = 'alert alert-' + $scope.type; - if ($scope.dismissible) - classes += ' alert-dismissible'; - $scope.classes = classes; - } - }; - }); - app.directive('sortBy', ['Store', function(Store) { return { scope: { @@ -179,46 +126,27 @@ }; }]); - app.directive('revolveSelect', function() { + app.directive('bsRadio', function() { return { scope: { - ngModel: '=', - values: '=' + bsRadio: '=', + ngModel: '=' }, - template: '<span ng-bind-html="label" ng-click="next()"></span>', - link: function($scope) { - var hasObjects = false; - if ($scope.values && $scope.values.length) - hasObjects = angular.isObject($scope.values[0]); - - var index = function() { - if (hasObjects) { - for (var i = 0; i < $scope.values.length; i++) { - if ($scope.values[i].value == $scope.ngModel) - return i; - } - return 0; - } else { - return $scope.values.indexOf($scope.ngModel); - } - }; - - var select = function(i) { - if (i < 0 || i >= $scope.values.length) return; - if (hasObjects) { - $scope.ngModel = $scope.values[i].value; - $scope.label = $scope.values[i].label; - } else { - $scope.ngModel = $scope.label = $scope.values[i]; - } + restrict: 'A', + link: function($scope, $elem) { + var setActive = function() { + $elem.parent().children().removeClass("active"); + $elem.addClass("active"); }; - $scope.next = function() { - select((index() + 1) % $scope.values.length); - }; + if ($scope.ngModel === $scope.bsRadio) + setActive(); - $scope.$watch('ngModel', function() { - select(index()); + $elem.click(function() { + $scope.$apply(function() { + $scope.ngModel = $scope.bsRadio; + setActive(); + }); }); } }; diff --git a/vipra-ui/app/js/factories.js b/vipra-ui/app/js/factories.js index b745096610a111a512ce565689efbb72070ce12d..55742067640b97be968a89604692dadabe956ccc 100644 --- a/vipra-ui/app/js/factories.js +++ b/vipra-ui/app/js/factories.js @@ -28,6 +28,10 @@ }); }]); + app.factory('SequenceFactory', ['$resource', function($resource) { + return $resource(Vipra.config.restUrl + '/sequences/:id'); + }]); + app.factory('SearchFactory', ['$resource', function($resource) { return $resource(Vipra.config.restUrl + '/search'); }]); diff --git a/vipra-ui/app/less/app.less b/vipra-ui/app/less/app.less index 3613090040c9e81e772571fb81fba09265b60ceb..b2789ca044a4f67eccf1045b538d7ee4fcd0216d 100644 --- a/vipra-ui/app/less/app.less +++ b/vipra-ui/app/less/app.less @@ -106,7 +106,7 @@ ul.dashed { .graph-legend { position: absolute; - top: 60px; + top: 50px; left: 10px; font-weight: bold; padding: 10px; @@ -287,17 +287,34 @@ revolve-select, [revolve-select] { .explorer { display: flex; flex-direction: row; + flex-wrap: wrap; .sidebar { flex: 0 0 250px; width: 250px; background: #f9f9f9; height: 100%; - padding: 5px 0 5px 5px; + padding: 5px; + + > * + * { + margin-top: 5px; + } + } + + .topbar { + background: #f9f9f9; + width: 100%; + padding: 5px; + vertical-align: middle; } .chart { flex: 1 0 0; + padding: 5px; + } + + .sequence { + flex: 1 0 0; } .topic-choice { @@ -330,6 +347,49 @@ input[type=checkbox], cursor: pointer; } +.radio-inline { + vertical-align: bottom; +} + +.btn-groups { + .btn-group:not(:first-child) { + .btn { + border-top-left-radius: 0; + border-top-right-radius: 0; + } + } + + .btn-group:not(:last-child) { + .btn { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + } + } +} + +.message-container { + position: relative; +} + +.message { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.searchclear { + position: absolute; + right: 5px; + top: 0; + bottom: 0; + height: 14px; + margin: auto; + font-size: 14px; + cursor: pointer; + color: #ccc; +} + @-moz-keyframes spin { 100% { -moz-transform: rotateY(360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotateY(360deg); } } @keyframes spin { 100% { -webkit-transform: rotateY(360deg); transform:rotateY(360deg); } } diff --git a/vipra-ui/bower.json b/vipra-ui/bower.json index c484899bfc46e5503535d8c4ab4646278594e2e6..f45e1e27a253877a749b43b3f68067bbf6d214de 100644 --- a/vipra-ui/bower.json +++ b/vipra-ui/bower.json @@ -28,6 +28,8 @@ "moment": "^2.x", "nya-bootstrap-select": "^2.x", "font-awesome": "^4.x", - "awesome-bootstrap-checkbox": "^0.3.7" + "awesome-bootstrap-checkbox": "^0.3.7", + "angular-bootstrap": "^1.x", + "angular-animate": "^1.5.0" } } diff --git a/vipra-ui/gulpfile.js b/vipra-ui/gulpfile.js index 3cfe64cac2daa164bce78064dfa23023e01ff701..e520fc6108a569b06372ca9480d7d885ce14834e 100644 --- a/vipra-ui/gulpfile.js +++ b/vipra-ui/gulpfile.js @@ -15,9 +15,11 @@ var assets = { 'bower_components/jquery/dist/jquery.min.js', 'bower_components/angular/angular.min.js', 'bower_components/angular-resource/angular-resource.min.js', + 'bower_components/angular-animate/angular-animate.min.js', 'bower_components/angular-sanitize/angular-sanitize.min.js', 'bower_components/angular-ui-router/release/angular-ui-router.min.js', 'bower_components/bootstrap/dist/js/bootstrap.min.js', + //'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js', 'bower_components/highcharts/highcharts.js', 'bower_components/vis/dist/vis.min.js', 'bower_components/moment/min/moment.min.js', diff --git a/vipra-util/src/main/java/de/vipra/util/Constants.java b/vipra-util/src/main/java/de/vipra/util/Constants.java index d245aa3eef31f41056a76a75a4553d1b7447da45..49a56366bbb062c79934803248bee976e4d3bc33 100644 --- a/vipra-util/src/main/java/de/vipra/util/Constants.java +++ b/vipra-util/src/main/java/de/vipra/util/Constants.java @@ -312,7 +312,6 @@ public class Constants { * The topic modeling analyzers available, including the default analyzer. */ public static enum Analyzer { - JGIBB("jgibb"), DTM("dtm"); public final String name; diff --git a/vipra-util/src/main/java/de/vipra/util/model/Sequence.java b/vipra-util/src/main/java/de/vipra/util/model/Sequence.java index 96f9538d1da691221027be1b483a8210b07f5fdf..784f0b233d0db496091040525a561439d7200d69 100644 --- a/vipra-util/src/main/java/de/vipra/util/model/Sequence.java +++ b/vipra-util/src/main/java/de/vipra/util/model/Sequence.java @@ -57,7 +57,7 @@ public class Sequence implements Model<ObjectId>, Comparable<Sequence>, Serializ return relevanceChange; } - public void setRelevanceChange(Double relevanceChange) { + public void setRelevanceChange(final Double relevanceChange) { this.relevanceChange = relevanceChange; } diff --git a/vipra-util/src/main/java/de/vipra/util/model/SequenceFull.java b/vipra-util/src/main/java/de/vipra/util/model/SequenceFull.java index 91b576f8f38cedfc78b9aa32cae51e938d5c3d60..9f43e31d3b53dd95c94c57fe12dc7a7e5a88eaba 100644 --- a/vipra-util/src/main/java/de/vipra/util/model/SequenceFull.java +++ b/vipra-util/src/main/java/de/vipra/util/model/SequenceFull.java @@ -63,7 +63,7 @@ public class SequenceFull implements Model<ObjectId>, Comparable<SequenceFull>, return relevanceChange; } - public void setRelevanceChange(Double relevanceChange) { + public void setRelevanceChange(final Double relevanceChange) { this.relevanceChange = relevanceChange; } diff --git a/vipra-util/src/main/java/de/vipra/util/model/TopicFull.java b/vipra-util/src/main/java/de/vipra/util/model/TopicFull.java index cb1d99dc52c4d37a0794ab498a8568ac53cb47f3..f206b6ade3644ef0d38abb1931931ca6a81bb3a5 100644 --- a/vipra-util/src/main/java/de/vipra/util/model/TopicFull.java +++ b/vipra-util/src/main/java/de/vipra/util/model/TopicFull.java @@ -6,7 +6,6 @@ import java.util.Date; import java.util.List; import org.bson.types.ObjectId; -import org.mongodb.morphia.annotations.Embedded; import org.mongodb.morphia.annotations.Entity; import org.mongodb.morphia.annotations.Id; import org.mongodb.morphia.annotations.PrePersist; @@ -26,10 +25,6 @@ public class TopicFull implements Model<ObjectId>, Serializable { private String name; - @Embedded - @QueryIgnore(multi = true) - private List<TopicWord> words; - @Reference @QueryIgnore(multi = true) private List<Sequence> sequences; @@ -40,8 +35,6 @@ public class TopicFull implements Model<ObjectId>, Serializable { @QueryIgnore(multi = true) private Double varRelevance; - private boolean dynamic = false; - private Date created; private Date modified; @@ -68,14 +61,6 @@ public class TopicFull implements Model<ObjectId>, Serializable { this.name = name; } - public List<TopicWord> getWords() { - return words; - } - - public void setWords(final List<TopicWord> topicWords) { - words = topicWords; - } - public List<Sequence> getSequences() { return sequences; } @@ -100,14 +85,6 @@ public class TopicFull implements Model<ObjectId>, Serializable { this.varRelevance = varRelevance; } - public boolean isDynamic() { - return dynamic; - } - - public void setDynamic(final boolean dynamic) { - this.dynamic = dynamic; - } - public Date getCreated() { return created; } @@ -165,9 +142,8 @@ public class TopicFull implements Model<ObjectId>, Serializable { @Override public String toString() { - return "TopicFull [id=" + id + ", name=" + name + ", words=" + words + ", sequences=" + sequences - + ", avgRelevance=" + avgRelevance + ", varRelevance=" + varRelevance + ", created=" + created - + ", modified=" + modified + "]"; + return "TopicFull [id=" + id + ", name=" + name + ", sequences=" + sequences + ", avgRelevance=" + avgRelevance + + ", varRelevance=" + varRelevance + ", created=" + created + ", modified=" + modified + "]"; } }