Révision 3518

TXM/trunk/org.txm.perl.core/src/org/txm/perl/core/PerlScriptEngine.java (revision 3518)
27 27

  
28 28
	@Override
29 29
	public boolean isRunning() {
30
		return true;
30
		
31
		String path = PerlPreferences.getInstance().getString(PerlPreferences.HOME);
32
		String perlRunner = PerlPreferences.getInstance().getString(PerlPreferences.EXECUTABLE_NAME);
33
		
34
		if (perlRunner.isEmpty()) return false;
35
		
36
//		if (false && (OSDetector.isFamilyUnix() || OSDetector.isFamilyMac())) {
37
//			if (path != null && path.length() > 0) {
38
//				cmd.add(0, new File(path, perlRunner).getAbsolutePath());
39
//			} else {
40
//				cmd.add(0, perlRunner);
41
//			}
42
//			
43
//			String code = "'"+StringUtils.join(cmd, "' '")+"'";
44
//			cmd = new ArrayList(Arrays.asList("bash", "-c", code));
45
//		} else {
46
			if (path != null && path.length() > 0) {
47
				return new File(path, perlRunner).canExecute();
48
			} else {
49
				//return new File(perlRunner).canExecute();
50
				return !perlRunner.isEmpty();
51
			}
52
//		}
31 53
	}
32 54

  
33 55
	@Override
......
59 81
		ArrayList<String> cmd = new ArrayList<String>();
60 82
		cmd.add("-c");
61 83
		cmd.add(str);
62
		System.out.println("Running Perl code...");
63
		
64
			return runPerl(cmd, env);
65
		
84
		//System.out.println("Running Perl code...");
85
		return runPerl(cmd, env);		
66 86
	}
67 87
	
68 88
	public boolean canExecute(File script) {
TXM/trunk/org.txm.connlu.core/src/org/txm/conllu/core/CallUD2TigerPerlScript.java (revision 3518)
11 11
import org.txm.tigersearch.preferences.TigerSearchPreferences;
12 12
import org.txm.utils.*;
13 13
import org.txm.utils.io.IOUtils;
14
import org.txm.utils.logger.Log;
14 15

  
15 16
public class CallUD2TigerPerlScript {
16 17
	
18
	public boolean canBuildTSFiles() {
19
		ScriptEngine engine = ScriptEnginesManager.getPerlEngine();
20
		if (engine == null) {
21
			Log.warning("No Perl script engine installed in TXM");
22
			return false;
23
		}
24
		if (!engine.isRunning()) {
25
			Log.warning("No Perl script engine ready in TXM. See Perl preferences.");
26
			return false;
27
		}
28
		return true;
29
	}
30
	
17 31
	public boolean convertCoNLLUFiles(String input_directory_path, String output_directory) throws IOException {
18 32
		
19 33
		File input_directory = new File(input_directory_path);
20 34
		
21 35
		if (input_directory_path.length() == 0 && input_directory.canRead()) {
22
			System.out.println("** impossible to access directory $input_directory. Aborting.");
36
			System.out.println("** impossible to access directory "+input_directory+". Aborting.");
23 37
			return false;
24 38
		}
25 39
		
......
49 63
				//System.out.println("$f... "+"perl '$perlScript' -s 10000 -o '$tigerXMLDirectory' '$f'");
50 64
				ScriptEngine engine = ScriptEnginesManager.getPerlEngine();
51 65
				if (!engine.canExecute(perlScript)) {
52
					System.out.println("Error: Perl engine not correctly set to run $perlScript");
66
					System.out.println("Error: Perl engine not correctly set to run: "+perlScript);
53 67
					return false;
54 68
				}
55 69
				ArrayList<String> cmd = new ArrayList<String>();
56 70
				cmd.addAll(Arrays.asList("-s", "10000", "-o", tigerXMLDirectory.getAbsolutePath(), f.getAbsolutePath()));
57
				System.out.println("calling perl with: "+cmd);
71
				System.out.println("Calling perl with: "+perlScript+" and "+cmd);
58 72
				IStatus status = engine.executeScript(perlScript, cmd);
59 73
				for (String line : IOUtils.getLines(mainFile, "UTF-8")) {
60
					if (line.contains("<subcorpus ")) subcorpusList += line+"\n";
74
					if (line.contains("<subcorpus ")) {
75
						subcorpusList += line+"\n";
76
					}
61 77
				}
62
			} catch (Throwable t) { System.out.println("Error: $t"); }
78
			} catch (Throwable t) { System.out.println("Error: "+t+" at "+t.getStackTrace()[0]); }
63 79
		}
