text2model 0.1.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. text2model-1.1.0/LICENSE +201 -0
  2. text2model-1.1.0/PKG-INFO +287 -0
  3. text2model-1.1.0/README.md +267 -0
  4. {text2model-0.1.0 → text2model-1.1.0}/pyproject.toml +6 -6
  5. {text2model-0.1.0 → text2model-1.1.0}/tests/test_integration.py +53 -0
  6. text2model-1.1.0/text2model/editor/__init__.py +10 -0
  7. text2model-1.1.0/text2model/editor/app.py +1246 -0
  8. text2model-1.1.0/text2model/editor/data/text2zinc.csv +64680 -0
  9. text2model-1.1.0/text2model/generate_knowledge_graph.py +110 -0
  10. {text2model-0.1.0 → text2model-1.1.0}/text2model/main.py +84 -31
  11. {text2model-0.1.0 → text2model-1.1.0}/text2model/utils.py +41 -0
  12. text2model-1.1.0/text2model.egg-info/PKG-INFO +287 -0
  13. {text2model-0.1.0 → text2model-1.1.0}/text2model.egg-info/SOURCES.txt +5 -0
  14. {text2model-0.1.0 → text2model-1.1.0}/text2model.egg-info/requires.txt +1 -2
  15. text2model-0.1.0/PKG-INFO +0 -221
  16. text2model-0.1.0/README.md +0 -203
  17. text2model-0.1.0/text2model.egg-info/PKG-INFO +0 -221
  18. {text2model-0.1.0 → text2model-1.1.0}/setup.cfg +0 -0
  19. {text2model-0.1.0 → text2model-1.1.0}/tests/test_main.py +0 -0
  20. {text2model-0.1.0 → text2model-1.1.0}/tests/test_utils.py +0 -0
  21. {text2model-0.1.0 → text2model-1.1.0}/text2model/__init__.py +0 -0
  22. {text2model-0.1.0 → text2model-1.1.0}/text2model/grammar.mzn +0 -0
  23. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_12.ttl +0 -0
  24. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_14.ttl +0 -0
  25. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_2.ttl +0 -0
  26. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_22.ttl +0 -0
  27. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_28.ttl +0 -0
  28. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_30.ttl +0 -0
  29. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_34.ttl +0 -0
  30. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_39.ttl +0 -0
  31. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_54.ttl +0 -0
  32. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_6.ttl +0 -0
  33. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/CSPLib_8.ttl +0 -0
  34. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/LPWP_128.ttl +0 -0
  35. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/LPWP_232.ttl +0 -0
  36. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/LPWP_53.ttl +0 -0
  37. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/LPWP_66.ttl +0 -0
  38. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/LPWP_85.ttl +0 -0
  39. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_1.ttl +0 -0
  40. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_18.ttl +0 -0
  41. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_2.ttl +0 -0
  42. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_28.ttl +0 -0
  43. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_31.ttl +0 -0
  44. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_4.ttl +0 -0
  45. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_5.ttl +0 -0
  46. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_6.ttl +0 -0
  47. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/OR_LP_IP_Scheduling_problem_8.ttl +0 -0
  48. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/combinatorial_problem_1.ttl +0 -0
  49. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/combinatorial_problem_31.ttl +0 -0
  50. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/combinatorial_problem_32.ttl +0 -0
  51. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/combinatorial_problem_7.ttl +0 -0
  52. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_AircraftAssignment.ttl +0 -0
  53. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_AircraftLanding.ttl +0 -0
  54. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_CFLP.ttl +0 -0
  55. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_CapacitatedWarehouseLocation.ttl +0 -0
  56. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_CarSelection.ttl +0 -0
  57. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_TSP.ttl +0 -0
  58. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/complexor_VRPTW.ttl +0 -0
  59. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_1.ttl +0 -0
  60. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_10.ttl +0 -0
  61. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_11.ttl +0 -0
  62. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_12.ttl +0 -0
  63. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_13.ttl +0 -0
  64. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_14.ttl +0 -0
  65. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_15.ttl +0 -0
  66. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_16.ttl +0 -0
  67. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_17.ttl +0 -0
  68. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_18.ttl +0 -0
  69. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_19.ttl +0 -0
  70. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_2.ttl +0 -0
  71. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_20.ttl +0 -0
  72. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_21.ttl +0 -0
  73. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_22.ttl +0 -0
  74. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_23.ttl +0 -0
  75. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_24.ttl +0 -0
  76. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_25.ttl +0 -0
  77. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_27.ttl +0 -0
  78. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_28.ttl +0 -0
  79. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_29.ttl +0 -0
  80. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_3.ttl +0 -0
  81. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_30.ttl +0 -0
  82. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_31.ttl +0 -0
  83. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_32.ttl +0 -0
  84. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_33.ttl +0 -0
  85. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_34.ttl +0 -0
  86. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_35.ttl +0 -0
  87. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_36.ttl +0 -0
  88. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_37.ttl +0 -0
  89. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_38.ttl +0 -0
  90. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_39.ttl +0 -0
  91. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_4.ttl +0 -0
  92. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_40.ttl +0 -0
  93. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_41.ttl +0 -0
  94. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_42.ttl +0 -0
  95. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_43.ttl +0 -0
  96. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_44.ttl +0 -0
  97. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_45.ttl +0 -0
  98. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_46.ttl +0 -0
  99. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_47.ttl +0 -0
  100. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_48.ttl +0 -0
  101. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_49.ttl +0 -0
  102. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_5.ttl +0 -0
  103. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_50.ttl +0 -0
  104. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_51.ttl +0 -0
  105. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_52.ttl +0 -0
  106. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_53.ttl +0 -0
  107. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_54.ttl +0 -0
  108. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_55.ttl +0 -0
  109. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_56.ttl +0 -0
  110. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_57.ttl +0 -0
  111. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_58.ttl +0 -0
  112. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_6.ttl +0 -0
  113. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_60.ttl +0 -0
  114. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_61.ttl +0 -0
  115. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_62.ttl +0 -0
  116. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_63.ttl +0 -0
  117. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_64.ttl +0 -0
  118. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_65.ttl +0 -0
  119. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_66.ttl +0 -0
  120. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_67.ttl +0 -0
  121. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_7.ttl +0 -0
  122. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_8.ttl +0 -0
  123. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/nlp4lp_9.ttl +0 -0
  124. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/non_linear_problem_10.ttl +0 -0
  125. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/non_linear_problem_15.ttl +0 -0
  126. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/non_linear_problem_23.ttl +0 -0
  127. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/non_linear_problem_9.ttl +0 -0
  128. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/puzzles_problem_1.ttl +0 -0
  129. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/puzzles_problem_11.ttl +0 -0
  130. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/puzzles_problem_12.ttl +0 -0
  131. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/puzzles_problem_13.ttl +0 -0
  132. {text2model-0.1.0 → text2model-1.1.0}/text2model/knowledge_graphs/puzzles_problem_31.ttl +0 -0
  133. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/assembler_prompt.txt +0 -0
  134. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/code_stitching_prompt.txt +0 -0
  135. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/code_validation_prompt.txt +0 -0
  136. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/constraint_generation_prompt.txt +0 -0
  137. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/cot_prompt.txt +0 -0
  138. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/all_different_prompt.txt +0 -0
  139. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/count_prompt.txt +0 -0
  140. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/cumulative_prompt.txt +0 -0
  141. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/global_cardinality_prompt.txt +0 -0
  142. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/increasing_prompt.txt +0 -0
  143. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/global_constraint_prompts/lex_less_prompt.txt +0 -0
  144. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/grammar_validation_prompt.txt +0 -0
  145. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/kg_code_generation_prompt.txt +0 -0
  146. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/kg_generation_prompt.txt +0 -0
  147. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/objective_generation_prompt.txt +0 -0
  148. {text2model-0.1.0 → text2model-1.1.0}/text2model/prompts/parameter_and_variable_generation_prompt.txt +0 -0
  149. {text2model-0.1.0 → text2model-1.1.0}/text2model.egg-info/dependency_links.txt +0 -0
  150. {text2model-0.1.0 → text2model-1.1.0}/text2model.egg-info/entry_points.txt +0 -0
  151. {text2model-0.1.0 → text2model-1.1.0}/text2model.egg-info/top_level.txt +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.4
