morgankavanagh commited on
Commit
4be79fa
·
1 Parent(s): 82bc5cb

added updates for new api

Browse files
evaluator/comet.py CHANGED
@@ -1,5 +1,9 @@
 
1
  from comet import download_model, load_from_checkpoint
2
 
 
 
 
3
  def calculate_comet(source_sentences, translations, references):
4
  """
5
  Calculate COMET scores for a list of translations.
@@ -9,7 +13,7 @@ def calculate_comet(source_sentences, translations, references):
9
  :return: List of COMET scores (one score per sentence pair).
10
  """
11
  # Download and load the COMET model
12
- model_path = download_model("Unbabel/wmt20-comet-da")
13
  model = load_from_checkpoint(model_path)
14
 
15
  # Prepare data for COMET
 
1
+ import os
2
  from comet import download_model, load_from_checkpoint
3
 
4
+ # Set a custom cache directory for COMET
5
+ os.environ["COMET_CACHE"] = "/tmp"
6
+
7
  def calculate_comet(source_sentences, translations, references):
8
  """
9
  Calculate COMET scores for a list of translations.
 
13
  :return: List of COMET scores (one score per sentence pair).
14
  """
15
  # Download and load the COMET model
16
+ model_path = download_model("Unbabel/wmt22-comet-da") # Use a supported model
17
  model = load_from_checkpoint(model_path)
18
 
19
  # Prepare data for COMET
evaluator/mt_data/beam_search_translations.txt CHANGED
@@ -1,20 +1,4 @@
1
- The merchandise cost less than 20 euros.
2
- The fee corresponds to 40% of the value of the goods....
3
- I am # PRS _ ORG # major customer so it is no problem for me.
4
- All I need is a number or an instruction on what I should put in the package so that it can be tracked by you as a return.
5
- I ordered the # PRS _ ORG # a few days ago... for 249 €.
6
- Today it costs €179.
7
- To be honest, I find that very annoying.
8
- Do I have to cancel the order and re-order for the better price or is there another way of credit?
9
- In principle, I also think that children should not be expected to take on the role of parents for their young siblings.
10
- However, I think it is also good for big siblings to take care of the little ones in moderation.
11
- Take a quick look, help a little, bring the bottle, etc.
12
- In this way they learn responsibility, help in the family and are involved.
13
- As long as they can still be children themselves, I don't see a problem with that.
14
- If your K1 occupies itself for the short time and it is OK for it, that is good.
15
- You can judge for yourself whether this is right for your children.
16
- It's not as if he's supposed to be wrapping K2 and going to sleep for hours on end.
17
- Legally, it is probably questionable.
18
- Perhaps this is where the psychologist comes in.
19
- Because if something should actually happen like a fire, burglary, earthquake, alien invasion etc., it would actually be too much of a responsibility for K1 to take care of K2.
20
- Whether this is a risk you want to take is of course up to you;)
 
1
+ The protection of individuals with regard to the processing of personal data is a fundamental right.
2
+ In accordance with Article 8(1) of the Charter of Fundamental Rights of the European Union ('the Charter') and Article 16(1) of the Treaty on the Functioning of the European Union (TFEU), everyone has the right to the protection of personal data concerning him or her.
3
+ (2) The principles and rules on the protection of natural persons with regard to the processing of their personal data should ensure that their fundamental rights and freedoms, and in particular their right to the protection of personal data, are respected, whatever their nationality or place of residence.
4
+ This Regulation should contribute to the completion of an area of freedom, security and justice and of an economic union, to economic and social progress, to the strengthening and integration of economies within the internal market and to the well-being of natural persons.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
evaluator/mt_data/reference_translations.txt CHANGED
@@ -1,20 +1,4 @@
1
- The goods cost less than 20 euros.
2
- The fee would equal 40% of the value of the goods...
3
- I am #PRS_ORG# a serious customer and that is why it is not a problem for me.
4
- I just need a number or a instructions what I should attach to the package so that it can be traced by you all as a return.
5
- I ordered the #PRS_ORG# a few days ago...for €249.
6
- Now it costs €179.
7
- That really bothers me, I must say.
8
- Do I need to cancel the order and reorder for the better price, or is there another way of getting the credit?
9
- I also think that as a general rule, children should not be expected to overtake a parental role for their younger siblings.
10
- However, I think it is also good for older siblings to care for the younger ones to some degree.
11
- Sometimes check-up on them, sometimes help, sometimes get the bottle, etc.
12
- They learn responsibility this way, help within the family and are thus connected with it.
13
- As long as they can continue to be a kid themselves, I don’t see the problem.
14
- If your first child looks after themselves alone for a short amount of time, that is OK, that is actually good.
15
- You can best get a sense of whether or not this works for your children.
16
- It is not as if they should change the second child’s diaper and sit for hours by them as they fall asleep.
17
- It is probably questionable from a strictly legal perspective.
18
- Maybe the psychologist would also have something to say about it.
19
- Since if something actually does happen, like a fire, break-in, earthquake, alien invasion, etc., it would be too much responsibility for child 1 to take care of child 2.
20
- If that is a risk that you would like to take that is up to you, of course ;)
 