64 80
		
65 81
		//	println "subcorpus-list: "+subcorpusList
66 82
		String content = IOUtils.getText(mainFile, "UTF-8");
67
		content = content.replaceAll("<subcorpus .+/>", subcorpusList+"\n<body/>"); // get the last main.xml content and patch it with the subcorpus tags
83
		content = content.replaceAll("<subcorpus .+\n", "");
84
		content = content.replaceAll("<body>", "<body>\n"+subcorpusList+"\n"); // get the last main.xml content and patch it with the subcorpus tags
68 85
		IOUtils.setText(mainFullFile, content, "UTF-8");
69 86
		//mainFullFile.setText(mainFile.getText().replaceAll("<body/>", subcorpusList+"\n<body/>"));
70 87
		
TXM/trunk/org.txm.connlu.core/groovy/org/txm/scripts/importer/conllu/CoNLLUImport.groovy (revision 3518)
19 19
import org.txm.scripts.importer.tigersearch.TSImport
20 20
import org.txm.utils.*
21 21
import org.txm.searchengine.ts.TIGERSearchEngine
22
import org.txm.tigersearch.preferences.TigerSearchPreferences
22 23
import org.txm.conllu.core.CallUD2TigerPerlScript
23 24

  
24 25
class CoNLLUImport extends XTZImport {
25

  
26
	
26 27
	public CoNLLUImport(Project params) {
27 28
		super(params);
28 29
	}
29

  
30
	
30 31
	@Override
31 32
	public void init(Project p) {
32 33
		super.init(p);
33

  
34
		
34 35
		importer = new CoNLLUImporter(this);
35 36
		compiler = new XTZCompiler(this)
36 37
		annotater = null; // no annotater step to do
......
46 47
		super.start(); // call the usual XTZ import
47 48
		
48 49
		// build the TIGER-XML file
49
		new CallUD2TigerPerlScript().convertCoNLLUFiles(this.sourceDirectory.getAbsolutePath(), this.binaryDirectory.getAbsolutePath())
50
		CallUD2TigerPerlScript cutps = new CallUD2TigerPerlScript();
50 51
		
51
		File tigerXMLDirectory = new File(this.binaryDirectory, "tiger-xml")
52
		
53
		File xslfile1 = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "tigerXml-commentOutLongSentences.xsl")
54
		File xslfile2 = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "tigerXml-sortBfmByDate.xsl")
55
		
56
		ApplyXsl2 a1 = new ApplyXsl2(xslfile1);
57
		ApplyXsl2 a2 = new ApplyXsl2(xslfile2);
