## Process this file with automake to produce Makefile.in ## Copyright (C) 2011 Samediggi ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . # DESCRIPTION: # # Makefile to extract tags from a transducer. To be included from other # Makefile's. # # Requirement: tag _must_ start with or end with a plus ('+'). # The OR construction needs to be put into a variable for the parentheses to # survive 'make' and be visible to the shell - this at the same time silences # grep. GREPTAGSCOMMAND=( grep -E '(^\+.|.\+$$)' || echo '+NoTagsFound' ) # Extract the sigma set using either HFST or Xfst depending on the configuration # The sigma extraction is tuned to the peculiarities of both, and does produce # the exact same output. The sigma set can be used to extract further symbol # sets. The file sigma.txt contains one symbol pr line, and the whole line # is the symbol (minus final newline). if CAN_HFST # Hfst: break on comma + space in three steps, to preserve space as a symbol. sigma.txt: $(TAG_EXTRACTION_FST).hfst $(AM_V_GEN)$(HFST_SUMMARIZE) -v 2>/dev/null $^ \ | grep -A1 '^sigma set' \ | grep -v '^sigma set' \ | sed 's/, /\\\\\\/g' \ | perl -pe 's/\\\\\\/\n/g' \ | grep -v '^$$' \ | egrep -v '(@_EPSILON_SYMBOL_@|@_IDENTITY_SYMBOL_@|@_UNKNOWN_SYMBOL_@)' \ > $@ else if CAN_XFST # Special treatment of space (" "), break on space, special treatment of # reserved symbols ("X") and double quote. The Xfst file needs to be sorted. sigma.txt: $(TAG_EXTRACTION_FST).xfst $(AM_V_GEN)$(XFST) -q \ -e "load stack $^" \ -e "print sigma" \ -stop \ | grep -v '^Size' \ | sed 's/^Sigma: //' \ | sed 's/ //' \ | sed 's/" "/XXXXX/g' \ | tr ' ' '\n' \ | sed 's/XXXXX/ /g' \ | grep -v '^$$' \ | sed 's/^"\(.\)"$$/\1/' \ | sed 's/%\"/"/' \ | LCALL=C sort \ > $@ else # If neither Hfst nor Xfst is enabled, create an empty file: sigma.txt: touch $@ endif # CAN_XFST endif # CAN_HFST $(TAG_FILE): sigma.txt $(AM_V_GEN)$(GREPTAGSCOMMAND) < $< > $@