1
+ (1) The protection of natural persons in relation to the processing of personal data is a fundamental right.
2
+ Article 8(1) of the Charter of Fundamental Rights of the European Union (the ‘Charter’) and Article 16(1) of the Treaty on the Functioning of the European Union (TFEU) provide that everyone has the right to the protection of personal data concerning him or her.
3
+ (2) The principles of, and rules on the protection of natural persons with regard to the processing of their personal data should, whatever their nationality or residence, respect their fundamental rights and freedoms, in particular their right to the protection of personal data.
4
+ This Regulation is intended to contribute to the accomplishment of an area of freedom, security and justice and of an economic union, to economic and social progress, to the strengthening and the convergence of the economies within the internal market, and to the well-being of natural persons.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
evaluator/mt_data/source_sentences.txt CHANGED
@@ -1,20 +1,4 @@
1
- Die Ware hat unter 20 Euro gekostet.
2
- Die Gebühr entspricht 40% des Warenwertest....
3
- Ich bin #PRS_ORG# Großkunde und somit ist es kein Problem für mich.
4
- Brauche lediglich eine Nummer oder Anweisung was ich den Paket beilegen sollte damit es von Ihnen als Retoure getrackt werden kann.
5
- Ich habe vor ein paar Tagen die #PRS_ORG# bestellt... für 249€.
6
- Heute kostet sie 179€.
7
- Das finde ich ehrlich gesagt sehr ärgerlich.
8
- Muss ich die Bestellung stornieren und neu bestellen für den besseren Preis oder gibt es eine andere Möglichkeit der Gutschrift?
9
- Ich finde grundsätzlich auch, dass man Kindern nicht zumuten sollte, eine Elternrolle für ihre kleinen Geschwister zu übernehmen.
10
- Allerdings finde ich, tut es großen Geschwistern auch gut, sich in Maßen mit um die Kleinen zu kümmern.
11
- Mal kurz gucken, mal kurz helfen, mal die Flasche bringen etc.
12
- So lernen sie Verantwortung, helfen in der Familie mit und sind mit eingebunden.
13
- Solange sie noch selbst genug Kind sein können, sehe ich da kein Problem.
14
- Wenn dein K1 sich für die kurze Zeit allein beschäftigt und es für ihn OK ist, ist das doch gut.
15
- Du kannst selbst am besten ermessen, ob das für deine Kinder passt.
16
- Es ist ja nicht so, dass er K2 wickeln und stundenlang beim Einschlafen begleiten soll.
17
- Rein rechtlich ist es wahrscheinlich fragwürdig.
18
- Vielleicht kommt daher auch die Aussage der Psychologin.
19
- Denn falls tatsächlich etwas passieren sollte wie ein Brand, Einbruch, Erdbeben, Alieninvasion etc. wäre es tatsächlich zu viel Verantwortung für K1, sich um K2 zu kümmern.
20
- Ob das nun ein Risiko ist, das du eingehen willst, ist natürlich dein Ermessen ;)
 
1
+ (1) Der Schutz natürlicher Personen bei der Verarbeitung personenbezogener Daten ist ein Grundrecht.
2
+ Gemäß Artikel 8 Absatz 1 der Charta der Grundrechte der Europäischen Union (im Folgenden „Charta“) sowie Artikel 16 Absatz 1 des Vertrags über die Arbeitsweise der Europäischen Union (AEUV) hat jede Person das Recht auf Schutz der sie betreffenden personenbezogenen Daten.
3
+ (2) Die Grundsätze und Vorschriften zum Schutz natürlicher Personen bei der Verarbeitung ihrer personenbezogenen Daten sollten gewährleisten, dass ihre Grundrechte und Grundfreiheiten und insbesondere ihr Recht auf Schutz personenbezogener Daten ungeachtet ihrer Staatsangehörigkeit oder ihres Aufenthaltsorts gewahrt bleiben.
4
+ Diese Verordnung soll zur Vollendung eines Raums der Freiheit, der Sicherheit und des Rechts und einer Wirtschaftsunion, zum wirtschaftlichen und sozialen Fortschritt, zur Stärkung und zum Zusammenwachsen der Volkswirtschaften innerhalb des Binnenmarkts sowie zum Wohlergehen natürlicher Personen beitragen.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -4,5 +4,5 @@ numpy
4
  pytest
5
  gradio
6
  requests
7
- unbabel-comet
8
  pathlib
 
4
  pytest
5
  gradio
6
  requests
7
+ unbabel-comet>=2.0.0
8
  pathlib
tests.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ OPENAI_API_URL = "https://api.openai.com/v1/chat/completions"
4
+ OPENAI_API_KEY = "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"
5
+
6
+ headers = {
7
+ "Authorization": f"Bearer {OPENAI_API_KEY}",
8
+ "Content-Type": "application/json"
9
+ }
10
+
11
+ payload = {
12
+ "model": "gpt-4",
13
+ "messages": [{"role": "user", "content": "Hello, world!"}],
14
+ "temperature": 0.7
15
+ }
16
+
17
+ response = requests.post(OPENAI_API_URL, headers=headers, json=payload)
18
+ print(response.status_code, response.json())