[LON-CAPA-cvs] cvs: loncom /localize/localize checksimilar_2files.pl

bisitz bisitz at source.lon-capa.org
Tue Jan 22 12:18:06 EST 2013


bisitz		Tue Jan 22 17:18:06 2013 EDT

  Modified files:              
    /loncom/localize/localize	checksimilar_2files.pl 
  Log:
  - Improve code of similar phrases check
  - Add "authoring" (-> "Authoring Space" vs. "Construction Space")
  
  
Index: loncom/localize/localize/checksimilar_2files.pl
diff -u loncom/localize/localize/checksimilar_2files.pl:1.4 loncom/localize/localize/checksimilar_2files.pl:1.5
--- loncom/localize/localize/checksimilar_2files.pl:1.4	Thu Jan 10 18:07:52 2013
+++ loncom/localize/localize/checksimilar_2files.pl	Tue Jan 22 17:18:05 2013
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # The LearningOnline Network with CAPA
-# $Id: checksimilar_2files.pl,v 1.4 2013/01/10 18:07:52 bisitz Exp $
+# $Id: checksimilar_2files.pl,v 1.5 2013/01/22 17:18:05 bisitz Exp $
 
 use strict;
 use warnings;
@@ -49,21 +49,22 @@
     my $text1 = shift;
     my $text2 = shift;
     
-    $text1 =~ s/courses/X001X/gi;
-    $text1 =~ s/communities/X001X/gi;    
-    $text1 =~ s/course/X002X/gi;
-    $text1 =~ s/community/X002X/gi;
-    $text1 =~ s/member/X003X/gi;
-    $text1 =~ s/student/X003X/gi;
-    $text1 =~ s/students/X003X/gi;
-
-    $text2 =~ s/courses/X001X/gi;
-    $text2 =~ s/communities/X001X/gi;
-    $text2 =~ s/course/X002X/gi;
-    $text2 =~ s/community/X002X/gi;
-    $text2 =~ s/member/X003X/gi;
-    $text2 =~ s/student/X003X/gi;
-    $text2 =~ s/students/X003X/gi;
+    my %phrases = (
+        'courses'     => 1,
+        'communities' => 1,
+        'course'      => 2,
+        'community'   => 2,
+        'member'      => 3,
+        'student'     => 3,
+        'students'    => 3,
+        'construction'=> 4,
+        'authoring'   => 4,
+    );
+
+    foreach my $word (keys %phrases) {
+        $text1 =~ s/$phrase/X$phrases{$word}X/gi;
+        $text2 =~ s/$phrase/X$phrases{$word}X/gi;
+    }
 
     if (lc($text1) eq lc($text2)) {
         return 1;




More information about the LON-CAPA-cvs mailing list