Gossamer Forum
Home : Products : DBMan : Customization :

list of field

(Page 2 of 3)
> > > >
Quote Reply
Re: list of field In reply to
I don't think you need to go through all that to do what you want, Don. You don't require all the stuff that's in the "browse categories" mod.

Let's take it from the top.

Code:
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
@lines = <DB>;
close DB;

$fieldnum = 6; change this to match your Year_Graduated field number

foreach $line (@lines) {
@data = &split_decode($line);
++$count{$data[$fieldnum]};
}

$i = 1;
foreach $gyear (sort {$count{$b} <=> $count{$a} } keys %count) {
if ($i>5) { last; }
print "$gyear: ($count{$gyear})<BR>";
++$i;
}

I tested this out and it seems to work.

Stephane, I'm afraid I'm not familiar with Isis, so I can't tell you if DBMan will give you something similar. Can you give me an example of what you want?



------------------
JPD







[This message has been edited by JPDeni (edited September 21, 1999).]
Quote Reply
Re: list of field In reply to
Carol - do you have any input on how I can get this to display in descending order?

Years (field: Year_Graduated) that have the most records listed first and then descending from there.

Thanks!
--------------
donm
Quote Reply
Re: list of field In reply to
Carol - I assumed that the code you supplied above replaced the "browse category" mod.

I replaced the code and now it does not work at all?

So - I know I missed something somewhere.

Could you tell me where I should place this code?

Ooooops nevermind JPD - I figured it out !

Thanks again !
---------------
donm

[This message has been edited by donm (edited September 21, 1999).]
Quote Reply
Re: list of field In reply to
Hello,
A link to an database ISIS with indices :

http://www.africa.u-bordeaux.fr/cgi-bin/wwwisis/[in=/usr/local/etc/isis/interro.in]/

click on "Pays auteurs" link

Stéphane

------------------

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
Hello / Bonjour
Another question : Now, I want to create a list with some words of field. For example, all the words of a summary except "the" "a" "with".

Any ideas?

bye,

Stéphane

------------------

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
Thank you for the information about Isis. I checked out what you suggested and it seems that it was just a select list based on the values of a field. Is that what you want?

Quote:
Now, I want to create a list with some words of field. For example, all the words of a summary except "the" "a" "with".

I'm not quite sure I understand. Do you want to catalog the words in a paragraph? For example, if I used the quoted paragraph above, I come up with:

all
create
example
except
field
for
i
list
now
of
some
summary
to
want
words

Is this what you want?


------------------
JPD





Quote Reply
Re: list of field In reply to
Re,
yes, exactly.

Have you any ideas ?





------------------

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
Re,
AND I want to exclude the words like : "a" "the" "all".

Stephane



------------------

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
For a select field that contains the list of values for a certain field, you would use

Code:
print &build_select_field_from_db("fieldname",$rec{'fieldname'});

As for the list of words, I'm not sure where you would put it, but I think I can figure out the code for it.

I'm also not sure how you're getting the text. Would you be going through the entire database and picking up the words from a specific field from each record?

For the time being, I'll just refer to the text as $text. This would be the general code that you would use:

Code:
# list all the words you don't want to include in the line below
@not_included = qw(a the an and with all);

# remove all puncutation
$text =~ s/[,!"]//g;

# change the text to lower case
$text = lc($text);

# put all the words into an array
@words = split(/ /,$text);

# put unique words into a master array, ignoring those that are not included
foreach $word (@words) {
if (!(grep $_ eq $word, @not_included)) {
if (!(grep $_ eq $word, @summary)) {
push (@summary, $word);
}
}
}

You will end up with an array called @summary that lists all the unique words in the $text variable, excluding those that were defined in the @not_included array.

I have tested the above code and it seems to work.


------------------
JPD





Quote Reply
Re: list of field In reply to
Re,
ok, where to put the code ?

Stephane

Quote Reply
Re: list of field In reply to
Re,
Well, the text is an summary of a dbman field. (like "Description" in your dbman online example).

Stéphane
Quote Reply
Re: list of field In reply to
Okay. That's a start.

Do you want this to be a compilation of all the text in all records for that field? Do you want this to be a select list on a search form? I really don't know what you're trying to do.


------------------
JPD





Quote Reply
Re: list of field In reply to
Re,
Yes,I want a compilation of all the text (except the words "the "a" etc) in all records for that field.

:-)thanks for your patience :-)

Stéphane




------------------

Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706
Quote Reply
Re: list of field In reply to
One more piece to the puzzle. Smile

What do you want to do with the list after it's made? Are you creating a text file? Do you want to make a select list? I can't give you any more code until I know what you are going to use it for.


------------------
JPD





Quote Reply
Re: list of field In reply to
Re,
I want to create a select list (with links to the records)

Stéphane
Quote Reply
Re: list of field In reply to
I don't think that can be done.

What can be done is to create a select list of the words and then do a search on that field for the word that is selected.

I'm going to assume that's what you want to do.

Create a new subroutine in db.cgi:

Code:
sub build_select_field_from_words {
#-------------------------------

my ($column, $value) = @_;

for ($i = 0; $i <= $#db_cols; $i++) {
if ($column eq $db_cols[$i]) {
$fieldnum = $i; $found = 1;
last;
}
}

if (!$found) {
return "error building select field: no fields specified!";
}

open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
$text = $fields[$fieldnum];

@not_included = qw(a the an and with all);
$text =~ s/[,!"]//g;
$text = lc($text);
@words = split(/ /,$text);
foreach $word (@words) {
if (!(grep $_ eq $word, @not_included)) {
if (!(grep $_ eq $word, @summary)) {
push (@summary, $word);
}
}
}
}

close DB;

$output = qq|<SELECT NAME="$name"><OPTION>---|;
foreach $field (sort @summary) {
($field eq $value) ?
($output .= "<OPTION SELECTED>$field") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";

return $output;
}

To print out the select field, use

Code:
print &build_select_field_from_words("fieldname",$rec{'fieldname'});

That's the best I can do.

------------------
JPD





Quote Reply
Re: list of field In reply to
Bonjour / Hello,
Ok, I try this way.

Thanks !

Stéphane

PS : sorry for my poor english ;-)
Quote Reply
Re: list of field In reply to
Re,
I paste this line in html.pl ?

print &build_select_field_from_words("fieldname",$rec{'fieldname'});

Stéphane
Quote Reply
Re: list of field In reply to
Yes. You would use that line wherever you want your select list to print out. It would be somewhere in html_record_form.


------------------
JPD





Quote Reply
Re: list of field In reply to
ok,
thanks...i try this...

Stéphane...

Quote Reply
Re: list of field In reply to
Re,
All right ! It is excalty what i want.
Thanks...

next...

Stéphane
Quote Reply
Re: list of field In reply to
the result :

http://www-sira.montaigne.u-bordeaux.fr/_intranet_/cgi-lib/stephane.x/

best
Quote Reply
Re: list of field In reply to
I'm not sure whether it works or not. I know absolutely no French (well, I know "merci," but that's as far as my education goes). Did it work for you?


------------------
JPD





Quote Reply
Re: list of field In reply to
Hi,
Yes, it works perfectly for me. no problem.
just a question : are you a developer from Gossamer ?

Thanks you for all

Stephane ;-)



Quote Reply
Re: list of field In reply to
I'm glad it worked for you.

No, I'm not from Gossamer Threads. I just like the DBMan script and I enjoy helping people. Smile


------------------
JPD





> > > >