Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:43:56+00:00 2026-06-11T04:43:56+00:00

I have table : ========================================================================= | id | stem_before | stem_after | stem_freq |

  • 0

I have table :

=========================================================================
| id | stem_before | stem_after | stem_freq | sentence_id | document_id | 
=========================================================================
|  1 |     a       |     b      |    1      |   0         |       1     |    
|  2 |     c       |     d      |    1      |   0         |       1     |        
|  3 |     e       |     f      |    1      |   1         |       1     |
|  4 |     g       |     h      |    1      |   2         |       1     |
|  5 |     i       |     j      |    2      |   0         |       2     |
|  6 |     k       |     l      |    1      |   0         |       2     |
=========================================================================

I want to count in 2 steps :
step one is divide 1 with the sum the value of stem_freq in every sentence_id and document_id. step two is multiplication the result of the first step with the value of stem_freq

for example :

for data with document_id = 1 and sentence_id = 0, first step: 1/(1+1) = 0.5, second step for id = 1 is 1*0.5 = 0.5. for id = 2 is 1*0.5 = 0.5.

for data with document_id = 2 and sentence_id = 0, first step: 1/(2+1) = 0.3333, second step for id = 5 is 2*0.3333 = 0.6666, for id = 6 is 1*0.3333 = 0.3333.

here’s my code :

$query = mysql_query ("SELECT sentence_id, document_id, stem_after, 
stem_freq,SUM(stem_freq) as freq 
FROM tb_stemming 
WHERE document_id ='$doc_id' 
GROUP BY(sentence_id)");

while ($row = mysql_fetch_array($query)) {
   $a    = $row['freq'];
   $freq = $row['stem_freq'];
   $tf   = $freq/$a;
}

but it only gives me result of the first data in every different sentence : can you help me. thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:43:58+00:00Added an answer on June 11, 2026 at 4:43 am

    Try this:

    SELECT
        a.*, 
        a.stem_freq * b.value
    FROM
        tb_stemming as a
        JOIN 
        (
            SELECT
                document_id,
                sentence_id,
                1 / sum(stem_freq) 'value'
            FROM
                tb_stemming
            GROUP BY document_id, sentence_id
        ) as b
        ON a.document_id = b.document_id AND a.sentence_id = b.sentence_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed one table having 3 comlumns and 10 rows, Now to insert
I have table defined with FlexiGrid. Call to all variables is ok. One column
I have table Owner in my database where one of the field (System) saved
I have table of over 4 million rows and accidentally in one column there
I have table cells with attributes data-position-x and data-position-y with integer values. I want
I have table in mysql with MyISAM storage engine. I want to create partition
i have table with below structure: <table class=cedvel> <caption> count: <%:Html.Encode(TempData[RowsCount])%></caption> <thead> <tr> <th
I have table, and I want check/uncheckcheck box not only by clicking on checkbox,
I have table that I want to remain dynamic meaning that I don't want
i have table with 2 columns: date and points. I want to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.