Fructose Malabsorption – Applying the Luhn algorithm for text summarization

The Luhn algorithm is a text summarization technique that uses statistical properties of the text to identify and extract the most important sentences from a document. The algorithm was developed by H.P. Luhn in the 1950s, and is still widely used in various forms today.

The Luhn algorithm works by first analyzing the frequency of each word in the document, and then assigning a score to each sentence based on the frequency of the words it contains. Sentences that contain words that are more frequent in the document as a whole are considered to be more important, and are assigned higher scores. The algorithm then selects the top-scoring sentences and concatenates them together to form the summary. The length of the summary is usually determined in advance by the user, and the algorithm selects the most important sentences that fit within that length limit.

It works by identifying the most salient or important sentences in a document based on the frequency of important words and their distribution within each sentence. First, the algorithm removes stopwords, which are common words such as “the”, “and”, and “a” that do not carry much meaning. Additionally, one could apply stemming, which reduces words to their base or root form. For example, “likes” and “liked” are reduced to “like”. Then, the algorithm looks for important words in each sentence. These are typically nouns, verbs, and adjectives that carry the most meaning. The specific method for identifying important words may vary depending on the implementation of the algorithm, but in general, they are selected based on their frequency and relevance to the topic of the text.

The algorithm counts the number of important words in each sentence and divides it by the span, or the distance between the first and last occurrence of an important word. This gives a measure of how densely the important words are distributed within the sentence. Finally, the algorithm ranks the sentences based on their scores, with the highest scoring sentences considered the most important and selected for the summary.

Here are the step-by-step instructions for the Luhn algorithm:

  1. Preprocess the text: Remove any stop words, punctuation, and other non-textual elements from the document, and convert all the remaining words to lowercase.
  2. Calculate the word frequency: Count the number of occurrences of each word in the document, and store this information in a frequency table.
  3. For each sentence, calculate the score by:
    a. Identifying the significant words (excluding stop words) that occur in the sentence.
    b. Ordering the significant words by their position in the sentence.
    c. Determining the distance between adjacent significant words (the “span”).
    d. Calculating a score for the sentence as the sum of the square of the number of significant words divided by the span for each adjacent pair of significant words.
  4. Select the top-scoring sentences: Sort the sentences in the document by their score, and select the top-scoring sentences up to a maximum length L. The length L is typically chosen by the user in advance, and represents the maximum number of words or sentences that the summary can contain.
  5. Generate the summary: Concatenate the selected sentences together to form the summary.

Below I summarize the topic of fructose malabsorption by generating a summary using the Luhn algorithm. To create the summary, I selected several articles from sources like Wikipedia and PubMed. The important words were selected based on their total frequency in all of the text. I chose the top 25 words to focus on, and then used the algorithm to identify the most important sentences based on the frequency and distribution of these words. The summary was generated using the top 15 sentences.

Symptoms and signs of Fructose malabsorption may cause gastrointestinal symptoms such as abdominal pain, bloating, flatulence or diarrhea. Although often assumed to be an acceptable alternative to wheat, spelt flour is not suitable for people with fructose malabsorption, just as it is not appropriate for those with wheat allergies or celiac disease. However, fructose malabsorbers do not need to avoid gluten, as those with celiac disease must. Many fructose malabsorbers can eat breads made from rye and corn flour. This can cause some surprises and pitfalls for fructose malabsorbers. Foods (such as bread) marked “gluten-free” are usually suitable for fructose malabsorbers, though they need to be careful of gluten-free foods that contain dried fruit or high fructose corn syrup or fructose itself in sugar form. Food-labeling Producers of processed food in most or all countries, including the US, are not currently required by law to mark foods containing “fructose in excess of glucose”.

Stone fruit: apricot, nectarine, peach, plum (caution – these fruits contain sorbitol);Berry fruit: blackberry, boysenberry, cranberry, raspberry, strawberry, loganberry; Citrus fruit: kumquat, grapefruit, lemon, lime, mandarin, orange, tangelo; Other fruits: ripe banana, jackfruit, passion fruit, pineapple, rhubarb, tamarillo.

The fructose and glucose contents of foods listed on the Australian food standards would appear to indicate that most of the listed foods have higher fructose levels.