58
		for (File xmlFile : tigerXMLDirectory.listFiles()) {
59
			if (!xmlFile.getName().endsWith(".xml")) continue;
60
			File xmlFileTmp = new File(xmlFile.getAbsolutePath()+".tmp")
61
			if (!(a1.process(xmlFile, xmlFileTmp) && xmlFile.delete() && xmlFileTmp.renameTo(xmlFile))) {
62
				println "Error while applying $xslfile1 to $xmlFile"
52
		if (cutps.canBuildTSFiles()) {
53
			cutps.convertCoNLLUFiles(this.sourceDirectory.getAbsolutePath(), this.binaryDirectory.getAbsolutePath())
54
			
55
			File tigerXMLDirectory = new File(this.binaryDirectory, "tiger-xml")
56
			String driverFilename = TigerSearchPreferences.getInstance().getString(TigerSearchPreferences.DRIVER_FILENAME);
57
			File xslfile1 = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "tigerXml-commentOutLongSentences.xsl")
58
			File xslfile2 = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "tigerXml-sortBfmByDate.xsl")
59
			
60
			println "Post-processing TIGER-XML files..."
61
			ApplyXsl2 a1 = new ApplyXsl2(xslfile1);
62
			ApplyXsl2 a2 = new ApplyXsl2(xslfile2);
63
			for (File xmlFile : tigerXMLDirectory.listFiles()) {
64
				
65
				if (!xmlFile.getName().endsWith(".xml")) continue;
66
				if (xmlFile.getName().equals(driverFilename)) continue;
67
				
68
				File xmlFileTmp = new File(xmlFile.getAbsolutePath()+".tmp")
69
				if (!(a1.process(xmlFile, xmlFileTmp) && xmlFile.delete() && xmlFileTmp.renameTo(xmlFile))) {
70
					println "Error while applying $xslfile1 to $xmlFile"
71
				}
72
				
73
				if (!(a2.process(xmlFile, xmlFileTmp) && xmlFile.delete() && xmlFileTmp.renameTo(xmlFile))) {
74
					println "Error while applying $xslfile2 to $xmlFile"
75
				}
63 76
			}
64 77
			
65
			if (!(a2.process(xmlFile, xmlFileTmp) && xmlFile.delete() && xmlFileTmp.renameTo(xmlFile))) {
66
				println "Error while applying $xslfile2 to $xmlFile"
78
			// build TIGER indexes
79
			if (isSuccessful) {
80
				// read from the 'tiger-xml' and write to the 'tiger' directory
81
				TIGERSearchEngine.buildTIGERCorpus(tigerXMLDirectory, this.binaryDirectory, corpusName);
67 82
			}
83
		} else {
84
			println "Skipping TIGER conversion step."
68 85
		}
69
		
70
		// build TIGER indexes
71
		if (isSuccessful) {
72
			// read from the 'tiger-xml' and write to the 'tiger' directory
73
			TIGERSearchEngine.buildTIGERCorpus(tigerXMLDirectory, this.binaryDirectory, corpusName);
74
		}
75 86
	}
76 87
}
TXM/trunk/org.txm.connlu.core/groovy/org/txm/scripts/importer/conllu/conll2tiger-ud.pl (revision 3518)
164 164

  
165 165
my $id = my $form = my $lemma = my $plemma = my $pos = my $ppos = my $feat = my $pfeat = my $head = my $phead = my $deprel = my $pdeprel = my $edition_id = "";
166 166

  
167
my $timestamp = `date`;
167
my $timestamp = gmtime();
168 168
chomp($timestamp);
169 169

  
170 170
my $infile = $ARGV[0];
......
176 176
$suffix = sprintf( "%05d", $counter );
177 177
$infilename = basename($infile);
178 178

  
179
$foo = `if [ ! -d $outdir ];then mkdir $outdir;fi`;
179
mkdir("$outdir");
180 180
open( XML, ">$outdir/$infilename-$suffix.xml" )
181 181
  or die "\nopen file error of $outdir/$infilename-$suffix.xml\n";
182 182
open( LOG, ">$outdir/conversion.log" )
......
523 523
	print XML "  </graph>\n";
524 524
	print XML "</s>\n";
525 525
	if ( $. % 100 == 0 ) {
526
		print STDERR "\b\b\b\b\b\b\b\b";
527
		printf STDERR "%08d", $.;
526
		#print STDERR "\b\b\b\b\b\b\b\b";
527
		#printf STDERR "%08d", $.;
528 528
	}
