<%args> $lang => undef $word => undef $notes => undef $meaning => undef $oncethrough => undef $valid => undef $stfu => undef <%init> our(%session,$dbh); use String::Approx 'amatch'; <%shared> our $titlestr; <%method title> <% $titlestr %> % unless(defined($session{'username'})) { Not logged in
Sorry, you've got to be logged in to add words. % $titlestr = "Not logged in"; % return; % } % unless(defined($lang)) { Must specify a language
A language hasn't been specified. % $titlestr = "Must specify a language"; % return; % } <%perl> if( ! defined( $stfu ) ) { Adding natural language word to language <% $dbh->selectrow_array("SELECT realname FROM languages WHERE tag=?", undef, $lang) %>
<%perl> } % unless(defined($valid)) { <%perl> $titlestr = "Adding natural language word"; my($realword,$realmeaning); if(defined $word) { $word =~ s/^\s+//g; $word =~ s/\s+$//g; $realword = $word; $word =~ s/(")/sprintf("&#%i;",ord($1))/ge; } if(defined $meaning) { $meaning =~ s/^\s+//g; $meaning =~ s/\s+$//g; $realmeaning = $meaning; $meaning =~ s/(")/sprintf("&#%i;",ord($1))/ge; }

Important: Make sure you understand what sort of data should be fed into this by reading the help section on natural language words.

PLEASE remember to vote for your new word, otherwise wiki links and Best Guesses listings will be guaranteed to *not* include it.

"Word"
Meaning
Notes May include links to lojban valsi using {}.
% if(length($word) && !defined($oncethrough)) { % } % my @tmp = split("!#!@!", $oncethrough, 3); % if(length($word) && defined($meaning) && defined($notes) && % ($realword eq $tmp[0]) && ($realmeaning eq $tmp[1]) && ($notes eq % $tmp[2]) ) { % }
% if(defined($oncethrough)) {

Submitting once more without changing the form content will add the word to the database! Are you sure you want to do that?

<%perl> my $langid = $dbh->selectrow_array("SELECT langid FROM languages WHERE tag=?", undef, $lang); my $words = $dbh->selectall_arrayref( "SELECT word, wordid FROM natlangwords WHERE wordid > 0 AND langid = $langid AND length(?)-2<=length(word) AND length(?)+2>=length(word) ", undef, $word, $word ); if( $words ) { my @mywords = map { $_->[0].":".$_->[1] } @{ $words }; my @matches; # If lang has any words at all... if( $#mywords > 0 ) { @matches = amatch( $word, [ "20%" ], @mywords ); } if( scalar( @matches ) ) {

Check These Words!

The following words seem similar to the one you entered. Please check that none of them will work for you:

% }

You have to repeatedly (two to four times, depending on whether or not you followed a link to this page, or pulled it up and hand entered the data) submit this form without changing the values in it. You'll be notified when the word has actually been added.

Yes, the excessive amount of submission is rather ridiculous. Something doesn't work quite right. I'm going to get around to fixing it sooner or later.

<%perl> } else { $titlestr = "Storing new natural language word";

Here we go...

<%perl> my $ok = 1; my $langid = $dbh->selectrow_array("SELECT langid FROM languages WHERE tag=?", undef, $lang); my $query = $dbh->prepare("SELECT * FROM natlangwords WHERE word=? AND langid=$langid"); $query->execute($word); $meaning =~ s/^\s+//g; $meaning =~ s/\s+$//g; while (defined(my $row = $query->fetchrow_hashref) && $ok ) { if (length($meaning) == 0) {

Please Read!

This word is already defined, but you are trying to add a definition with a default meaning (i.e. you put nothing in the "in the sense of" box).

The problem here is that the existence of a default meaning implies that no differentiation from that meaning is reasonable. Since another definition exists, this is patently false.

Please go look at other definitions for this word, and see if any of them work for you.

If not, you're just going to have to go back and narrow the sense of the word.

<%perl> $ok = 0; } elsif ($row->{'meaning'} eq $meaning ) { $m->out("

This word already exists with this same meaning...

"); $ok = 0; } } if($ok) { my $meaningNum = $dbh->selectrow_array("SELECT max(meaningNum) + 1 FROM natlangwords WHERE word=?\n", undef, $word); if (! defined($meaningNum)) { $meaningNum=1 } if(length($meaning)) { $dbh->do("INSERT INTO natlangwords (langid, word, meaning, notes, meaningNum, userid, time ) VALUES ((SELECT langid FROM languages WHERE tag=?), ?, ?, ?, ?, ?, ?)", undef, $lang, $word, $meaning, $notes, $meaningNum, $session{'userid'}, time() ); } else { $dbh->do("INSERT INTO natlangwords (langid, word, meaning, notes, meaningNum, userid, time ) VALUES ((SELECT langid FROM languages WHERE tag=?), ?, null, ?, ?, ?, ?)", undef, $lang, $word, $notes, $meaningNum, $session{'userid'}, time() ); } # Send e-mail to the word creator(s) my @email; push @email, $dbh->selectrow_array("SELECT u.email FROM natlangwords nlw, users u WHERE nlw.userid = u.userid AND nlw.word=? AND nlw.langid = ?", undef, $word, $langid ); # Get language info my $langtag = $dbh->selectrow_array("SELECT tag FROM languages WHERE langid = ?", undef, $langid); my $langname = $dbh->selectrow_array("SELECT realname FROM languages WHERE langid = ?", undef, $langid); @email = keys %{{ map { $_ => 1 } @email }}; utils::sendemail( \@email, "New NatLang Word $word", " In jbovlaste, the user $session{'username'} has added the following natural language word: Word: $word In Sense: $meaning Notes: $notes In Language: $langname You can go to to see it. ", $session{'username'} ); } if ($ok) {

No errors? Excellent.

<%perl> if( ! defined( $stfu ) ) {

Go to the page for the word you added.

<%perl> } else {

Go to the page for the word you added.

<%perl> } } else {

We were unable to add the new word.

<%perl> } }