mirror of https://github.com/percyliang/sempre
make Freebase demo (./run @mode=simple-freebase)
This commit is contained in:
parent
035a03c088
commit
54d7aad5f3
|
|
@ -40,14 +40,16 @@ Commands:
|
|||
! compute listing for all items in list
|
||||
EOF
|
||||
|
||||
$mid2id = TCPSocket.new('localhost', 4000)
|
||||
$server = 'freebase.cloudapp.net'
|
||||
|
||||
$mid2id = TCPSocket.new($server, 4000)
|
||||
def call(command)
|
||||
$mid2id.puts command
|
||||
result = $mid2id.gets.strip
|
||||
return nil if result == '__NULL__'
|
||||
return result
|
||||
end
|
||||
call("open\t/u/nlp/data/semparse/scr/freebase/freebase-rdf-2013-06-09-00-00.canonical-id-map")
|
||||
call("open\tfreebase-rdf-2013-06-09-00-00.canonical-id-map.gz")
|
||||
|
||||
# Explore the Freebase graph
|
||||
def fbsearch(query)
|
||||
|
|
@ -70,7 +72,7 @@ end
|
|||
def sparql(query)
|
||||
query = 'PREFIX fb: <http://rdf.freebase.com/ns/> ' + query + ' LIMIT 1000'
|
||||
encodedQuery = URI::encode(query).gsub(/\+/, '%2b')
|
||||
queryUrl = "http://localhost:3093/sparql?query=#{encodedQuery}"
|
||||
queryUrl = "http://#{$server}:3093/sparql?query=#{encodedQuery}"
|
||||
raw = open(queryUrl).read
|
||||
raw.sub!(/<sparql.*>/, '<sparql>') # Remove namespace
|
||||
xml = Nokogiri::XML(raw)
|
||||
|
|
|
|||
17
run
17
run
|
|
@ -415,15 +415,22 @@ addMode('simple-freebase', 'Simple shell for using Freebase', lambda { |e| l(
|
|||
letDefault(:cacheserver, 'freebase.cloudapp.net:4000'),
|
||||
sparqlOpts,
|
||||
# Set up Freebase search for entities
|
||||
# Assume run following on the server:
|
||||
# ./run @mode=cacheserver -readOnly -basePath lib/fb_data
|
||||
# Assume run following on the server (read-only and capacity are important!)
|
||||
# ./run @mode=cacheserver -readOnly -capacity MAX -basePath lib/fb_data
|
||||
o('FreebaseSearch.cachePath', 'FreebaseSearch.cache'),
|
||||
o('EntityLexicon.mid2idPath', lambda { |e| e[:cacheserver] + ':freebase-rdf-2013-06-09-00-00.canonical-id-map.gz' }),
|
||||
o('TypeInference.typeLookup', 'freebase.FreebaseTypeLookup'),
|
||||
o('FreebaseTypeLookup.entityTypesPath', lambda { |e| e[:cacheserver] + ':freebase-rdf-2013-06-09-00-00.canonicalized.en-types.gz' }),
|
||||
o('EntityLexicon.maxEntries', 3),
|
||||
o('coarsePrune'),
|
||||
o('interactive'),
|
||||
o('EntityLexicon.maxEntries', 2),
|
||||
o('Parser.coarsePrune'),
|
||||
o('JoinFn.typeInference'),
|
||||
o('UnaryLexicon.unaryLexiconFilePath', '/dev/null'),
|
||||
o('BinaryLexicon.binaryLexiconFilesPath', '/dev/null'),
|
||||
#o('JoinFn.showTypeCheckFailures'), # Use this to debug
|
||||
o('Grammar.inPaths', 'freebase/data/demo1.grammar'), # Override with your own custom grammar
|
||||
o('SparqlExecutor.returnTable'),
|
||||
#o('SparqlExecutor.includeSupportingInfo'), # Show full information
|
||||
o('Main.interactive'),
|
||||
nil) })
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -240,6 +240,9 @@ public class Master {
|
|||
FeatureVector.logChoices("Pred", choices);
|
||||
|
||||
// Print denotation
|
||||
LogInfo.begin_track("Top formula");
|
||||
LogInfo.logs("%s", deriv.formula);
|
||||
LogInfo.end_track();
|
||||
if (deriv.value != null) {
|
||||
LogInfo.begin_track("Top value");
|
||||
deriv.value.log();
|
||||
|
|
|
|||
Loading…
Reference in New Issue