cstr commited on
Commit
279d509
·
verified ·
1 Parent(s): 77a28b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -86,7 +86,10 @@ except ImportError:
86
  print("CRITICAL WARNING: `wn` library not found.")
87
 
88
  # --- Pattern.en Import (ENGLISH) ---
 
89
  try:
 
 
90
  from pattern.en import (
91
  pluralize, singularize, conjugate, tenses, lemma, lexeme,
92
  attributive, predicative,
@@ -100,9 +103,27 @@ try:
100
  )
101
  PATTERN_EN_AVAILABLE = True
102
  print("✓ Successfully imported pattern.en")
103
- except ImportError as e:
104
- PATTERN_EN_AVAILABLE = False
105
- print(f"CRITICAL WARNING: `pattern.en` library not found: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  # --- HanTa Tagger Import (for EN) ---
108
  try:
@@ -2499,5 +2520,9 @@ if __name__ == "__main__":
2499
 
2500
  # --- 10. Launch Gradio ---
2501
  demo = create_consolidated_interface()
 
2502
  # Use a different port (e.g., 7861) to avoid conflicts with the German app
2503
- demo.launch(server_name="0.0.0.0", server_port=7861, show_error=True)
 
 
 
 
86
  print("CRITICAL WARNING: `wn` library not found.")
87
 
88
  # --- Pattern.en Import (ENGLISH) ---
89
+ PATTERN_EN_AVAILABLE = False
90
  try:
91
+ # Try importing from the standard pattern library
92
+ import pattern.en
93
  from pattern.en import (
94
  pluralize, singularize, conjugate, tenses, lemma, lexeme,
95
  attributive, predicative,
 
103
  )
104
  PATTERN_EN_AVAILABLE = True
105
  print("✓ Successfully imported pattern.en")
106
+ except ImportError:
107
+ print("Using PatternLite fallback...")
108
+ try:
109
+ # Sometimes PatternLite structure is slightly different, but usually compatible
110
+ import pattern.en
111
+ from pattern.en import (
112
+ pluralize, singularize, conjugate, tenses, lemma, lexeme,
113
+ attributive, predicative,
114
+ article, MALE, FEMALE, NEUTRAL, PLURAL,
115
+ INFINITIVE, PRESENT, PAST, PARTICIPLE,
116
+ FIRST, SECOND, THIRD, SINGULAR, PLURAL as PL,
117
+ INDICATIVE, IMPERATIVE, SUBJUNCTIVE,
118
+ comparative, superlative,
119
+ NOUN, VERB, ADJECTIVE,
120
+ parse, split
121
+ )
122
+ PATTERN_EN_AVAILABLE = True
123
+ print("✓ Successfully imported pattern.en (via PatternLite)")
124
+ except ImportError as e:
125
+ PATTERN_EN_AVAILABLE = False
126
+ print(f"CRITICAL WARNING: `pattern.en` library not found: {e}")
127
 
128
  # --- HanTa Tagger Import (for EN) ---
129
  try:
 
2520
 
2521
  # --- 10. Launch Gradio ---
2522
  demo = create_consolidated_interface()
2523
+
2524
  # Use a different port (e.g., 7861) to avoid conflicts with the German app
2525
+ # demo.launch(server_name="0.0.0.0", server_port=7861, show_error=True)
2526
+
2527
+ # No server_port argument!
2528
+ demo.launch(server_name="0.0.0.0", show_error=True)