529 529
}    # main
530 530
print XML "</subcorpus>\n";
531
print STDERR "\n$CMD: $. sentences converted. Results in $outdir. Log in $outdir/conversion.log.\n";
532
print STDERR "   Hint 1: on OS X convert master file to MacRoman, e.g  iconv -f latin1 -t macroman\n";
533
print STDERR "   Hint 2: use tiger.pl -c <Tiger XML file> to detect unbound nodes.\n";
534
print STDERR "   Hint 3: build reliable feature declarations using tiger.sh\n";
535
print STDERR "           tiger.sh -a \"lemma word pos ppos\"  (for terminals)\n";
536
print STDERR "           tiger.sh -A \"lemma word pos ppos\"  (for non-terminals)\n";
531
#print STDERR "\n$CMD: $. sentences converted. Results in $outdir. Log in $outdir/conversion.log.\n";
532
#print STDERR "   Hint 1: on OS X convert master file to MacRoman, e.g  iconv -f latin1 -t macroman\n";
533
#print STDERR "   Hint 2: use tiger.pl -c <Tiger XML file> to detect unbound nodes.\n";
534
#print STDERR "   Hint 3: build reliable feature declarations using tiger.sh\n";
535
#print STDERR "           tiger.sh -a \"lemma word pos ppos\"  (for terminals)\n";
536
#print STDERR "           tiger.sh -A \"lemma word pos ppos\"  (for non-terminals)\n";
537 537

  
538 538
if ( $noroot > 0 ) {
539 539
	print STDERR "$noroot sentences ignored: root not found (see log file)\n";
TXM/trunk/org.txm.analec.feature/feature.xml (revision 3518)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<feature
3 3
      id="org.txm.annotation.urs.feature"
4
      label="URS Annotation (Unité-Relation-Schéma)"
4
      label="URS Annotation (Unit-Relation-Schema)"
5 5
      version="1.0.0.qualifier"
6 6
      provider-name="Textometrie.org"
7 7
      license-feature="org.txm.rcp.feature"
......
33 33
http://www.gnu.org/licenses
34 34
   </copyright>
35 35

  
36
   <license url="http://www.example.com/license"> -</license>
36
   <license url="http://www.example.com/license">
37
      -
38
   </license>
37 39

  
38 40
   <requires>
39 41
      <import plugin="org.eclipse.ui"/>
TXM/trunk/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java (revision 3518)
9 9
import org.apache.commons.lang.StringUtils;
10 10
import org.txm.concordance.core.preferences.ConcordancePreferences;
11 11
import org.txm.core.results.TXMParameters;
12
import org.txm.objects.CorpusBuild;
13
import org.txm.searchengine.core.IQuery;
14
import org.txm.searchengine.core.SearchEnginesManager;
15 12
import org.txm.searchengine.core.Selection;
16 13
import org.txm.searchengine.cqp.CQPSearchEngine;
17 14
import org.txm.searchengine.cqp.corpus.CQPCorpus;
18 15
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
19 16
import org.txm.searchengine.cqp.corpus.WordProperty;
20 17
import org.txm.searchengine.ts.TIGERQuery;
21
import org.txm.searchengine.ts.TIGERSearchEngine;
22 18
import org.txm.searchengine.ts.TSCorpus;
23 19
import org.txm.searchengine.ts.TSCorpusManager;
24 20
import org.txm.searchengine.ts.TSMatch;
25 21
import org.txm.searchengine.ts.TSResult;
26
import org.txm.tigersearch.preferences.TigerSearchPreferences;
27 22
import org.txm.tigersearch.rcp.Messages;
28 23
import org.txm.treesearch.function.TreeSearch;
29 24
import org.txm.treesearch.function.TreeSearchSelector;
......
31 26
import org.txm.utils.logger.Log;
32 27

  
33 28
import ims.tiger.index.reader.Index;
34
import ims.tiger.index.reader.IndexException;
35 29

  
36 30
public class TIGERSearch extends TreeSearch {
37 31
	
TXM/trunk/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 3518)
204 204
			TXMEditor.initContextMenu(this.specificitesTable, this.getSite(), this.viewer);
205 205
			
206 206
			// adjust UI to the original sorting
207
			specificitesTable.setSortColumn(unitColumn);
208
			specificitesTable.setSortDirection(SWT.UP);
207
			//specificitesTable.setSortColumn(unitColumn);
208
			//specificitesTable.setSortDirection(SWT.UP);
209 209
			
210 210
			if (!this.getResult().isParentVisible()) {
211 211
				
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 3518)
125 125
	
126 126
	public static final int MAX_NAME_LENGTH = 40;
127 127
	
128
	public static final int NMAXLINESTOTEST = 30;
129
	
128 130
	/**
129 131
	 * The editor main tool bar, positioned at the top of the editor.
130 132
	 */
......
1074 1076
	@SuppressWarnings("unchecked")
1075 1077
	public static <T extends TXMResult> TXMEditor<T> openEditor(TXMResultEditorInput<T> editorInput, String editorId) {
1076 1078
		
1077
		
1078
		
1079 1079
		TXMEditor<T> editor = null;
1080 1080
		IWorkbenchWindow window = TXMWindows.getActiveWindow();
1081 1081
		IWorkbenchPage page = window.getActivePage();
1082 1082
		try {
1083 1083
			boolean wasAlreadyOpened = SWTEditorsUtils.isOpenEditor(editorInput, editorId);
1084 1084
			if (!wasAlreadyOpened) {
1085
				try {StatusLine.setMessage(NLS.bind("Opening {0}...", editorInput.getResult().getSimpleName())); } catch(Exception e) {}
1085
				try {StatusLine.setMessage(NLS.bind(TXMUIMessages.openingP0etc, editorInput.getResult().getSimpleName())); } catch(Exception e) {}
1086 1086
			}
1087 1087
			// since some editor fields need some values of their parent,
1088 1088
			// ensure the parents branch is ready (e.g. Sub-corpus properties in Cooccurrence editor, etc.)
......
1765 1765
		TableColumn[] columns = viewer.getTable().getColumns();
1766 1766
		TableColumn sortedColumn = viewer.getTable().getSortColumn();
1767 1767
		int ncolumns = columns.length;
1768
		int nlinestotest = viewer.getTable().getItemCount();
1769
		if (nlinestotest > NMAXLINESTOTEST) nlinestotest = NMAXLINESTOTEST;
1768 1770
		
1769 1771
		Font font = viewer.getTable().getFont();
1770 1772
		FontData fd = font.getFontData()[0];
......
1776 1778
			TableColumn col = columns[i];
1777 1779
			int refMax = col.getText().length();
1778 1780
			
1779
			
1780
			for (TableItem item : viewer.getTable().getItems()) {
1781
			for (int j = 0 ; j < nlinestotest ; j++) { // get lines one per one to avoid loading the full table lines
1782
				TableItem item = viewer.getTable().getItem(j);
1781 1783
				if (refMax < item.getText(i).length()) refMax = item.getText(i).length();
1782 1784
			}
1783 1785
			
1784
			
1785 1786
			int w = 2 * (int) (refMax * W);
1786 1787
			if (col.equals(sortedColumn)) { // the sorted column has an extra marker to show
1787 1788
				w += 30;
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 3518)
5 5
_3=3. 
6 6
_default=par défaut
7 7
_default_2=Défaut
8
openingP0etc=Ouverture de {0}...
8 9
aBinaryCorpusIsATXMFileExtensionTxmOrZip=Un corpus TXM au format binaire est soit un fichier d'extension .txm ou .zip, soit un dossier composé des sous-dossiers 'html', 'data', 'registry', 'txm'
9 10
abort=Annuler
10 11
abortingLoadingOfPOACorpusWithTheSameCQPIDAlreadyExists=Un corpus avec le même identifiant {1} existe déjà. Abandon du chargement de {0}.
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 3518)
1482 1482
	public static String YouReGoingToLostThoseModificationsIfNotAlreadyExportedContinue;
1483 1483

  
1484 1484
	public static String defaultReferences;
1485

  
1486
	public static String openingP0etc;
1485 1487
	
1486 1488
	static {
1487 1489
		// initialize resource bundle
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 3518)
5 5
_3=3. 
6 6
_default=by default
7 7
_default_2=Default
8
openingP0etc=Opening {0}...
8 9
aBinaryCorpusIsATXMFileExtensionTxmOrZip=A TXM corpus in binary format is either a file with an extension .txm or .zip, or a compressed folder composed of sub-folders 'html', 'data', 'registry', 'txm'
9 10
abort=Abort
10 11
abortingLoadingOfPOACorpusWithTheSameCQPIDAlreadyExists=A corpus with the same identifier {1} already exists. Aborting loading of {0}.
TXM/trunk/org.txm.core/src/java/org/txm/core/engines/ScriptEngine.java (revision 3518)
37 37
	}
38 38
	
39 39
	public IStatus executeScript(File script) {
40
		return executeScript(script);
40
		return executeScript(script, null, null);
41 41
	}
42 42

  
43 43
	public IStatus executeScript(File script, HashMap<String, Object> env) {

Formats disponibles : Unified diff