jgyasu commited on
Commit
8b20c56
·
verified ·
1 Parent(s): 4b89d6b

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. highlighter.py +0 -44
  2. lcs.py +2 -13
  3. paraphraser.py +1 -1
highlighter.py CHANGED
@@ -38,50 +38,6 @@ def highlight_common_words(common_words, sentences, title):
38
  </div>
39
  '''
40
 
41
- # import re
42
-
43
- # def highlight_common_words_dict(common_words, sentences, title, bg_color):
44
- # color_map = {}
45
- # color_index = 0
46
- # highlighted_html = []
47
-
48
- # for idx, (sentence, score) in enumerate(sentences.items(), start=1):
49
- # sentence_with_idx = f"{idx}. {sentence}"
50
- # highlighted_sentence = sentence_with_idx
51
-
52
- # for index, word in common_words:
53
- # if word not in color_map:
54
- # color_map[word] = f'hsl({color_index * 60 % 360}, 70%, 80%)'
55
- # color_index += 1
56
- # escaped_word = re.escape(word)
57
- # pattern = rf'\b{escaped_word}\b'
58
- # highlighted_sentence = re.sub(
59
- # pattern,
60
- # lambda m, idx=index, color=color_map[word]: (
61
- # f'<span style="background-color: {color}; font-weight: bold;'
62
- # f' padding: 1px 2px; border-radius: 2px; position: relative;">'
63
- # f'<span style="background-color: black; color: white; border-radius: 50%;'
64
- # f' padding: 1px 3px; margin-right: 3px; font-size: 0.8em;">{idx}</span>'
65
- # f'{m.group(0)}'
66
- # f'</span>'
67
- # ),
68
- # highlighted_sentence,
69
- # flags=re.IGNORECASE
70
- # )
71
- # highlighted_html.append(
72
- # f'<div style="margin-bottom: 5px;">'
73
- # f'{highlighted_sentence}'
74
- # f'<div style="display: inline-block; margin-left: 5px; border: 1px solid #ddd; padding: 3px 5px; border-radius: 3px; background-color: white; font-size: 0.9em;">'
75
- # f'Entailment Score: {score}</div></div>'
76
- # )
77
-
78
- # final_html = "<br>".join(highlighted_html)
79
- # return f'''
80
- # <div style="border: solid 1px #; padding: 16px; background-color: {bg_color}; color: #374151; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px;">
81
- # <h3 style="margin-top: 0; font-size: 1em; color: #111827;">{title}</h3>
82
- # <div style="background-color: #F5F5F5; line-height: 1.6; padding: 15px; border-radius: 8px;">{final_html}</div>
83
- # </div>
84
- # '''
85
 
86
  import re
87
 
 
38
  </div>
