Révision 4020

TXM/trunk/bundles/org.txm.nlp.core/.classpath (revision 4020)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
TXM/trunk/bundles/org.txm.nlp.core/META-INF/MANIFEST.MF (revision 4020)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: org.txm.nlp.core
4
Bundle-SymbolicName: org.txm.nlp.core;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Export-Package: org.txm.nlp.core
7
Require-Bundle: org.txm.core;bundle-version="0.8.3";visibility:=reexport
8
Automatic-Module-Name: org.txm.nlp.core
9
Bundle-RequiredExecutionEnvironment: JavaSE-17
TXM/trunk/bundles/org.txm.nlp.core/schema/org.txm.nlp.core.NLPEngine.exsd (revision 4020)
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.txm.nlp.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.txm.nlp.core" id="org.txm.nlp.core.NLPEngine" name="org.txm.nlp.core.NLPEngine"/>
7
      </appinfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <choice>
21
            <element ref="NLPEngine"/>
22
         </choice>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="NLPEngine">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="org.txm.nlp.core.NLPEngine:"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="description" type="string">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71

  
72
   <annotation>
73
      <appinfo>
74
         <meta.section type="since"/>
75
      </appinfo>
76
      <documentation>
77
         [Enter the first release in which this extension point appears.]
78
      </documentation>
79
   </annotation>
80

  
81
   <annotation>
82
      <appinfo>
83
         <meta.section type="examples"/>
84
      </appinfo>
85
      <documentation>
86
         [Enter extension point usage example here.]
87
      </documentation>
88
   </annotation>
89

  
90
   <annotation>
91
      <appinfo>
92
         <meta.section type="apiinfo"/>
93
      </appinfo>
94
      <documentation>
95
         [Enter API information here.]
96
      </documentation>
97
   </annotation>
98

  
99
   <annotation>
100
      <appinfo>
101
         <meta.section type="implementation"/>
102
      </appinfo>
103
      <documentation>
104
         [Enter information about supplied implementation of this extension point.]
105
      </documentation>
106
   </annotation>
107

  
108

  
109
</schema>
TXM/trunk/bundles/org.txm.nlp.core/.project (revision 4020)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.nlp.core</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
TXM/trunk/bundles/org.txm.nlp.core/src/org/txm/nlp/core/messages_fr.properties (revision 4020)
1
NLPEnginesManager_ErrorFailedToStopNLPEngineP0P1=?chec lors de l''arr?te du moteur TAL ''{0}'' : {1}
2
NLPEnginesManager_FailToInitializeTheP0NLPEngine=?chec lors de l''initialisation du moteur TAL {0}.
3
NLPEnginesManager_FailToInstanciateP0P1=?chec de l'instanciation de {0} : {1}.
4
ErrorNoSuitableFileToProcessInP0=Erreur: pas de fichier ? traiter dans {0}.
TXM/trunk/bundles/org.txm.nlp.core/src/org/txm/nlp/core/NLPEnginesManager.java (revision 4020)
1
package org.txm.nlp.core;
2

  
3
import org.eclipse.core.runtime.IConfigurationElement;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.core.runtime.Platform;
6
import org.eclipse.osgi.util.NLS;
7
import org.txm.core.engines.EngineType;
8
import org.txm.core.engines.EnginesManager;
9
import org.txm.utils.logger.Log;
10

  
11

  
12
/**
13
 * 
14
 * @author mdecorde
15
 **/