2
+ Name: text2model
3
+ Version: 1.1.0
4
+ Summary: LLM Modeling Copilots for Text-to-Model Translation
5
+ License: Apache-2.0
6
+ Keywords: minizinc,constraint-programming,LLM,text-to-model
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: openai
14
+ Requires-Dist: datasets
15
+ Requires-Dist: tqdm
16
+ Requires-Dist: langchain-ollama
17
+ Requires-Dist: flet==0.21.2
18
+ Requires-Dist: pytest
19
+ Dynamic: license-file
20
+
21
+ [![Tests](https://github.com/skadio/text2model/actions/workflows/tests.yml/badge.svg)](https://github.com/skadio/text2model/actions/workflows/tests.yml)
22
+ [![PyPI version](https://img.shields.io/pypi/v/text2model.svg?cacheSeconds=1)](https://pypi.org/project/text2model/)
23
+ [![PyPI license](https://img.shields.io/pypi/l/text2model.svg?cacheSeconds=1)](https://pypi.python.org/pypi/text2model/)
24
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
25
+ [![Downloads](https://static.pepy.tech/personalized-badge/text2model?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pepy.tech/project/text2model)
26
+
27
+ ---
28
+
29
+ <div align="center"><a name="menu"></a>
30
+ <h3>
31
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#text-mode">Text Mode</a> •
32
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#text2zinc-mode">Text2Zinc Mode</a> •
33
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#interactive-mode">Interactive Mode</a> •
34
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#copilots">Copilots</a> •
35
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#installation">Installation</a> •
36
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#dataset-editor">Dataset Editor</a> •
37
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#evaluation">Evaluation</a> •
38
+ <a href="https://github.com/skadio/text2model?tab=readme-ov-file#leaderboard">Leaderboard</a>
39
+ </h3>
40
+ </div>
41
+
42
+ ---
43
+
44
+ # Text2Model: LLM Modeling Copilots for Text-to-Model Translation
45
+
46
+ [Text2Model](https://skadio.github.io/text2model/) is a suite of LLM modeling copilots, datasets, fined-tuned models, demos, interactive editor, and online leaderboard for translating natural language text into formal combinatorial constraint models.
47
+
48
+ Text2Model uses MiniZinc as the target modeling language which makes our copilots both **paradigm- and solver-agnostic**. Our copilots generate models that can be solved by any MiniZinc compatible solver including Gecode, Chuffed, OR-Tools, CBC, Gurobi, Cplex, HiGH. This covers a wide range of paradigms including CP, CP-SAT, and MIP. As such, Text2Model can address **both combinatorial satisfaction and optimization problems.**
49
+
50
+ Please visit [Text2Model](https://skadio.github.io/text2model/) for latest publications and resources.
51
+
52
+ ## Quick Start
53
+
54
+ Text2Model supports translating given problem descriptions (**Text mode**), specific problems from our dataset (**Text2Zinc mode**), or running interactively using the [editor](https://github.com/skadio/text2model?tab=readme-ov-file#dataset-editor) (**Editor mode**).
55
+
56
+ ### Text Mode
57
+
58
+ ```bash
59
+ # Translate a given problem description
60
+ text2model --problem "A country produces fighter jets each year. Some of these jets must be set aside for pilot training instead of combat use. Year 1 production is 10 jets, and Year 2 production is 15 jets. Each training jet can train 5 pilots per year. Training runs for 2 years, starting in Year 1. Determine how many pilots will be trained in total by the end of Year 2."
61
+
62
+ # Translate a given problem file
63
+ text2model --problem my_problem.txt
64
+
65
+ # Choose the copilot strategy and the model
66
+ # Note that `knowledge_graph` is not available for text-mode as it requires pre-built TTL files
67
+ text2model --problem my_problem.txt --strategies agents_with_code_validation --model gpt-4o
68
+
69
+ # Redirect the output to a MiniZinc model
70
+ text2model --problem my_problem.txt > my_model.mzn
71
+ ```
72
+
73
+ ### Text2Zinc Mode
74
+
75
+ ```bash
76
+ # Translate specific problems from Text2Zinc
77
+ text2model --problem-ids 0 1 2 --strategies cot --model gpt-4 --output-dir my_results
78
+
79
+ # Run multiple strategies on all Text2Zinc problems
80
+ text2model --strategies cot --model gpt-4 --output-dir my_results
81
+
82
+ # Run all strategies
83
+ text2model --strategies all --model gpt-4 --output-dir my_results
84
+
85
+ # Run on specific source of Text2Zinc problems
86
+ text2model --source nlp4lp --strategies cot --model gpt-4 --output-dir my_results
87
+
88
+ # List all available data sources
89
+ text2model --list-sources
90
+
91
+ # List all available --model options (which need OPENAI_API_KEY vs. run locally through Ollama)
92
+ text2model --list-models
93
+
94
+ # Advanced options
95
+ text2model --strategies agents --model gpt-4 \
96
+ --output-dir my_results \
97
+ --temperature 0.7 \
98
+ --max-tokens 8192 \
99
+ --sleep-time 2 \
100
+ --include-unverified
101
+
102
+ # Use a local dataset (e.g. one saved by `text2model --editor`) instead of the
103
+ # default skadio/text2zinc HuggingFace dataset
104
+ text2model --strategies cot --model gpt-4 --output-dir my_results \
105
+ --dataset-path text2zinc_edited.csv
106
+ ```
107
+
108
+ ### Interactive Mode
109
+
110
+ ```bash
111
+ text2model --editor
112
+ text2model --editor --dataset-path text2zinc_edited.csv
113
+ ```
114
+
115
+ See [Dataset Editor](https://github.com/skadio/text2model?tab=readme-ov-file#dataset-editor) for details.
116
+
117
+ ## Copilots
118
+
119
+ Text2Model offers different copilot strategies, ranging from simple single-call approaches to sophisticated multi-agent systems. Each makes different trade-offs between speed and accuracy.
120
+
121
+ | Strategy | Description |
122
+ |----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
123
+ | `baseline` | Direct code generation from problem description. No special prompting. Good for simple problems or establishing a baseline. |
124
+ | `cot` | **Chain-of-Thought** prompting with guiding principles. The LLM reasons through the problem step-by-step before generating code. |
125
+ | `knowledge_graph` | First extracts structured information (entities, relationships) from the problem, then generates code from this intermediate representation. |
126
+ | `cot_with_code_validation` | Generates code with CoT, then validates and fixes any compilation errors. Good default choice. |
127
+ | `cot_with_grammar_validation` | Generates code with CoT, then checks against MiniZinc grammar rules. |
128
+ | `cot_with_code_and_grammar_validation` | Combines CoT generation with both grammar checking and code validation. |
129
+ | `agents` | Decomposes the task into specialized agents: (1) parameters & variables, (2) constraints, (3) objective, (4) assembler that stitches everything together. |
130
+ | `agents_with_code_validation` | Agents approach plus a final validation/fix step. |
131
+ | `gala` | Global Agents for different constraint types (all_different, cumulative, etc.) plus an assembler. See the [GALA paper](https://arxiv.org/abs/2509.08970).|
132
+
133
+ > **Want to use `knowledge_graph` on your own problems?** It requires a pre-built `.ttl` knowledge-graph file per problem. See [`text2model/generate_knowledge_graph.py`](text2model/generate_knowledge_graph.py) and any example file under [`text2model/knowledge_graphs/`](text2model/knowledge_graphs/) (e.g. `nlp4lp_1.ttl`) and do similar — either adapt the script to your problem or hand-write a `.ttl` following the same structure.
134
+
135
+ ### Adding a Custom Copilot
136
+
137
+ Every strategy in the table above follows the same shape, so plugging in a new one is mechanical:
138
+
139
+ 1. **Add prompt(s)** under [`text2model/prompts/`](text2model/prompts/) (`.txt` files with `{problem_description}`, `{input_data}`, etc. placeholders — see any existing prompt for the pattern).
140
+ 2. **Write a `run_<name>_strategy(client, model, problem, problem_identifier, output_dir)` function** in [`text2model/main.py`](text2model/main.py). Use `utils.prepare_problem_data`, `utils.get_effective_input_data`, and `utils.load_file` to build your prompt(s), call `utils.call_api(client, model, prompt)` to get code back, and stitch/combine calls the way `run_agents_strategy` does if your copilot needs multiple LLM calls. Finish with `utils.save_solution(output_dir, problem_identifier, code)`.
141
+ 3. **Register it** by adding `'<name>': run_<name>_strategy` to `_STRATEGY_MAP` in `main.py`, and add `'<name>'` to the `--strategies` argparse `choices` list (and to the `'all'` expansion list if it should run as part of `--strategies all`).
142
+
143
+ That's it — your strategy is now available via `--strategies <name>` in both `--problem` and batch modes.
144
+
145
+ ## Installation
146
+
147
+ Text2Model requires **Python 3.8+** and can be installed from PyPI or by building from source.
148
+
149
+ ### Set Your API Key
150
+
151
+ ```bash
152
+ export OPENAI_API_KEY="your-api-key-here"
153
+ ```
154
+
155
+ ### Install from PyPI
156
+ ```bash
157
+ pip install text2model
158
+ ```
159
+
160
+ ### Install from Source
161
+ ```bash
162
+ git clone https://github.com/skadio/text2model.git
163
+ cd text2model
164
+ pip install -e .
165
+ ```
166
+
167
+ ## Dataset Editor
168
+
169
+ Text2Model ships a GUI editor (built with [Flet](https://flet.dev)) for browsing and editing Text2Zinc problems (input.json, data.dzn, model.mzn, output.json), running them through MiniZinc, and chatting with an AI assistant for help rephrasing descriptions or fixing model code.
170
+
171
+ ### Launch
172
+
173
+ ```bash
174
+ text2model --editor
175
+ ```
176
+
177
+ By default the editor opens, in order: a previous editing session (`text2zinc_edited.csv` in the current directory), otherwise the dataset bundled with the package. Use the **"Load from HuggingFace"** button inside the editor to instead start from a fresh copy of `skadio/text2zinc`, or open any other local dataset with **"Open CSV..."** — or non-interactively:
178
+
179
+ ```bash
180
+ text2model --editor --dataset-path my_dataset.csv
181
+ ```
182
+
183
+ ### Save and Benchmark
184
+
185
+ - **Save** (or Ctrl+S) quick-saves your edits to `text2zinc_edited.csv` in the current directory.
186
+ - **Save As New Dataset...** exports to any path you choose. That path is a complete Text2Zinc dataset you can pass to `--dataset-path` to generate or benchmark against your edits instead of the default HuggingFace dataset:
187
+
188
+ ```bash
189
+ text2model --strategies cot --model gpt-4 --output-dir my_results --dataset-path my_dataset.csv
190
+ python evals/evaluate.py --output-dir my_results --dataset-path my_dataset.csv
191
+ ```
192
+
193
+ ## Evaluation
194
+
195
+ After generating models, evaluate their correctness via [`evals/evaluate.py`](evals/evaluate.py). This script compiles and runs each generated MiniZinc model against test instances, checking for both execution success and solution correctness.
196
+
197
+ #### Prerequisite
198
+
199
+ Install MiniZinc solver: https://www.minizinc.org/doc-2.5.5/en/installation.html
200
+
201
+ #### Evals
202
+ ```bash
203
+ # Evaluate all generated code
204
+ # `--output-dir` is required. Point it at the directory produced by the batch-mode `text2model` run.
205
+ python evals/evaluate.py --output-dir my_results
206
+
207
+ # Evaluate against a local dataset (e.g. one saved by `text2model --editor`) instead
208
+ # of the default skadio/text2zinc HuggingFace dataset
209
+ python evals/evaluate.py --output-dir my_results --dataset-path text2zinc_edited.csv
210
+ ```
211
+
212
+ Running the eval generates a JSON file (`evals/evaluation_results.json` by default, via `--output-json`) with your accuracy metrics. You can PR that file to the [Text2Model Leaderboard](https://huggingface.co/spaces/skadio/text2model-leaderboard) on Hugging Face to get your results added to the online leaderboard.
213
+
214
+ #### Metrics
215
+
216
+ | Metric | Description |
217
+ |--------|-------------|
218
+ | **Execution Accuracy** | % of models that compile and run without errors |
219
+ | **Solution Accuracy** | % of models that produce correct solutions |
220
+ | **Average Score** | Average of execution and solution accuracy |
221
+
222
+ Results are broken down by problem type as satisfaction vs. optimization.
223
+
224
+ ## Leaderboard
225
+
226
+ Text2Model hosts an online leaderboard tracking execution accuracy, solution accuracy, and average score across models and copilot strategies on the Text2Zinc benchmark:
227
+
228
+ **[Text2Model Leaderboard](https://huggingface.co/spaces/skadio/text2model-leaderboard)** (Hugging Face Spaces)
229
+
230
+ ## Testing
231
+
232
+ **Default tests** (`tests/test_main.py`, `tests/test_utils.py`) do not need an API key, network, or MiniZinc.
233
+ They are pure logic tests with mocked API calls and is run by the CI:
234
+
235
+ ```bash
236
+ pytest -m "not integration"
237
+ ```
238
+
239
+ **Integration tests** (`tests/test_integration.py`) hit real external dependencies and are opt-in only.
240
+ This is not to be used in CI:
241
+ - MiniZinc tests run the real `minizinc` binary and are skipped unless it is on `PATH`.
242
+ - The OpenAI test makes exactly one real, cheap, token-capped call (`gpt-4o-mini`, `max_tokens=20`) and is skipped unless `OPENAI_API_KEY` is set. It's intentionally not exhaustive to avoid API costs.
243
+
244
+ To run everything locally (with `OPENAI_API_KEY` set and MiniZinc installed):
245
+
246
+ ```bash
247
+ pytest -m ""
248
+ ```
249
+
250
+ ## Repository Structure
251
+ ```
252
+ text2model/
253
+ ├── text2model/ # Installable Python package
254
+ │ ├── prompts/ # Prompt templates for each strategy
255
+ │ │ ├── cot_prompt.txt
256
+ │ │ ├── code_validation_prompt.txt
257
+ │ │ ├── global_constraint_prompts/
258
+ │ │ └── ...
259
+ │ ├── knowledge_graphs/ # KG files (.ttl) for knowledge_graph strategy
260
+ │ ├── editor/ # Dataset editor GUI (`text2model --editor`)
261
+ │ │ ├── app.py # Flet app: browse/edit/execute Text2Zinc problems, AI chat assistant
262
+ │ │ └── data/text2zinc.csv # Bundled default dataset the editor opens on first run
263
+ │ ├── grammar.mzn # MiniZinc grammar for validation
264
+ │ ├── main.py # Copilot strategies and CLI entry point
265
+ │ ├── generate_knowledge_graph.py # Generates KGs for the knowledge_graph strategy
266
+ │ └── utils.py # Shared utilities (API calls, validation, dataset loading)
267
+ ├── tests/ # Unit and integration tests (pytest)
268
+ ├── evals/ # Evaluation tooling
269
+ │ ├── evaluate.py # Evaluates generated MiniZinc models
270
+ │ ├── evaluation_results.json # Latest evaluation results (PR-able to the HF leaderboard)
271
+ │ └── results/ # Accuracy metrics and leaderboard from paper runs
272
+ ├── output/ # Original outputs per strategy, kept for reproducing paper results
273
+ │ └── [model]/[strategy]/ # e.g., gpt-4/cot/problem_1.mzn
274
+ ├── pyproject.toml # Package metadata and install config
275
+ ├── CHANGELOG.txt # Release history
276
+ └── LICENSE # Apache License 2.0
277
+ ```
278
+
279
+ ## Support
280
+
281
+ Please submit bug reports and feature requests as [Issues](https://github.com/skadio/text2model/issues).
282
+
283
+ ## License
284
+
285
+ Text2Model is licensed under the [Apache License 2.0](LICENSE).
286
+
287
+ <br>