39
  '''
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  import re
43
 
lcs.py CHANGED
@@ -40,18 +40,7 @@ def find_common_subsequences(sentence, str_list):
40
  return indexed_common_grams
41
 
42
  # Example usage
43
- sentence = "Billie Eilish, Charli XCX and Lorde are among a group of young female pop stars who are revealing, in their music, the pressure they have felt to look thin in a time of especially punishing beauty standards."
44
- str_list = [
45
- 'Young female pop stars, such as Billie Eilish, Charli XCX, and Lorde, are using their music to showcase how they have been subjected to harsh beauty standards in recent times.',
46
- 'A group of young female pop stars, such as Billie Eilish, Charli XCX, and Lorde, are using their music to showcase how they have been subjected to harsh beauty standards in recent times.',
47
- 'The music of a group of young female pop stars, such as Billie Eilish, Charli XCX and Lorde, is revealing the pressure to appear slim in an age where beauty is highly regulated.',
48
- 'Through their songs, young female pop stars like Billie Eilish, Charli XCX and Lordé reveal the pressure they have been subjected to in order to appear attractive in an age of strict beauty standards.',
49
- 'A number of female pop stars, including Billie Eilish, Charli XCx, and Lorde, are using their music to showcase the pressure they have experienced in order not to look unappealing in an age where beauty is highly valued.',
50
- "Some young female pop stars, such as Billie Eilish from the R&B Music Hall of Fame in Las Vegas and Charli XCX from Lorde from Manchester's Outer Banks, are using their music to showcase how they have been subjected to harsh beauty standards",
51
- 'Among the group of young female pop stars who are using their music to showcase their unappealing appearance, are Billié Eilish and Charli XCX while Lorde is currently struggling to maintain her attractive looks.',
52
- 'Young female pop icons such as Billie Eilish, Charliile XCX and Lorde are using their music to showcase the pressure they have been subjected too harshly to look attractive in an age where beauty is highly regulated.',
53
- 'Billie Eilish, Charliile XCX and Lordé are just some of the young female pop stars who have been exposing their looks to music in an age where beauty standards are particularly hard to find.',
54
- 'In the music industry, young female pop stars like Billie Eilish and Charliile XCx (with an average height of 160cm), as well as Lorde, are displaying how they have been subjected to harsh beauty standards.'
55
- ]
56
 
57
  print(find_common_subsequences(sentence, str_list))
 
40
  return indexed_common_grams
41
 
42
  # Example usage
43
+ sentence = "Kim Beom-su, the billionaire behind the South Korean technology giant Kakao, was taken into custody on allegations of stock manipulation during a bidding war over one of the country’s largest K-pop agencies."
44
+ str_list = ["The founder of South Korean technology company Kakao, billionaire Kim Beom-su, was arrested on charges of stock fraud during a bidding war for one of North Korea's biggest K-pop companies.", "In a bidding war for one of South Korea's largest K-pop agencies, Kim Beom-su, the billionaire who owns Kakao, was arrested on charges of manipulating stocks.", "During a bidding war for one of South Korea's biggest K-pop agencies, Kim Beom-su, the billionaire who owns Kakao, was arrested on charges of manipulating stocks.", "Kim Beom-su, the founder of South Korean technology giant Kakao's billionaire investor status, was arrested on charges of stock fraud during a bidding war for one of North Korea'S top K-pop agencies.", "A bidding war over one of South Korea's biggest K-pop agencies led to the arrest and apprehension charges of Kim Beom-Su, the billionaire who owns the technology giant Kakao.", "The billionaire who owns South Korean technology giant Kakao, Kim Beom-Su, was taken into custody for allegedly engaging in stock trading during a bidding war for one of North Korea's biggest K-pop media groups.", "Accused of stockpiling during a bidding war for one of South Korea's biggest K-pop agencies, Kim Beom-Su, the founder and owner of technology firm known as Kakao, was arrested on charges of manipulating stocks.", 'Kakao, the South Korean technology giant, was involved in a bidding war with Kim Beon-su, its founder, who was arrested on charges of manipulating stocks.', "South Korea's Kakao corporation'entrepreneur husband, Kim Beom-su (pictured), was arrested on suspicion of stock fraud during a bidding war for one of the country'S top K-pop companies.", 'Kim Beom-su, the billionaire who own a South Korean technology company called Kakaof, was arrested on charges of manipulating stocks in an ongoing bidding war over one million shares.']
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  print(find_common_subsequences(sentence, str_list))
paraphraser.py CHANGED
@@ -28,4 +28,4 @@ def generate_paraphrase(question):
28
  res = paraphrase(question, para_tokenizer, para_model)
29
  return res
30
 
31
- print(generate_paraphrase("Billie Eilish, Charli XCX and Lorde are among a group of young female pop stars who are revealing, in their music, the pressure they have felt to look thin in a time of especially punishing beauty standards."))
 
28
  res = paraphrase(question, para_tokenizer, para_model)
29
  return res
30
 
31
+ print(generate_paraphrase("Kim Beom-su, the billionaire behind the South Korean technology giant Kakao, was taken into custody on allegations of stock manipulation during a bidding war over one of the country’s largest K-pop agencies."))