16
public class NLPEnginesManager extends EnginesManager<NLPEngine> {
17
	
18
	private static final long serialVersionUID = -6288338617609951960L;
19

  
20
	public NLPEnginesManager() {
21
		
22
	}
23
	
24
	@Override
25
	public boolean startEngines(IProgressMonitor monitor) {
26
		
27
		for (NLPEngine e : values()) {
28
			
29
			// lazy mode
30
			
31
			// NLPEngine se = (NLPEngine)e;
32
			// if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
33
			// try {
34
			// se.start(monitor);
35
			// } catch (Exception ex) {
36
			// System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
37
			// }
38
		}
39
		return true;
40
	}
41
	
42
	
43
	@Override
44
	public boolean stopEngines() {
45
		for (NLPEngine e : values()) {
46
			// System.out.println(e);
47
			NLPEngine se = e;
48
			Log.fine("Stoping " + se.getName() + " annotation engine."); //$NON-NLS-1$ //$NON-NLS-2$
49
			try {
50
				se.stop();
51
			}
52
			catch (Exception ex) {
53
				Log.severe(NLS.bind(Messages.ErrorFailedToStopNLPEngineP0P1, se.getName(), ex.getLocalizedMessage()));
54
			}
55
		}
56
		return true;
57
	}
58
	
59
	@Override
60
	public EngineType getEnginesType() {
61
		return EngineType.NLP;
62
	}
63
	
64
	@Override
65
	public boolean fetchEngines() {
66
		
67
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(NLPEngine.EXTENSION_POINT_ID);
68
		// System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
69
		for (int i = 0; i < contributions.length; i++) {
70
			try {
71
				NLPEngine e = (NLPEngine) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
72
				if (e.initialize()) {
73
					put(e.getName(), e);
74
				}
75
				else {
76
					Log.warning(NLS.bind(Messages.FailToInitializeTheP0NLPEngine, e.getName()));
77
				}
78
			}
79
			catch (Exception e) {
80
				Log.warning(NLS.bind(Messages.FailToInstanciateP0P1, contributions[i].getName(), e.getLocalizedMessage()));
81
				Log.printStackTrace(e);
82
			}
83
		}
84
		
85
		return size() > 0;
86
	}
87

  
88
}
TXM/trunk/bundles/org.txm.nlp.core/src/org/txm/nlp/core/NLPEngine.java (revision 4020)
1
package org.txm.nlp.core;
2

  
3
import java.io.File;
4
import java.io.FileFilter;
5
import java.util.HashMap;
6

  
7
import org.eclipse.osgi.util.NLS;
8
import org.txm.core.engines.Engine;
9
import org.txm.core.results.TXMResult;
10
import org.txm.tokenizer.StringTokenizer;
11
import org.txm.utils.ConsoleProgressBar;
12
import org.txm.utils.DeleteDir;
13
import org.txm.utils.logger.Log;
14

  
15
public abstract class NLPEngine implements Engine {
16
	
17
	public static final String EXTENSION_POINT_ID = NLPEngine.class.getCanonicalName();
18
	
19
	@Override
20
	public abstract String getName();
21
	
22

  
23
	/**
24
	 * 
25
	 * @return a StringTokenizer, override this method if the engine needs a speciq tokenization
26
	 * @throws Exception
27
	 */
28
	public StringTokenizer getStringTokenizer(String lang) throws Exception {
29
		return null;
30
	}
31
	
32
	/**
33
	 * Automatically annotate a XML-TXM file
34
	 * 
35
	 * @param xmlFile to annotate
36
	 * @param binaryCorpusDirectory
37
	 * @param parameters
38
	 * @return
39
	 */
40
	public abstract boolean processFile(File xmlFile, File binaryCorpusDirectory, HashMap<String, Object> parameters);
41
	
42
	/**
43
	 * 
44
	 * @param xmlFilesDirectory contains the *.xml files to process
45
	 * @param binaryCorpusDirectory the output directory
46
	 * @param parameters ["lang": model_file_name_without_extension]
47
	 * @return
48
	 */
49
	public boolean processDirectory(File xmlFilesDirectory, File binaryCorpusDirectory, HashMap<String, Object> parameters) {
50
		File[] files = xmlFilesDirectory.listFiles(new FileFilter() {
51
			
52
			@Override
53
			public boolean accept(File pathname) {
54
				return pathname.isFile() && !pathname.isHidden() && !pathname.getName().startsWith(".") && pathname.getName().endsWith(".xml"); //$NON-NLS-1$ //$NON-NLS-2$
55
			}
56
		});
57
		if (files == null || files.length == 0) {
58
			Log.warning(NLS.bind(Messages.ErrorNoSuitableFileToProcessInP0, xmlFilesDirectory));
59
			return false;
60
		}
61
		boolean ret = true;
62
		ConsoleProgressBar cpb = new ConsoleProgressBar(files.length);
63
		
64
		File annotDir = new File(binaryCorpusDirectory, "annotations"); //$NON-NLS-1$
65
		DeleteDir.deleteDirectory(annotDir);
66
		annotDir.mkdir();
67
		File ptreetaggerDir = new File(binaryCorpusDirectory, "ptreetagger"); //$NON-NLS-1$
68
		DeleteDir.deleteDirectory(ptreetaggerDir);
69
		ptreetaggerDir.mkdir();
70
		File treetaggerDir = new File(binaryCorpusDirectory, "treetagger"); //$NON-NLS-1$
71
		DeleteDir.deleteDirectory(treetaggerDir);
72
		treetaggerDir.mkdir();
73
		
74
		for (File xmlFile : files) {
75
			ret = processFile(xmlFile, binaryCorpusDirectory, parameters) && ret;
76
			
77
			cpb.tick();
78
		}
79
		cpb.done();
80
		return ret;
81
	}
82
	
83
	public String hasAdditionalDetailsForResult(TXMResult result) {
84
		return null;
85
	}
86
	
87
	public String getAdditionalDetailsForResult(TXMResult result) {
88
		return null;
89
	}
90
}
TXM/trunk/bundles/org.txm.nlp.core/src/org/txm/nlp/core/messages.properties (revision 4020)
1
NLPEnginesManager_ErrorFailedToStopNLPEngineP0P1=Error: failed to stop the ''{0}'' NLP engine: {1}.
2
NLPEnginesManager_FailToInitializeTheP0NLPEngine=Fail to initialize the {0} NLP engine.
3
NLPEnginesManager_FailToInstanciateP0P1=Fail to instanciate {0}: {1}.
4
ErrorNoSuitableFileToProcessInP0=Error: no suitable file to process in {0}.
TXM/trunk/bundles/org.txm.nlp.core/src/org/txm/nlp/core/Messages.java (revision 4020)
1
package org.txm.nlp.core;
2

  
3
import org.eclipse.osgi.util.NLS;
4
import org.txm.utils.messages.Utf8NLS;
5

  
6
public class Messages extends NLS {
7

  
8
	public static String ErrorFailedToStopNLPEngineP0P1;
9
	public static String FailToInitializeTheP0NLPEngine;
10
	public static String FailToInstanciateP0P1;
11
	public static String ErrorNoSuitableFileToProcessInP0;
12
	
13
	static {
14
		// initialize resource bundle
15
		Utf8NLS.initializeMessages(Messages.class);
16
	}
17

  
18
	private Messages() { }
19
}
TXM/trunk/bundles/org.txm.nlp.core/bin/org/txm/nlp/core/messages.properties (revision 4020)
1
NLPEnginesManager_ErrorFailedToStopNLPEngineP0P1=Error: failed to stop the ''{0}'' NLP engine: {1}.
2
NLPEnginesManager_FailToInitializeTheP0NLPEngine=Fail to initialize the {0} NLP engine.
3
NLPEnginesManager_FailToInstanciateP0P1=Fail to instanciate {0}: {1}.
4
ErrorNoSuitableFileToProcessInP0=Error: no suitable file to process in {0}.
TXM/trunk/bundles/org.txm.nlp.core/bin/org/txm/nlp/core/messages_fr.properties (revision 4020)
1
NLPEnginesManager_ErrorFailedToStopNLPEngineP0P1=?chec lors de l''arr?te du moteur TAL ''{0}'' : {1}
2
NLPEnginesManager_FailToInitializeTheP0NLPEngine=?chec lors de l''initialisation du moteur TAL {0}.
3
NLPEnginesManager_FailToInstanciateP0P1=?chec de l'instanciation de {0} : {1}.
4
ErrorNoSuitableFileToProcessInP0=Erreur: pas de fichier ? traiter dans {0}.
TXM/trunk/bundles/org.txm.nlp.core/build.properties (revision 4020)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
TXM/trunk/bundles/org.txm.nlp.core/plugin.xml (revision 4020)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension-point id="org.txm.nlp.core.NLPEngine" name="org.txm.nlp.core.NLPEngine" schema="schema/org.txm.nlp.core.NLPEngine.exsd"/>
5
   <extension
6
         point="org.txm.core.engines.EnginesManager">
7
      <EngineManager
8
            class="org.txm.nlp.core.NLPEnginesManager"
9
            description="NLP engines manager"
10
            name="NLP">
11
      </EngineManager>
12
   </extension>
13

  
14
</plugin>
TXM/trunk/bundles/org.txm.nlp.core/.settings/org.eclipse.jdt.core.prefs (revision 4020)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
3
org.eclipse.jdt.core.compiler.compliance=17
4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
5
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
8
org.eclipse.jdt.core.compiler.release=enabled
9
org.eclipse.jdt.core.compiler.source=17
TXM/trunk/bundles/org.txm.nlp.core/.settings/org.eclipse.core.resources.prefs (revision 4020)
1
eclipse.preferences.version=1
2
encoding/<project>=UTF-8

Formats disponibles : Unified diff