Glucose enhances absorption of fructose, so fructose from foods with fructose-to-glucose ratio <1, like white potatoes, are readily absorbed, whereas foods with fructose-to-glucose ratio >1, like apples and pears, are often problematic regardless of the total amount of fructose in the food.

Foods with high fructose-to-glucose ratio.

Dietary supplements of xylose isomerase may improve some symptoms of fructose malabsorption, although there is currently only a single scientific study available.

This can lead to issues such as bloating, heartburn and constipation.


It is called a hydrogen breath test and is the method currently used for a clinical diagnosis.

People with fructose malabsorption absorb less than 25 g per sitting.

Fructose malabsorption should be considered in patients with symptoms of depression and disturbances of tryptophan metabolism. This prospective cross-sectional study aimed to investigate the potential association between primary-adult lactose malabsorption, fructose malabsorption, tryptophan (TRP) metabolism and the presence of depressive signs.

High intestinal fructose concentration seems to interfere with L-tryptophan metabolism, and it may reduce availability of tryptophan for the biosynthesis of serotonin (5-hydroxytryptamine).

After obtaining the top sentences above, I used them as input into ChatGPT to generate another summary. The summary ended up with some mistakes, such as “People with this condition should avoid foods like spelt flour that contain fructose.“, as spelt does not contain fructose, it contains fructans. But it was still a fun exercise.

Fructose malabsorption can cause gastrointestinal symptoms such as abdominal pain, bloating, flatulence, and diarrhea. People with this condition should avoid foods like spelt flour that contain fructose. However, they do not need to avoid gluten, and many can eat breads made from rye and corn flour. Foods marked “gluten-free” are generally suitable for fructose malabsorbers, but they need to be careful of gluten-free foods that contain dried fruit or high fructose corn syrup. Certain fruits such as apricots, nectarines, peaches, and plums can cause issues due to their sorbitol content. The fructose-to-glucose ratio of foods can also play a role in absorption, with foods with a higher ratio often being problematic. A hydrogen breath test is used for clinical diagnosis, and dietary supplements of xylose isomerase may help with symptoms. Fructose malabsorption may also be associated with depressive signs due to the interference with L-tryptophan metabolism.

Yerba Mate (Ilex Paraguariensis) articles summary using NLP

The following summary was created using a google search for specific phrases and then performing natural language processing steps for sentence scoring. Yerba mate is an evergreen tree/shrub that grows in subtropical regions of South America. The leaves of the plant are used to make tea. Yerba mate tea contains caffeine and theobromine, which are known to affect the mood. I was interested in summarizing the existing articles in regards to research on this plant in psychiatry.

The first search phrase used was “yerba mate psychiatry depression research evidence“, and the number of collected articles for this phrase was 18. The text from all articles was combined, and relative word frequencies were calculated (after removing stop-words). These relative frequencies were then used to score each sentence. Sentence length distribution was checked, and the 90th percentile of 30 words was chosen to select sentences below the maximum length. Below are the 10 highest scoring sentences that summarize the text from the 18 articles.

We can infer from the summary that studies have been performed using the yerba mate extract on rats and tasks for chosen as proxies for the rats’ depression and anxiety levels. There are no mentions of human studies in the summary. Also the chosen sentences indicate that based on these studies, yerba mate has potential antidepressant activity, and it may improve memory as well. The results of the anxiety study were not mentioned and it’s not clear whether there were any side effects from yerba mate. These results are in line with descriptions of personal experiences of reddit users that I have reviewed, as many report better mood and improved focus after drinking yerba mate tea. Some users do report increased anxiety correlated with yerba mate consumption.

View abstract. J Agric.Food Chem. Vitamin C Levels Cerebral vitamin C (ascorbic acid (AA)) levels were determined as described by Jacques-Silva et al. Conclusion: In conclusion, the present study showed that Ilex paraguariensis presents an important effect on reducing immobility time on forced swimming test which could suggest an antidepressant-like effect of this extract. Despite previous some studies show the antidepressant-like activity of flavonoids [31, 32] which are present in the extract of I. paraguariensis, any study has evaluated the possible antidepressant-like activity of it. The presence of nine antioxidants compounds was investigated, namely, gallic acid, chlorogenic acid, caffeic acid, catechin, quercetin, rutin, kaempferol, caffeine, and theobromine. Abstract In this study, we investigated the possible antidepressant-like effect of I. paraguariensis in rats. Another study showed that an infusion of I. paraguariensis can improve the memory of rats treated with haloperidol and this effect was related to an indirect modulation of oxidative stress . In addition to flavonoids as quercetin and rutin and phenolic compounds as chlorogenic and caffeic acids, yerba mate is also rich in caffeine and saponins . After four weeks, behavioral analysis of locomotor activity and anxiety was evaluated in animals receiving water (n = 11) or I. paraguariensis (n = 9). In the same way, we evaluated if the presence of stimulants compounds like caffeine and theobromine in the extract of I. paraguariensis could cause anxiety. In the present study, we evaluated the possible antidepressant-like effect of I. paraguariensis by using forced swimming test (FST) in rats. Forced Swimming Test This experiment was performed using the FST according to the method previously published by Porsolt et al. In this context, Yerba mate (Ilex paraguariensis) is a beverage commonly consumed in South America especially in Argentina, Brazil, Uruguay, and Paraguay. I. paraguariensis reduced the immobility time on forced swimming test without significant changes in locomotor activity in the open field test.

I also tried several other search phrases, such as “yerba mate mood anxiety evidence” and “yerba mate side effects evidence“. In total of 17 articles were collected for the first query and 19 articles for the second query. The summaries are presented below. There was nothing in the summary directly discussing mood or anxiety, but there are mentions of neuroprotective effects and antioxidant effects. We can also learn that a cup of yerba mate tea has similar caffeine content as a cup of coffee, and that drinking yerba mate is not recommended while pregnant or breastfeeding. As in the previous summary, no human trials were mentioned, so it seems that all the summarized studies were performed on rats. The side effects query summary mentions the risk of transferring the caffeine from the tea to the fetus when pregnant, as well as a link to cancer for those who drink both alcohol and yerba mate. It also mentions and anxiety is a side effect of the tea.

Query 1:
View abstract. J Agric.Food Chem. On the other hand, studies conducted on an animal model showed chemopreventive effects of both pure mate saponin fraction and Yerba Mate tea in chemically induced colitis in rats. Yerba Mate Nutrition Facts The following nutrition information is provided by the USDA for one cup (12g) of a branded yerba mate beverage (Mate Revolution) that lists just organic yerba mate as an ingredient. Researchers found that steeping yerba mate (such as in yerba mate tea) may increase the level of absorption. Yerba mate beverages are not recommended for children and women who are pregnant or breastfeeding. Chlorogenic acid and theobromine tested individually also had neuroprotective effects, but slightly weaker than Yerba Mate extract as a whole, but stronger than known neuroprotective compounds, such as caffeine [ 83 ]. The caffeine content in a cup (about 150 mL) of Yerba Mate tea is comparable to that in a cup of coffee and is about 80 mg [ 1 , 11 , 20 ]. In aqueous and alcoholic extracts from green and roasted Yerba Mate, the presence of chlorogenic acid (caffeoylquinic acid), caffeic acid, quinic acid, dicaffeoylquinic acid, and feruloylquinic acid was confirmed. After consumption of Yerba Mate tea, antioxidant compounds are absorbed and appear in the circulating plasma where they exert antioxidant effects [ 55 ]. According to the cited studies, Yerba Mate tea consumption attenuates oxidative stress in patients with type 2 diabetes, which may prevent its complications.

Query 2:
View abstract. J Agric.Food Chem. Because yerba mate has a high concentration of caffeine, drinking mate tea while pregnant can increase the risk of transferring caffeine to the fetus. J Ethnopharmacol. South Med J 1988;81:1092-4.. View abstract. J Am Coll Nutr 2000;19:591-600.. View abstract. Am J Med 2005;118:998-1003.. View abstract. J Psychosom Res 2003;54:191-8.. View abstract. Yerba mate consumed by those who drink alcohol is linked to a higher risk of developing cancer. Anxiety and nervousness are a side effect of excessive yerba mate tea consumption.